pingerchips-js 1.0.0-a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +14 -0
- package/.github/ISSUE_TEMPLATE.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- package/.github/dependabot.yml +14 -0
- package/.github/stale.yml +26 -0
- package/.github/workflows/release.yml +112 -0
- package/.github/workflows/release_pr.yml +43 -0
- package/.github/workflows/run-tests.yml +62 -0
- package/.gitmodules +3 -0
- package/.prettierrc +2 -0
- package/CHANGELOG.md +924 -0
- package/LICENCE +19 -0
- package/Makefile +78 -0
- package/README.md +707 -0
- package/bower.json +28 -0
- package/dist/node/pusher.js +10870 -0
- package/dist/node/pusher.js.map +1 -0
- package/dist/react-native/pusher.js +9 -0
- package/dist/react-native/pusher.js.map +1 -0
- package/dist/web/json2.js +486 -0
- package/dist/web/json2.min.js +1 -0
- package/dist/web/pusher-with-encryption.js +7009 -0
- package/dist/web/pusher-with-encryption.js.map +1 -0
- package/dist/web/pusher-with-encryption.min.js +9 -0
- package/dist/web/pusher-with-encryption.min.js.map +1 -0
- package/dist/web/pusher.js +4587 -0
- package/dist/web/pusher.js.map +1 -0
- package/dist/web/pusher.min.js +9 -0
- package/dist/web/pusher.min.js.map +1 -0
- package/dist/web/sockjs.js +2435 -0
- package/dist/web/sockjs.min.js +89 -0
- package/dist/worker/pusher-with-encryption.worker.js +6622 -0
- package/dist/worker/pusher-with-encryption.worker.js.map +1 -0
- package/dist/worker/pusher-with-encryption.worker.min.js +9 -0
- package/dist/worker/pusher-with-encryption.worker.min.js.map +1 -0
- package/dist/worker/pusher.worker.js +4200 -0
- package/dist/worker/pusher.worker.js.map +1 -0
- package/dist/worker/pusher.worker.min.js +9 -0
- package/dist/worker/pusher.worker.min.js.map +1 -0
- package/index.d.ts +29 -0
- package/integration_tests_server/index.js +176 -0
- package/integration_tests_server/package-lock.json +1177 -0
- package/integration_tests_server/package.json +15 -0
- package/node.js +1 -0
- package/package.json +70 -0
- package/pusher-with-encryption/index.js +1 -0
- package/react-native/index.d.ts +29 -0
- package/react-native/index.js +1 -0
- package/spec/config/jasmine/helpers/reporter.js +14 -0
- package/spec/config/jasmine/integration.json +13 -0
- package/spec/config/jasmine/unit.json +13 -0
- package/spec/config/jasmine/webpack.integration.js +33 -0
- package/spec/config/jasmine/webpack.unit.js +30 -0
- package/spec/config/karma/available_browsers.json +4957 -0
- package/spec/config/karma/config.ci.js +25 -0
- package/spec/config/karma/config.common.js +50 -0
- package/spec/config/karma/config.integration.js +26 -0
- package/spec/config/karma/config.unit.js +10 -0
- package/spec/config/karma/config.worker.js +34 -0
- package/spec/config/karma/integration.js +24 -0
- package/spec/config/karma/unit.js +20 -0
- package/spec/javascripts/helpers/mocks.js +274 -0
- package/spec/javascripts/helpers/node/integration.js +33 -0
- package/spec/javascripts/helpers/node/mock-dom-dependencies.ts +1 -0
- package/spec/javascripts/helpers/pusher_integration.js +1 -0
- package/spec/javascripts/helpers/pusher_integration_class.ts +12 -0
- package/spec/javascripts/helpers/timers/promises.js +9 -0
- package/spec/javascripts/helpers/waitsFor.js +37 -0
- package/spec/javascripts/helpers/web/integration.js +44 -0
- package/spec/javascripts/helpers/worker/mock-dom-dependencies.js +1 -0
- package/spec/javascripts/integration/core/cluster_config_spec.js +153 -0
- package/spec/javascripts/integration/core/falling_back_spec.js +195 -0
- package/spec/javascripts/integration/core/pusher_spec/index.js +68 -0
- package/spec/javascripts/integration/core/pusher_spec/test_builder.js +715 -0
- package/spec/javascripts/integration/core/timeout_configuration_spec.js +200 -0
- package/spec/javascripts/integration/core/transport_lists_spec.js +103 -0
- package/spec/javascripts/integration/index.node.js +12 -0
- package/spec/javascripts/integration/index.web.js +63 -0
- package/spec/javascripts/integration/index.worker.js +13 -0
- package/spec/javascripts/integration/web/dom/jsonp_spec.js +97 -0
- package/spec/javascripts/integration/web/dom/script_request_spec.js +90 -0
- package/spec/javascripts/polyfills/index.js +105 -0
- package/spec/javascripts/unit/core/channels/channel_spec.js +355 -0
- package/spec/javascripts/unit/core/channels/channels_spec.js +94 -0
- package/spec/javascripts/unit/core/channels/encrypted_channel_spec.js +343 -0
- package/spec/javascripts/unit/core/channels/presence_channel_spec.js +553 -0
- package/spec/javascripts/unit/core/channels/private_channel_spec.js +182 -0
- package/spec/javascripts/unit/core/config_spec.js +507 -0
- package/spec/javascripts/unit/core/connection/connection_manager_spec.js +656 -0
- package/spec/javascripts/unit/core/connection/connection_spec.js +286 -0
- package/spec/javascripts/unit/core/connection/handshake_spec.js +160 -0
- package/spec/javascripts/unit/core/connection/protocol_spec.js +420 -0
- package/spec/javascripts/unit/core/defaults_spec.js +26 -0
- package/spec/javascripts/unit/core/events_dispatcher_spec.js +385 -0
- package/spec/javascripts/unit/core/http/http_polling_socket_spec.js +60 -0
- package/spec/javascripts/unit/core/http/http_request_spec.js +185 -0
- package/spec/javascripts/unit/core/http/http_socket_spec.js +370 -0
- package/spec/javascripts/unit/core/http/http_streaming_socket_spec.js +56 -0
- package/spec/javascripts/unit/core/http/http_xhr_request_spec.js +164 -0
- package/spec/javascripts/unit/core/logger_spec.js +133 -0
- package/spec/javascripts/unit/core/pusher_spec.js +613 -0
- package/spec/javascripts/unit/core/pusher_with_encryption_spec.js +18 -0
- package/spec/javascripts/unit/core/strategies/best_connected_ever_strategy_spec.js +104 -0
- package/spec/javascripts/unit/core/strategies/delayed_strategy_spec.js +95 -0
- package/spec/javascripts/unit/core/strategies/first_connected_strategy_spec.js +68 -0
- package/spec/javascripts/unit/core/strategies/if_strategy_spec.js +165 -0
- package/spec/javascripts/unit/core/strategies/sequential_strategy_spec.js +213 -0
- package/spec/javascripts/unit/core/strategies/transport_strategy_spec.js +250 -0
- package/spec/javascripts/unit/core/strategies/websocket_prioritized_cached_strategy_spec.js +400 -0
- package/spec/javascripts/unit/core/timeline/timeline_spec.js +153 -0
- package/spec/javascripts/unit/core/transports/assistant_to_the_transport_manager_spec.js +223 -0
- package/spec/javascripts/unit/core/transports/hosts_and_ports_spec.js +85 -0
- package/spec/javascripts/unit/core/transports/transport_connection_spec.js +585 -0
- package/spec/javascripts/unit/core/transports/transport_manager_spec.js +64 -0
- package/spec/javascripts/unit/core/user_spec.js +303 -0
- package/spec/javascripts/unit/core/utils/periodic_timer_spec.js +74 -0
- package/spec/javascripts/unit/core/utils/timers_spec.js +157 -0
- package/spec/javascripts/unit/core/utils/url_store_spec.js +14 -0
- package/spec/javascripts/unit/core/watchlist_spec.js +48 -0
- package/spec/javascripts/unit/core_with_runtime/auth/channel_authorizer_spec.js +137 -0
- package/spec/javascripts/unit/core_with_runtime/auth/deprecated_channel_authorizer_spec.js +48 -0
- package/spec/javascripts/unit/core_with_runtime/auth/user_authorizer_spec.js +128 -0
- package/spec/javascripts/unit/core_with_runtime/readme.md +5 -0
- package/spec/javascripts/unit/index.node.js +11 -0
- package/spec/javascripts/unit/index.web.js +12 -0
- package/spec/javascripts/unit/index.worker.js +11 -0
- package/spec/javascripts/unit/isomorphic/transports/hosts_and_ports_spec.js +82 -0
- package/spec/javascripts/unit/isomorphic/transports/transports_spec.js +202 -0
- package/spec/javascripts/unit/node/timeline_sender_spec.js +83 -0
- package/spec/javascripts/unit/web/dom/dependency_loader_spec.js +249 -0
- package/spec/javascripts/unit/web/dom/jsonp_request_spec.js +130 -0
- package/spec/javascripts/unit/web/dom/script_receiver_factory_spec.js +68 -0
- package/spec/javascripts/unit/web/http/http_xdomain_request_spec.js +222 -0
- package/spec/javascripts/unit/web/pusher_authorizer_spec.js +64 -0
- package/spec/javascripts/unit/web/timeline/timeline_sender_spec.js +131 -0
- package/spec/javascripts/unit/web/transports/hosts_and_ports_spec.js +127 -0
- package/spec/javascripts/unit/web/transports/transports_spec.js +444 -0
- package/spec/javascripts/unit/worker/channel_authorizer_spec.js +156 -0
- package/spec/javascripts/unit/worker/timeline_sender_spec.js +76 -0
- package/src/core/auth/auth_transports.ts +18 -0
- package/src/core/auth/channel_authorizer.ts +64 -0
- package/src/core/auth/deprecated_channel_authorizer.ts +58 -0
- package/src/core/auth/options.ts +78 -0
- package/src/core/auth/user_authenticator.ts +62 -0
- package/src/core/base64.ts +49 -0
- package/src/core/channels/channel.ts +163 -0
- package/src/core/channels/channel_table.ts +7 -0
- package/src/core/channels/channels.ts +85 -0
- package/src/core/channels/encrypted_channel.ts +149 -0
- package/src/core/channels/members.ts +80 -0
- package/src/core/channels/metadata.ts +5 -0
- package/src/core/channels/presence_channel.ts +113 -0
- package/src/core/channels/private_channel.ts +25 -0
- package/src/core/config.ts +189 -0
- package/src/core/connection/callbacks.ts +21 -0
- package/src/core/connection/connection.ts +160 -0
- package/src/core/connection/connection_manager.ts +371 -0
- package/src/core/connection/connection_manager_options.ts +14 -0
- package/src/core/connection/handshake/handshake_payload.ts +10 -0
- package/src/core/connection/handshake/index.ts +90 -0
- package/src/core/connection/protocol/action.ts +8 -0
- package/src/core/connection/protocol/message-types.ts +8 -0
- package/src/core/connection/protocol/protocol.ts +154 -0
- package/src/core/defaults.ts +66 -0
- package/src/core/errors.ts +69 -0
- package/src/core/events/callback.ts +6 -0
- package/src/core/events/callback_registry.ts +75 -0
- package/src/core/events/callback_table.ts +7 -0
- package/src/core/events/dispatcher.ts +84 -0
- package/src/core/http/ajax.ts +24 -0
- package/src/core/http/http_factory.ts +16 -0
- package/src/core/http/http_polling_socket.ts +24 -0
- package/src/core/http/http_request.ts +81 -0
- package/src/core/http/http_socket.ts +220 -0
- package/src/core/http/http_streaming_socket.ts +19 -0
- package/src/core/http/request_hooks.ts +9 -0
- package/src/core/http/socket_hooks.ts +11 -0
- package/src/core/http/state.ts +7 -0
- package/src/core/http/url_location.ts +6 -0
- package/src/core/logger.ts +53 -0
- package/src/core/options.ts +59 -0
- package/src/core/pusher-licence.js +7 -0
- package/src/core/pusher-with-encryption.js +1 -0
- package/src/core/pusher-with-encryption.ts +14 -0
- package/src/core/pusher.js +2 -0
- package/src/core/pusher.ts +249 -0
- package/src/core/reachability.ts +7 -0
- package/src/core/socket.ts +14 -0
- package/src/core/strategies/best_connected_ever_strategy.ts +81 -0
- package/src/core/strategies/delayed_strategy.ts +48 -0
- package/src/core/strategies/first_connected_strategy.ts +28 -0
- package/src/core/strategies/if_strategy.ts +34 -0
- package/src/core/strategies/sequential_strategy.ts +129 -0
- package/src/core/strategies/strategy.ts +8 -0
- package/src/core/strategies/strategy_builder.ts +67 -0
- package/src/core/strategies/strategy_options.ts +18 -0
- package/src/core/strategies/strategy_runner.ts +6 -0
- package/src/core/strategies/transport_strategy.ts +144 -0
- package/src/core/strategies/websocket_prioritized_cached_strategy.ts +157 -0
- package/src/core/timeline/level.ts +7 -0
- package/src/core/timeline/timeline.ts +90 -0
- package/src/core/timeline/timeline_sender.ts +33 -0
- package/src/core/timeline/timeline_transport.ts +11 -0
- package/src/core/transports/assistant_to_the_transport_manager.ts +104 -0
- package/src/core/transports/ping_delay_options.ts +7 -0
- package/src/core/transports/transport.ts +54 -0
- package/src/core/transports/transport_connection.ts +241 -0
- package/src/core/transports/transport_connection_options.ts +8 -0
- package/src/core/transports/transport_hooks.ts +16 -0
- package/src/core/transports/transport_manager.ts +52 -0
- package/src/core/transports/transports_table.ts +12 -0
- package/src/core/transports/url_scheme.ts +13 -0
- package/src/core/transports/url_schemes.ts +47 -0
- package/src/core/user.ts +186 -0
- package/src/core/util.ts +34 -0
- package/src/core/utils/collections.ts +353 -0
- package/src/core/utils/factory.ts +75 -0
- package/src/core/utils/flat_promise.ts +10 -0
- package/src/core/utils/timers/abstract_timer.ts +39 -0
- package/src/core/utils/timers/index.ts +39 -0
- package/src/core/utils/timers/scheduling.ts +11 -0
- package/src/core/utils/timers/timed_callback.ts +5 -0
- package/src/core/utils/url_store.ts +48 -0
- package/src/core/watchlist.ts +31 -0
- package/src/d.ts/constants/index.d.ts +5 -0
- package/src/d.ts/faye-websocket/faye-websocket.d.ts +21 -0
- package/src/d.ts/global/global.d.ts +1 -0
- package/src/d.ts/module/module.d.ts +12 -0
- package/src/d.ts/tweetnacl-util/index.d.ts +6 -0
- package/src/d.ts/window/events.d.ts +4 -0
- package/src/d.ts/window/sockjs.d.ts +3 -0
- package/src/d.ts/window/websocket.d.ts +4 -0
- package/src/d.ts/window/xmlhttprequest.d.ts +3 -0
- package/src/runtimes/interface.ts +59 -0
- package/src/runtimes/isomorphic/auth/xhr_auth.ts +90 -0
- package/src/runtimes/isomorphic/default_strategy.ts +155 -0
- package/src/runtimes/isomorphic/http/http.ts +32 -0
- package/src/runtimes/isomorphic/http/http_xhr_request.ts +35 -0
- package/src/runtimes/isomorphic/runtime.ts +62 -0
- package/src/runtimes/isomorphic/timeline/xhr_timeline.ts +50 -0
- package/src/runtimes/isomorphic/transports/transport_connection_initializer.ts +19 -0
- package/src/runtimes/isomorphic/transports/transports.ts +81 -0
- package/src/runtimes/node/net_info.ts +10 -0
- package/src/runtimes/node/runtime.ts +68 -0
- package/src/runtimes/react-native/net_info.ts +42 -0
- package/src/runtimes/react-native/runtime.ts +65 -0
- package/src/runtimes/web/auth/jsonp_auth.ts +51 -0
- package/src/runtimes/web/browser.ts +24 -0
- package/src/runtimes/web/default_strategy.ts +201 -0
- package/src/runtimes/web/dom/dependencies.ts +16 -0
- package/src/runtimes/web/dom/dependency_loader.ts +93 -0
- package/src/runtimes/web/dom/json2.js +486 -0
- package/src/runtimes/web/dom/jsonp_request.ts +52 -0
- package/src/runtimes/web/dom/script_receiver.ts +8 -0
- package/src/runtimes/web/dom/script_receiver_factory.ts +57 -0
- package/src/runtimes/web/dom/script_request.ts +85 -0
- package/src/runtimes/web/dom/sockjs/COPYING +11 -0
- package/src/runtimes/web/dom/sockjs/Changelog +147 -0
- package/src/runtimes/web/dom/sockjs/LICENSE-MIT-SockJS +19 -0
- package/src/runtimes/web/dom/sockjs/Makefile +109 -0
- package/src/runtimes/web/dom/sockjs/README.md +388 -0
- package/src/runtimes/web/dom/sockjs/VERSION-GEN +17 -0
- package/src/runtimes/web/dom/sockjs/bin/render.coffee +111 -0
- package/src/runtimes/web/dom/sockjs/bin/run_testling.sh +135 -0
- package/src/runtimes/web/dom/sockjs/lib/all.js +9 -0
- package/src/runtimes/web/dom/sockjs/lib/dom.js +185 -0
- package/src/runtimes/web/dom/sockjs/lib/dom2.js +280 -0
- package/src/runtimes/web/dom/sockjs/lib/eventemitter.js +57 -0
- package/src/runtimes/web/dom/sockjs/lib/heartbeater.js +70 -0
- package/src/runtimes/web/dom/sockjs/lib/index.js +41 -0
- package/src/runtimes/web/dom/sockjs/lib/info.js +117 -0
- package/src/runtimes/web/dom/sockjs/lib/json2.min.js +1 -0
- package/src/runtimes/web/dom/sockjs/lib/reventtarget.js +55 -0
- package/src/runtimes/web/dom/sockjs/lib/simpleevent.js +28 -0
- package/src/runtimes/web/dom/sockjs/lib/sockjs.js +288 -0
- package/src/runtimes/web/dom/sockjs/lib/test-hooks.js +16 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-iframe-eventsource.js +29 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-iframe-htmlfile.js +35 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-iframe-within.js +100 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-iframe-xhr-polling.js +30 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-iframe.js +103 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-jsonp-polling.js +106 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-jsonp-receiver.js +116 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-polling.js +44 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-receiver-eventsource.js +41 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-receiver-htmlfile.js +65 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-receiver-xhr.js +42 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-sender.js +138 -0
- package/src/runtimes/web/dom/sockjs/lib/trans-xhr.js +29 -0
- package/src/runtimes/web/dom/sockjs/lib/utils.js +297 -0
- package/src/runtimes/web/dom/sockjs/package.json +18 -0
- package/src/runtimes/web/dom/sockjs/version +1 -0
- package/src/runtimes/web/http/http.ts +8 -0
- package/src/runtimes/web/http/http_xdomain_request.ts +37 -0
- package/src/runtimes/web/net_info.ts +50 -0
- package/src/runtimes/web/runtime.ts +174 -0
- package/src/runtimes/web/timeline/jsonp_timeline.ts +34 -0
- package/src/runtimes/web/transports/transport_connection_initializer.ts +39 -0
- package/src/runtimes/web/transports/transports.ts +65 -0
- package/src/runtimes/worker/auth/fetch_auth.ts +69 -0
- package/src/runtimes/worker/net_info.ts +10 -0
- package/src/runtimes/worker/runtime.ts +75 -0
- package/src/runtimes/worker/timeline/fetch_timeline.ts +39 -0
- package/tsconfig.json +26 -0
- package/types/spec/javascripts/helpers/node/mock-dom-dependencies.d.ts +1 -0
- package/types/spec/javascripts/helpers/pusher_integration_class.d.ts +4 -0
- package/types/src/core/auth/auth_transports.d.ts +9 -0
- package/types/src/core/auth/channel_authorizer.d.ts +3 -0
- package/types/src/core/auth/deprecated_channel_authorizer.d.ts +18 -0
- package/types/src/core/auth/options.d.ts +48 -0
- package/types/src/core/auth/user_authenticator.d.ts +3 -0
- package/types/src/core/base64.d.ts +1 -0
- package/types/src/core/channels/channel.d.ts +23 -0
- package/types/src/core/channels/channel_table.d.ts +5 -0
- package/types/src/core/channels/channels.d.ts +12 -0
- package/types/src/core/channels/encrypted_channel.d.ts +15 -0
- package/types/src/core/channels/members.d.ts +14 -0
- package/types/src/core/channels/metadata.d.ts +4 -0
- package/types/src/core/channels/presence_channel.d.ts +13 -0
- package/types/src/core/channels/private_channel.d.ts +5 -0
- package/types/src/core/config.d.ts +31 -0
- package/types/src/core/connection/callbacks.d.ts +18 -0
- package/types/src/core/connection/connection.d.ts +16 -0
- package/types/src/core/connection/connection_manager.d.ts +50 -0
- package/types/src/core/connection/connection_manager_options.d.ts +11 -0
- package/types/src/core/connection/handshake/handshake_payload.d.ts +8 -0
- package/types/src/core/connection/handshake/index.d.ts +12 -0
- package/types/src/core/connection/protocol/action.d.ts +7 -0
- package/types/src/core/connection/protocol/message-types.d.ts +7 -0
- package/types/src/core/connection/protocol/protocol.d.ts +10 -0
- package/types/src/core/defaults.d.ts +26 -0
- package/types/src/core/errors.d.ts +28 -0
- package/types/src/core/events/callback.d.ts +5 -0
- package/types/src/core/events/callback_registry.d.ts +11 -0
- package/types/src/core/events/callback_table.d.ts +5 -0
- package/types/src/core/events/dispatcher.d.ts +14 -0
- package/types/src/core/http/ajax.d.ts +16 -0
- package/types/src/core/http/http_factory.d.ts +13 -0
- package/types/src/core/http/http_polling_socket.d.ts +3 -0
- package/types/src/core/http/http_request.d.ts +17 -0
- package/types/src/core/http/http_socket.d.ts +32 -0
- package/types/src/core/http/http_streaming_socket.d.ts +3 -0
- package/types/src/core/http/request_hooks.d.ts +6 -0
- package/types/src/core/http/socket_hooks.d.ts +8 -0
- package/types/src/core/http/state.d.ts +6 -0
- package/types/src/core/http/url_location.d.ts +5 -0
- package/types/src/core/logger.d.ts +11 -0
- package/types/src/core/options.d.ts +34 -0
- package/types/src/core/pusher-with-encryption.d.ts +5 -0
- package/types/src/core/pusher.d.ts +49 -0
- package/types/src/core/reachability.d.ts +5 -0
- package/types/src/core/socket.d.ts +12 -0
- package/types/src/core/strategies/best_connected_ever_strategy.d.ts +10 -0
- package/types/src/core/strategies/delayed_strategy.d.ts +15 -0
- package/types/src/core/strategies/first_connected_strategy.d.ts +8 -0
- package/types/src/core/strategies/if_strategy.d.ts +10 -0
- package/types/src/core/strategies/sequential_strategy.d.ts +16 -0
- package/types/src/core/strategies/strategy.d.ts +6 -0
- package/types/src/core/strategies/strategy_builder.d.ts +5 -0
- package/types/src/core/strategies/strategy_options.d.ts +16 -0
- package/types/src/core/strategies/strategy_runner.d.ts +5 -0
- package/types/src/core/strategies/transport_strategy.d.ts +15 -0
- package/types/src/core/strategies/websocket_prioritized_cached_strategy.d.ts +20 -0
- package/types/src/core/timeline/level.d.ts +6 -0
- package/types/src/core/timeline/timeline.d.ts +25 -0
- package/types/src/core/timeline/timeline_sender.d.ts +13 -0
- package/types/src/core/timeline/timeline_transport.d.ts +6 -0
- package/types/src/core/transports/assistant_to_the_transport_manager.d.ts +14 -0
- package/types/src/core/transports/ping_delay_options.d.ts +6 -0
- package/types/src/core/transports/transport.d.ts +8 -0
- package/types/src/core/transports/transport_connection.d.ts +35 -0
- package/types/src/core/transports/transport_connection_options.d.ts +6 -0
- package/types/src/core/transports/transport_hooks.d.ts +13 -0
- package/types/src/core/transports/transport_manager.d.ts +14 -0
- package/types/src/core/transports/transports_table.d.ts +10 -0
- package/types/src/core/transports/url_scheme.d.ts +11 -0
- package/types/src/core/transports/url_schemes.d.ts +4 -0
- package/types/src/core/user.d.ts +21 -0
- package/types/src/core/util.d.ts +8 -0
- package/types/src/core/utils/collections.d.ts +18 -0
- package/types/src/core/utils/factory.d.ts +29 -0
- package/types/src/core/utils/flat_promise.d.ts +6 -0
- package/types/src/core/utils/timers/abstract_timer.d.ts +10 -0
- package/types/src/core/utils/timers/index.d.ts +9 -0
- package/types/src/core/utils/timers/scheduling.d.ts +8 -0
- package/types/src/core/utils/timers/timed_callback.d.ts +4 -0
- package/types/src/core/utils/url_store.d.ts +4 -0
- package/types/src/core/watchlist.d.ts +8 -0
- package/types/src/runtimes/interface.d.ts +43 -0
- package/types/src/runtimes/isomorphic/auth/xhr_auth.d.ts +3 -0
- package/types/src/runtimes/isomorphic/default_strategy.d.ts +5 -0
- package/types/src/runtimes/isomorphic/http/http.d.ts +3 -0
- package/types/src/runtimes/isomorphic/http/http_xhr_request.d.ts +3 -0
- package/types/src/runtimes/isomorphic/runtime.d.ts +2 -0
- package/types/src/runtimes/isomorphic/timeline/xhr_timeline.d.ts +6 -0
- package/types/src/runtimes/isomorphic/transports/transport_connection_initializer.d.ts +1 -0
- package/types/src/runtimes/isomorphic/transports/transports.d.ts +5 -0
- package/types/src/runtimes/node/net_info.d.ts +6 -0
- package/types/src/runtimes/node/runtime.d.ts +3 -0
- package/types/src/runtimes/react-native/net_info.d.ts +8 -0
- package/types/src/runtimes/react-native/runtime.d.ts +3 -0
- package/types/src/runtimes/web/auth/jsonp_auth.d.ts +3 -0
- package/types/src/runtimes/web/browser.d.ts +19 -0
- package/types/src/runtimes/web/default_strategy.d.ts +5 -0
- package/types/src/runtimes/web/dom/dependencies.d.ts +4 -0
- package/types/src/runtimes/web/dom/dependency_loader.d.ts +10 -0
- package/types/src/runtimes/web/dom/jsonp_request.d.ts +10 -0
- package/types/src/runtimes/web/dom/script_receiver.d.ts +7 -0
- package/types/src/runtimes/web/dom/script_receiver_factory.d.ts +10 -0
- package/types/src/runtimes/web/dom/script_request.d.ts +9 -0
- package/types/src/runtimes/web/http/http.d.ts +2 -0
- package/types/src/runtimes/web/http/http_xdomain_request.d.ts +3 -0
- package/types/src/runtimes/web/net_info.d.ts +7 -0
- package/types/src/runtimes/web/runtime.d.ts +3 -0
- package/types/src/runtimes/web/timeline/jsonp_timeline.d.ts +6 -0
- package/types/src/runtimes/web/transports/transport_connection_initializer.d.ts +1 -0
- package/types/src/runtimes/web/transports/transports.d.ts +2 -0
- package/types/src/runtimes/worker/auth/fetch_auth.d.ts +3 -0
- package/types/src/runtimes/worker/net_info.d.ts +6 -0
- package/types/src/runtimes/worker/runtime.d.ts +3 -0
- package/types/src/runtimes/worker/timeline/fetch_timeline.d.ts +6 -0
- package/webpack/config.node.js +26 -0
- package/webpack/config.react-native.js +35 -0
- package/webpack/config.shared.js +50 -0
- package/webpack/config.web.js +36 -0
- package/webpack/config.worker.js +42 -0
- package/webpack/dev.server.js +17 -0
- package/webpack/hosting_config.js +6 -0
- package/with-encryption/index.d.ts +29 -0
- package/with-encryption/index.js +4 -0
- package/worker/index.d.ts +29 -0
- package/worker/index.js +1 -0
- package/worker/with-encryption/index.d.ts +29 -0
- package/worker/with-encryption/index.js +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// The simplest and most robust transport, using the well-know cross
|
|
10
|
+
// domain hack - JSONP. This transport is quite inefficient - one
|
|
11
|
+
// mssage could use up to one http request. But at least it works almost
|
|
12
|
+
// everywhere.
|
|
13
|
+
// Known limitations:
|
|
14
|
+
// o you will get a spinning cursor
|
|
15
|
+
// o for Konqueror a dumb timer is needed to detect errors
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var JsonPTransport = SockJS['jsonp-polling'] = function(ri, trans_url) {
|
|
19
|
+
utils.polluteGlobalNamespace();
|
|
20
|
+
var that = this;
|
|
21
|
+
that.ri = ri;
|
|
22
|
+
that.trans_url = trans_url;
|
|
23
|
+
that.send_constructor(jsonPGenericSender);
|
|
24
|
+
that._schedule_recv();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Inheritnace
|
|
28
|
+
JsonPTransport.prototype = new BufferedSender();
|
|
29
|
+
|
|
30
|
+
JsonPTransport.prototype._schedule_recv = function() {
|
|
31
|
+
var that = this;
|
|
32
|
+
var callback = function(data) {
|
|
33
|
+
that._recv_stop = null;
|
|
34
|
+
if (data) {
|
|
35
|
+
// no data - heartbeat;
|
|
36
|
+
if (!that._is_closing) {
|
|
37
|
+
that.ri._didMessage(data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// The message can be a close message, and change is_closing state.
|
|
41
|
+
if (!that._is_closing) {
|
|
42
|
+
that._schedule_recv();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
that._recv_stop = jsonPReceiverWrapper(that.trans_url + '/jsonp',
|
|
46
|
+
jsonPGenericReceiver, callback);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
JsonPTransport.enabled = function() {
|
|
50
|
+
return true;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
JsonPTransport.need_body = true;
|
|
54
|
+
JsonPTransport.polling = true;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
JsonPTransport.prototype.doCleanup = function() {
|
|
58
|
+
var that = this;
|
|
59
|
+
that._is_closing = true;
|
|
60
|
+
if (that._recv_stop) {
|
|
61
|
+
that._recv_stop();
|
|
62
|
+
}
|
|
63
|
+
that.ri = that._recv_stop = null;
|
|
64
|
+
that.send_destructor();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// Abstract away code that handles global namespace pollution.
|
|
69
|
+
var jsonPReceiverWrapper = function(url, constructReceiver, user_callback) {
|
|
70
|
+
var id = 'a' + utils.random_string(6);
|
|
71
|
+
var url_id = url + '?c=' + escape(WPrefix + '.' + id);
|
|
72
|
+
|
|
73
|
+
// Unfortunately it is not possible to abort loading of the
|
|
74
|
+
// script. We need to keep track of frake close frames.
|
|
75
|
+
var aborting = 0;
|
|
76
|
+
|
|
77
|
+
// Callback will be called exactly once.
|
|
78
|
+
var callback = function(frame) {
|
|
79
|
+
switch(aborting) {
|
|
80
|
+
case 0:
|
|
81
|
+
// Normal behaviour - delete hook _and_ emit message.
|
|
82
|
+
delete _window[WPrefix][id];
|
|
83
|
+
user_callback(frame);
|
|
84
|
+
break;
|
|
85
|
+
case 1:
|
|
86
|
+
// Fake close frame - emit but don't delete hook.
|
|
87
|
+
user_callback(frame);
|
|
88
|
+
aborting = 2;
|
|
89
|
+
break;
|
|
90
|
+
case 2:
|
|
91
|
+
// Got frame after connection was closed, delete hook, don't emit.
|
|
92
|
+
delete _window[WPrefix][id];
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var close_script = constructReceiver(url_id, callback);
|
|
98
|
+
_window[WPrefix][id] = close_script;
|
|
99
|
+
var stop = function() {
|
|
100
|
+
if (_window[WPrefix][id]) {
|
|
101
|
+
aborting = 1;
|
|
102
|
+
_window[WPrefix][id](utils.closeFrame(1000, "JSONP user aborted read"));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return stop;
|
|
106
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Parts derived from Socket.io:
|
|
10
|
+
// https://github.com/LearnBoost/socket.io/blob/0.6.17/lib/socket.io/transports/jsonp-polling.js
|
|
11
|
+
// and jQuery-JSONP:
|
|
12
|
+
// https://code.google.com/p/jquery-jsonp/source/browse/trunk/core/jquery.jsonp.js
|
|
13
|
+
var jsonPGenericReceiver = function(url, callback) {
|
|
14
|
+
var tref;
|
|
15
|
+
var script = _document.createElement('script');
|
|
16
|
+
var script2; // Opera synchronous load trick.
|
|
17
|
+
var close_script = function(frame) {
|
|
18
|
+
if (script2) {
|
|
19
|
+
script2.parentNode.removeChild(script2);
|
|
20
|
+
script2 = null;
|
|
21
|
+
}
|
|
22
|
+
if (script) {
|
|
23
|
+
clearTimeout(tref);
|
|
24
|
+
// Unfortunately, you can't really abort script loading of
|
|
25
|
+
// the script.
|
|
26
|
+
script.parentNode.removeChild(script);
|
|
27
|
+
script.onreadystatechange = script.onerror =
|
|
28
|
+
script.onload = script.onclick = null;
|
|
29
|
+
script = null;
|
|
30
|
+
callback(frame);
|
|
31
|
+
callback = null;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// IE9 fires 'error' event after orsc or before, in random order.
|
|
36
|
+
var loaded_okay = false;
|
|
37
|
+
var error_timer = null;
|
|
38
|
+
|
|
39
|
+
script.id = 'a' + utils.random_string(8);
|
|
40
|
+
script.src = url;
|
|
41
|
+
script.type = 'text/javascript';
|
|
42
|
+
script.charset = 'UTF-8';
|
|
43
|
+
script.onerror = function(e) {
|
|
44
|
+
if (!error_timer) {
|
|
45
|
+
// Delay firing close_script.
|
|
46
|
+
error_timer = setTimeout(function() {
|
|
47
|
+
if (!loaded_okay) {
|
|
48
|
+
close_script(utils.closeFrame(
|
|
49
|
+
1006,
|
|
50
|
+
"JSONP script loaded abnormally (onerror)"));
|
|
51
|
+
}
|
|
52
|
+
}, 1000);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
script.onload = function(e) {
|
|
56
|
+
close_script(utils.closeFrame(1006, "JSONP script loaded abnormally (onload)"));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
script.onreadystatechange = function(e) {
|
|
60
|
+
if (/loaded|closed/.test(script.readyState)) {
|
|
61
|
+
if (script && script.htmlFor && script.onclick) {
|
|
62
|
+
loaded_okay = true;
|
|
63
|
+
try {
|
|
64
|
+
// In IE, actually execute the script.
|
|
65
|
+
script.onclick();
|
|
66
|
+
} catch (x) {}
|
|
67
|
+
}
|
|
68
|
+
if (script) {
|
|
69
|
+
close_script(utils.closeFrame(1006, "JSONP script loaded abnormally (onreadystatechange)"));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
// IE: event/htmlFor/onclick trick.
|
|
74
|
+
// One can't rely on proper order for onreadystatechange. In order to
|
|
75
|
+
// make sure, set a 'htmlFor' and 'event' properties, so that
|
|
76
|
+
// script code will be installed as 'onclick' handler for the
|
|
77
|
+
// script object. Later, onreadystatechange, manually execute this
|
|
78
|
+
// code. FF and Chrome doesn't work with 'event' and 'htmlFor'
|
|
79
|
+
// set. For reference see:
|
|
80
|
+
// http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html
|
|
81
|
+
// Also, read on that about script ordering:
|
|
82
|
+
// http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order
|
|
83
|
+
if (typeof script.async === 'undefined' && _document.attachEvent) {
|
|
84
|
+
// According to mozilla docs, in recent browsers script.async defaults
|
|
85
|
+
// to 'true', so we may use it to detect a good browser:
|
|
86
|
+
// https://developer.mozilla.org/en/HTML/Element/script
|
|
87
|
+
if (!/opera/i.test(navigator.userAgent)) {
|
|
88
|
+
// Naively assume we're in IE
|
|
89
|
+
try {
|
|
90
|
+
script.htmlFor = script.id;
|
|
91
|
+
script.event = "onclick";
|
|
92
|
+
} catch (x) {}
|
|
93
|
+
script.async = true;
|
|
94
|
+
} else {
|
|
95
|
+
// Opera, second sync script hack
|
|
96
|
+
script2 = _document.createElement('script');
|
|
97
|
+
script2.text = "try{var a = document.getElementById('"+script.id+"'); if(a)a.onerror();}catch(x){};";
|
|
98
|
+
script.async = script2.async = false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (typeof script.async !== 'undefined') {
|
|
102
|
+
script.async = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Fallback mostly for Konqueror - stupid timer, 35 seconds shall be plenty.
|
|
106
|
+
tref = setTimeout(function() {
|
|
107
|
+
close_script(utils.closeFrame(1006, "JSONP script loaded abnormally (timeout)"));
|
|
108
|
+
}, 35000);
|
|
109
|
+
|
|
110
|
+
var head = _document.getElementsByTagName('head')[0];
|
|
111
|
+
head.insertBefore(script, head.firstChild);
|
|
112
|
+
if (script2) {
|
|
113
|
+
head.insertBefore(script2, head.firstChild);
|
|
114
|
+
}
|
|
115
|
+
return close_script;
|
|
116
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var Polling = function(ri, Receiver, recv_url, AjaxObject) {
|
|
10
|
+
var that = this;
|
|
11
|
+
that.ri = ri;
|
|
12
|
+
that.Receiver = Receiver;
|
|
13
|
+
that.recv_url = recv_url;
|
|
14
|
+
that.AjaxObject = AjaxObject;
|
|
15
|
+
that._scheduleRecv();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Polling.prototype._scheduleRecv = function() {
|
|
19
|
+
var that = this;
|
|
20
|
+
var poll = that.poll = new that.Receiver(that.recv_url, that.AjaxObject);
|
|
21
|
+
var msg_counter = 0;
|
|
22
|
+
poll.onmessage = function(e) {
|
|
23
|
+
msg_counter += 1;
|
|
24
|
+
that.ri._didMessage(e.data);
|
|
25
|
+
};
|
|
26
|
+
poll.onclose = function(e) {
|
|
27
|
+
that.poll = poll = poll.onmessage = poll.onclose = null;
|
|
28
|
+
if (!that.poll_is_closing) {
|
|
29
|
+
if (e.reason === 'permanent') {
|
|
30
|
+
that.ri._didClose(1006, 'Polling error (' + e.reason + ')');
|
|
31
|
+
} else {
|
|
32
|
+
that._scheduleRecv();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Polling.prototype.abort = function() {
|
|
39
|
+
var that = this;
|
|
40
|
+
that.poll_is_closing = true;
|
|
41
|
+
if (that.poll) {
|
|
42
|
+
that.poll.abort();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var EventSourceReceiver = function(url) {
|
|
10
|
+
var that = this;
|
|
11
|
+
var es = new EventSource(url);
|
|
12
|
+
es.onmessage = function(e) {
|
|
13
|
+
that.dispatchEvent(new SimpleEvent('message',
|
|
14
|
+
{'data': unescape(e.data)}));
|
|
15
|
+
};
|
|
16
|
+
that.es_close = es.onerror = function(e, abort_reason) {
|
|
17
|
+
// ES on reconnection has readyState = 0 or 1.
|
|
18
|
+
// on network error it's CLOSED = 2
|
|
19
|
+
var reason = abort_reason ? 'user' :
|
|
20
|
+
(es.readyState !== 2 ? 'network' : 'permanent');
|
|
21
|
+
that.es_close = es.onmessage = es.onerror = null;
|
|
22
|
+
// EventSource reconnects automatically.
|
|
23
|
+
es.close();
|
|
24
|
+
es = null;
|
|
25
|
+
// Safari and chrome < 15 crash if we close window before
|
|
26
|
+
// waiting for ES cleanup. See:
|
|
27
|
+
// https://code.google.com/p/chromium/issues/detail?id=89155
|
|
28
|
+
utils.delay(200, function() {
|
|
29
|
+
that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
EventSourceReceiver.prototype = new REventTarget();
|
|
35
|
+
|
|
36
|
+
EventSourceReceiver.prototype.abort = function() {
|
|
37
|
+
var that = this;
|
|
38
|
+
if (that.es_close) {
|
|
39
|
+
that.es_close({}, true);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var _is_ie_htmlfile_capable;
|
|
10
|
+
var isIeHtmlfileCapable = function() {
|
|
11
|
+
if (_is_ie_htmlfile_capable === undefined) {
|
|
12
|
+
if ('ActiveXObject' in _window) {
|
|
13
|
+
try {
|
|
14
|
+
_is_ie_htmlfile_capable = !!new ActiveXObject('htmlfile');
|
|
15
|
+
} catch (x) {}
|
|
16
|
+
} else {
|
|
17
|
+
_is_ie_htmlfile_capable = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return _is_ie_htmlfile_capable;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var HtmlfileReceiver = function(url) {
|
|
25
|
+
var that = this;
|
|
26
|
+
utils.polluteGlobalNamespace();
|
|
27
|
+
|
|
28
|
+
that.id = 'a' + utils.random_string(6, 26);
|
|
29
|
+
url += ((url.indexOf('?') === -1) ? '?' : '&') +
|
|
30
|
+
'c=' + escape(WPrefix + '.' + that.id);
|
|
31
|
+
|
|
32
|
+
var constructor = isIeHtmlfileCapable() ?
|
|
33
|
+
utils.createHtmlfile : utils.createIframe;
|
|
34
|
+
|
|
35
|
+
var iframeObj;
|
|
36
|
+
_window[WPrefix][that.id] = {
|
|
37
|
+
start: function () {
|
|
38
|
+
iframeObj.loaded();
|
|
39
|
+
},
|
|
40
|
+
message: function (data) {
|
|
41
|
+
that.dispatchEvent(new SimpleEvent('message', {'data': data}));
|
|
42
|
+
},
|
|
43
|
+
stop: function () {
|
|
44
|
+
that.iframe_close({}, 'network');
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
that.iframe_close = function(e, abort_reason) {
|
|
48
|
+
iframeObj.cleanup();
|
|
49
|
+
that.iframe_close = iframeObj = null;
|
|
50
|
+
delete _window[WPrefix][that.id];
|
|
51
|
+
that.dispatchEvent(new SimpleEvent('close', {reason: abort_reason}));
|
|
52
|
+
};
|
|
53
|
+
iframeObj = constructor(url, function(e) {
|
|
54
|
+
that.iframe_close({}, 'permanent');
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
HtmlfileReceiver.prototype = new REventTarget();
|
|
59
|
+
|
|
60
|
+
HtmlfileReceiver.prototype.abort = function() {
|
|
61
|
+
var that = this;
|
|
62
|
+
if (that.iframe_close) {
|
|
63
|
+
that.iframe_close({}, 'user');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var XhrReceiver = function(url, AjaxObject) {
|
|
10
|
+
var that = this;
|
|
11
|
+
var buf_pos = 0;
|
|
12
|
+
|
|
13
|
+
that.xo = new AjaxObject('POST', url, null);
|
|
14
|
+
that.xo.onchunk = function(status, text) {
|
|
15
|
+
if (status !== 200) return;
|
|
16
|
+
while (1) {
|
|
17
|
+
var buf = text.slice(buf_pos);
|
|
18
|
+
var p = buf.indexOf('\n');
|
|
19
|
+
if (p === -1) break;
|
|
20
|
+
buf_pos += p+1;
|
|
21
|
+
var msg = buf.slice(0, p);
|
|
22
|
+
that.dispatchEvent(new SimpleEvent('message', {data: msg}));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
that.xo.onfinish = function(status, text) {
|
|
26
|
+
that.xo.onchunk(status, text);
|
|
27
|
+
that.xo = null;
|
|
28
|
+
var reason = status === 200 ? 'network' : 'permanent';
|
|
29
|
+
that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
XhrReceiver.prototype = new REventTarget();
|
|
34
|
+
|
|
35
|
+
XhrReceiver.prototype.abort = function() {
|
|
36
|
+
var that = this;
|
|
37
|
+
if (that.xo) {
|
|
38
|
+
that.xo.close();
|
|
39
|
+
that.dispatchEvent(new SimpleEvent('close', {reason: 'user'}));
|
|
40
|
+
that.xo = null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var BufferedSender = function() {};
|
|
10
|
+
BufferedSender.prototype.send_constructor = function(sender) {
|
|
11
|
+
var that = this;
|
|
12
|
+
that.send_buffer = [];
|
|
13
|
+
that.sender = sender;
|
|
14
|
+
that.init_window_size = that.ri._options.init_window_size;
|
|
15
|
+
that.window_size = that.init_window_size;
|
|
16
|
+
that.max_window_time = that.ri._options.max_window_time;
|
|
17
|
+
};
|
|
18
|
+
BufferedSender.prototype.doSend = function(message) {
|
|
19
|
+
var that = this;
|
|
20
|
+
if (message.length > 0) {
|
|
21
|
+
that.send_buffer.push(message);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (that.send_stop && message.length == 0) {
|
|
25
|
+
that.ri._debug('Attempting to send a heartbeat, but sending previous messages is still in progress.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!that.send_stop) {
|
|
29
|
+
that.send_schedule();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
BufferedSender.prototype.adjustWindow = function(td, full_window) {
|
|
35
|
+
var that = this;
|
|
36
|
+
if (td > that.max_window_time) {
|
|
37
|
+
// Over time, reduce window
|
|
38
|
+
that.window_size = Math.max(that.window_size / 2,
|
|
39
|
+
that.init_window_size);
|
|
40
|
+
return true;
|
|
41
|
+
} else {
|
|
42
|
+
if (full_window) {
|
|
43
|
+
if (td*2 < that.max_window_time) {
|
|
44
|
+
// A lot time left
|
|
45
|
+
that.window_size *= 2;
|
|
46
|
+
} else {
|
|
47
|
+
// Not so much time left...
|
|
48
|
+
that.window_size *= 1.1;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// For polling transports in a situation when in the message callback,
|
|
57
|
+
// new message is being send. If the sending connection was started
|
|
58
|
+
// before receiving one, it is possible to saturate the network and
|
|
59
|
+
// timeout due to the lack of receiving socket. To avoid that we delay
|
|
60
|
+
// sending messages by some small time, in order to let receiving
|
|
61
|
+
// connection be started beforehand. This is only a halfmeasure and
|
|
62
|
+
// does not fix the big problem, but it does make the tests go more
|
|
63
|
+
// stable on slow networks.
|
|
64
|
+
BufferedSender.prototype.send_schedule_wait = function() {
|
|
65
|
+
var that = this;
|
|
66
|
+
var tref;
|
|
67
|
+
that.send_stop = function() {
|
|
68
|
+
that.send_stop = null;
|
|
69
|
+
clearTimeout(tref);
|
|
70
|
+
};
|
|
71
|
+
tref = utils.delay(25, function() {
|
|
72
|
+
that.send_stop = null;
|
|
73
|
+
if (that.send_buffer.length > 0) {
|
|
74
|
+
that.send_schedule();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
BufferedSender.prototype.send_schedule = function() {
|
|
80
|
+
var that = this;
|
|
81
|
+
var t0 = +new Date();
|
|
82
|
+
var i, serialized = 2, full_window = false;
|
|
83
|
+
for (i=0; i < that.send_buffer.length; i++) {
|
|
84
|
+
serialized += that.send_buffer[i].length + 1;
|
|
85
|
+
if (serialized > that.window_size) {
|
|
86
|
+
full_window = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Splice removes messages from the array.
|
|
91
|
+
var messages = that.send_buffer.splice(0, i);
|
|
92
|
+
|
|
93
|
+
var payload = '[' + messages.join(',') + ']';
|
|
94
|
+
that.send_stop = that.sender(that.trans_url, payload, function(success, abort_reason) {
|
|
95
|
+
that.send_stop = null;
|
|
96
|
+
if (success === false) {
|
|
97
|
+
that.ri._didClose(1006, 'Sending error ' + abort_reason);
|
|
98
|
+
} else {
|
|
99
|
+
var td = (+new Date()) - t0;
|
|
100
|
+
if (that.adjustWindow(td, full_window)) {
|
|
101
|
+
that.ri._debug('window_size adjusted: ' + that.window_size);
|
|
102
|
+
}
|
|
103
|
+
that.send_schedule_wait();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
BufferedSender.prototype.send_destructor = function() {
|
|
109
|
+
var that = this;
|
|
110
|
+
if (that.send_stop) {
|
|
111
|
+
that.send_stop();
|
|
112
|
+
}
|
|
113
|
+
that.send_stop = null;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var jsonPGenericSender = function(url, payload, callback) {
|
|
117
|
+
var that = this;
|
|
118
|
+
var js = new JsonpSender(url, payload, that);
|
|
119
|
+
js.onfinish = function(){
|
|
120
|
+
callback(true);
|
|
121
|
+
};
|
|
122
|
+
return function(){
|
|
123
|
+
js.close();
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var createAjaxSender = function(AjaxObject) {
|
|
128
|
+
return function(url, payload, callback) {
|
|
129
|
+
var xo = new AjaxObject('POST', url + '/xhr_send', payload);
|
|
130
|
+
xo.onfinish = function(status, text) {
|
|
131
|
+
callback(status === 200 || status === 204,
|
|
132
|
+
'http status ' + status);
|
|
133
|
+
};
|
|
134
|
+
return function(abort_reason) {
|
|
135
|
+
xo.close();
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
3
|
+
* Copyright (c) 2011-2012 VMware, Inc.
|
|
4
|
+
*
|
|
5
|
+
* For the license see COPYING.
|
|
6
|
+
* ***** END LICENSE BLOCK *****
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var AjaxBasedTransport = function() {};
|
|
10
|
+
AjaxBasedTransport.prototype = new BufferedSender();
|
|
11
|
+
|
|
12
|
+
AjaxBasedTransport.prototype.run = function(ri, trans_url,
|
|
13
|
+
url_suffix, Receiver, AjaxObject) {
|
|
14
|
+
var that = this;
|
|
15
|
+
that.ri = ri;
|
|
16
|
+
that.trans_url = trans_url;
|
|
17
|
+
that.send_constructor(createAjaxSender(AjaxObject));
|
|
18
|
+
that.poll = new Polling(ri, Receiver,
|
|
19
|
+
trans_url + url_suffix, AjaxObject);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
AjaxBasedTransport.prototype.doCleanup = function() {
|
|
23
|
+
var that = this;
|
|
24
|
+
if (that.poll) {
|
|
25
|
+
that.poll.abort();
|
|
26
|
+
that.poll = null;
|
|
27
|
+
}
|
|
28
|
+
that.send_destructor();
|
|
29
|
+
};
|