@cendarsoss/pusher-js 8.4.11
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 +928 -0
- package/DELTA_COMPRESSION.md +365 -0
- package/DELTA_USAGE.md +179 -0
- package/IMPLEMENTATION_SUMMARY.md +261 -0
- package/IMPORT_GUIDE.md +638 -0
- package/LIBRARY_STRUCTURE_ANALYSIS.md +940 -0
- package/LICENCE +19 -0
- package/Makefile +14 -0
- package/README.md +709 -0
- package/TAG_FILTERING_CLIENT.md +471 -0
- package/bower.json +19 -0
- package/bun.lock +2695 -0
- package/dist/node/filter.js +252 -0
- package/dist/node/filter.js.map +1 -0
- package/dist/node/pusher.js +4434 -0
- package/dist/node/pusher.js.map +1 -0
- package/dist/web/filter.mjs +252 -0
- package/dist/web/filter.mjs.map +1 -0
- package/dist/web/pusher.mjs +5889 -0
- package/dist/web/pusher.mjs.map +1 -0
- package/examples/delta-compression-example.html +372 -0
- package/examples/delta-seamless-example.html +185 -0
- package/index.d.ts +36 -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/interactive/.env +16 -0
- package/interactive/CONFLATION_TEST.md +73 -0
- package/interactive/DELTA_COMPRESSION_TESTING.md +262 -0
- package/interactive/bun.lock +208 -0
- package/interactive/package-lock.json +1075 -0
- package/interactive/package.json +32 -0
- package/interactive/public/app.js +1363 -0
- package/interactive/public/bundle-entry.js +14 -0
- package/interactive/public/conflation-test.html +508 -0
- package/interactive/public/conflation-test.js +785 -0
- package/interactive/public/delta-compression.js +1090 -0
- package/interactive/public/dist/bundle.js +5857 -0
- package/interactive/public/index.html +392 -0
- package/interactive/public/main.js +20 -0
- package/interactive/public/style.css +823 -0
- package/interactive/server.js +246 -0
- package/interactive/test-bundle.html +89 -0
- package/interactive/test-delta.js +146 -0
- package/node.js +1 -0
- package/package.json +94 -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 +56 -0
- package/src/core/auth/options.ts +76 -0
- package/src/core/auth/user_authenticator.ts +62 -0
- package/src/core/base64.ts +49 -0
- package/src/core/channels/channel.ts +173 -0
- package/src/core/channels/channel_table.ts +7 -0
- package/src/core/channels/channels.ts +86 -0
- package/src/core/channels/encrypted_channel.ts +150 -0
- package/src/core/channels/filter.ts +342 -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 +11 -0
- package/src/core/connection/protocol/protocol.ts +166 -0
- package/src/core/defaults.ts +66 -0
- package/src/core/delta/channel_state.ts +194 -0
- package/src/core/delta/decoders.ts +129 -0
- package/src/core/delta/index.ts +10 -0
- package/src/core/delta/manager.ts +504 -0
- package/src/core/delta/types.ts +60 -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 +66 -0
- package/src/core/options.ts +61 -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 +10 -0
- package/src/core/pusher.ts +412 -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 +31 -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 +79 -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/filter.ts +5 -0
- package/src/index.ts +8 -0
- package/src/runtimes/interface.ts +60 -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 +83 -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/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 +67 -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 +18 -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 +25 -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/filter.d.ts +33 -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 +10 -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/delta/channel_state.d.ts +23 -0
- package/types/src/core/delta/decoders.d.ts +12 -0
- package/types/src/core/delta/index.d.ts +4 -0
- package/types/src/core/delta/manager.d.ts +27 -0
- package/types/src/core/delta/types.d.ts +50 -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 +36 -0
- package/types/src/core/pusher-with-encryption.d.ts +5 -0
- package/types/src/core/pusher.d.ts +56 -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/vite.config.js +52 -0
- package/vite.config.node.js +72 -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,246 @@
|
|
|
1
|
+
// server.js
|
|
2
|
+
require("dotenv").config();
|
|
3
|
+
const express = require("express");
|
|
4
|
+
const bodyParser = require("body-parser");
|
|
5
|
+
const Pusher = require("pusher");
|
|
6
|
+
const crypto = require("crypto");
|
|
7
|
+
|
|
8
|
+
const app = express();
|
|
9
|
+
const port = process.env.BACKEND_PORT || 3000;
|
|
10
|
+
|
|
11
|
+
// Configure Pusher for your WebSocket server
|
|
12
|
+
const pusher = new Pusher({
|
|
13
|
+
appId: process.env.PUSHER_APP_ID,
|
|
14
|
+
key: process.env.PUSHER_APP_KEY,
|
|
15
|
+
secret: process.env.PUSHER_APP_SECRET,
|
|
16
|
+
cluster: "mt1",
|
|
17
|
+
host: process.env.PUSHER_HOST,
|
|
18
|
+
port: process.env.PUSHER_PORT,
|
|
19
|
+
useTLS: process.env.PUSHER_USE_TLS === "true",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
console.log("Pusher Server SDK configured for:", {
|
|
23
|
+
appId: process.env.PUSHER_APP_ID,
|
|
24
|
+
key: process.env.PUSHER_APP_KEY ? "***" : "Not Set",
|
|
25
|
+
secret: process.env.PUSHER_APP_SECRET ? "***" : "Not Set",
|
|
26
|
+
host: process.env.PUSHER_HOST,
|
|
27
|
+
port: process.env.PUSHER_PORT,
|
|
28
|
+
useTLS: process.env.PUSHER_USE_TLS === "true",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Store received webhooks and active channels
|
|
32
|
+
let receivedWebhooks = [];
|
|
33
|
+
let activeChannels = new Set();
|
|
34
|
+
let eventHistory = [];
|
|
35
|
+
|
|
36
|
+
// Middleware
|
|
37
|
+
app.use(express.static("public"));
|
|
38
|
+
app.use(
|
|
39
|
+
bodyParser.json({
|
|
40
|
+
verify: (req, res, buf) => {
|
|
41
|
+
req.rawBody = buf;
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
app.use(bodyParser.urlencoded({ extended: false }));
|
|
46
|
+
|
|
47
|
+
// Routes
|
|
48
|
+
|
|
49
|
+
// Frontend config endpoint
|
|
50
|
+
app.get("/config", (req, res) => {
|
|
51
|
+
res.json({
|
|
52
|
+
pusherKey: process.env.PUSHER_APP_KEY,
|
|
53
|
+
pusherHost: process.env.PUSHER_HOST,
|
|
54
|
+
pusherPort: process.env.PUSHER_PORT,
|
|
55
|
+
pusherUseTLS: process.env.PUSHER_USE_TLS === "true",
|
|
56
|
+
authEndpoint: `${process.env.BACKEND_BASE_URL}/pusher/auth`,
|
|
57
|
+
pusherCluster: "mt1",
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Authentication endpoint
|
|
62
|
+
app.post("/pusher/auth", (req, res) => {
|
|
63
|
+
const socketId = req.body.socket_id;
|
|
64
|
+
const channel = req.body.channel_name;
|
|
65
|
+
|
|
66
|
+
console.log(`Auth attempt for socket_id: ${socketId}, channel: ${channel}`);
|
|
67
|
+
|
|
68
|
+
const MOCK_USER_ID = `user_${Math.random().toString(36).substr(2, 9)}`;
|
|
69
|
+
const MOCK_USER_INFO = {
|
|
70
|
+
name: `Test User ${MOCK_USER_ID.split("_")[1]}`,
|
|
71
|
+
id: MOCK_USER_ID,
|
|
72
|
+
avatar: `https://ui-avatars.com/api/?name=${MOCK_USER_ID}&background=random`,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (channel.startsWith("private-")) {
|
|
77
|
+
const authResponse = pusher.authorizeChannel(socketId, channel);
|
|
78
|
+
console.log("Auth success (private):", authResponse);
|
|
79
|
+
res.send(authResponse);
|
|
80
|
+
} else if (channel.startsWith("presence-")) {
|
|
81
|
+
const presenceData = {
|
|
82
|
+
user_id: MOCK_USER_ID,
|
|
83
|
+
user_info: MOCK_USER_INFO,
|
|
84
|
+
};
|
|
85
|
+
const authResponse = pusher.authorizeChannel(
|
|
86
|
+
socketId,
|
|
87
|
+
channel,
|
|
88
|
+
presenceData,
|
|
89
|
+
);
|
|
90
|
+
console.log("Auth success (presence):", authResponse);
|
|
91
|
+
res.send(authResponse);
|
|
92
|
+
} else {
|
|
93
|
+
console.error(
|
|
94
|
+
`Auth failed: Channel ${channel} is not private or presence.`,
|
|
95
|
+
);
|
|
96
|
+
res.status(403).send("Forbidden: Channel is not private or presence");
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error("Auth error:", error);
|
|
100
|
+
res.status(500).send(`Authentication error: ${error.message}`);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Webhook endpoint
|
|
105
|
+
app.post("/pusher/webhooks", (req, res) => {
|
|
106
|
+
console.log("\n--- Webhook Received ---");
|
|
107
|
+
|
|
108
|
+
const receivedSignature = req.headers["x-pusher-signature"];
|
|
109
|
+
const expectedSignature = crypto
|
|
110
|
+
.createHmac("sha256", process.env.PUSHER_APP_SECRET)
|
|
111
|
+
.update(req.rawBody)
|
|
112
|
+
.digest("hex");
|
|
113
|
+
|
|
114
|
+
if (receivedSignature && receivedSignature !== expectedSignature) {
|
|
115
|
+
console.error("Webhook signature invalid!");
|
|
116
|
+
return res.status(403).send("Webhook signature invalid");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const webhookBody = req.body;
|
|
120
|
+
console.log("Webhook Body:", JSON.stringify(webhookBody, null, 2));
|
|
121
|
+
|
|
122
|
+
const webhookData = {
|
|
123
|
+
timestamp: new Date().toISOString(),
|
|
124
|
+
headers: req.headers,
|
|
125
|
+
body: webhookBody,
|
|
126
|
+
};
|
|
127
|
+
receivedWebhooks.unshift(webhookData);
|
|
128
|
+
if (receivedWebhooks.length > 100) {
|
|
129
|
+
receivedWebhooks.pop();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
res.status(200).json({ message: "Webhook received" });
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Server-side event trigger endpoint
|
|
136
|
+
app.post("/trigger-event", async (req, res) => {
|
|
137
|
+
try {
|
|
138
|
+
const { channel, event, data } = req.body;
|
|
139
|
+
|
|
140
|
+
if (!channel || !event) {
|
|
141
|
+
return res.status(400).json({ error: "Channel and event are required" });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
console.log(`Triggering server event: ${event} on ${channel}`);
|
|
145
|
+
|
|
146
|
+
const result = await pusher.trigger(channel, event, data || {});
|
|
147
|
+
|
|
148
|
+
const eventRecord = {
|
|
149
|
+
timestamp: new Date().toISOString(),
|
|
150
|
+
type: "server-triggered",
|
|
151
|
+
channel,
|
|
152
|
+
event,
|
|
153
|
+
data: data || {},
|
|
154
|
+
result,
|
|
155
|
+
};
|
|
156
|
+
eventHistory.unshift(eventRecord);
|
|
157
|
+
if (eventHistory.length > 100) {
|
|
158
|
+
eventHistory.pop();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
res.json({ success: true, result });
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error("Error triggering event:", error);
|
|
164
|
+
res.status(500).json({ error: error.message });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Batch events endpoint
|
|
169
|
+
app.post("/trigger-batch-events", async (req, res) => {
|
|
170
|
+
try {
|
|
171
|
+
const { channel, count = 5, delay = 1000 } = req.body;
|
|
172
|
+
|
|
173
|
+
if (!channel) {
|
|
174
|
+
return res.status(400).json({ error: "Channel is required" });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
res.json({ success: true, message: `Triggering ${count} events...` });
|
|
178
|
+
|
|
179
|
+
// Trigger events with delay
|
|
180
|
+
for (let i = 1; i <= count; i++) {
|
|
181
|
+
setTimeout(
|
|
182
|
+
async () => {
|
|
183
|
+
try {
|
|
184
|
+
await pusher.trigger(channel, "batch-test", {
|
|
185
|
+
message: `Batch message ${i} of ${count}`,
|
|
186
|
+
timestamp: new Date().toISOString(),
|
|
187
|
+
sequence: i,
|
|
188
|
+
});
|
|
189
|
+
console.log(`Batch event ${i}/${count} sent to ${channel}`);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.error(`Error sending batch event ${i}:`, error);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
(i - 1) * delay,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error("Error triggering batch events:", error);
|
|
199
|
+
res.status(500).json({ error: error.message });
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// Get various logs
|
|
204
|
+
app.get("/webhooks-log", (req, res) => {
|
|
205
|
+
res.json(receivedWebhooks);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
app.get("/event-history", (req, res) => {
|
|
209
|
+
res.json(eventHistory);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
app.get("/channel-info", async (req, res) => {
|
|
213
|
+
try {
|
|
214
|
+
const { channel } = req.query;
|
|
215
|
+
if (!channel) {
|
|
216
|
+
return res.status(400).json({ error: "Channel parameter required" });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const info = await pusher.get({ path: `/channels/${channel}` });
|
|
220
|
+
res.json(info);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error("Error getting channel info:", error);
|
|
223
|
+
res.status(500).json({ error: error.message });
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
app.get("/channels", async (req, res) => {
|
|
228
|
+
try {
|
|
229
|
+
const channels = await pusher.get({ path: "/channels" });
|
|
230
|
+
res.json(channels);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
console.error("Error getting channels:", error);
|
|
233
|
+
res.status(500).json({ error: error.message });
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Start server
|
|
238
|
+
app.listen(port, () => {
|
|
239
|
+
console.log(`\n🚀 Pusher Test Backend Server`);
|
|
240
|
+
console.log(`📡 Running at ${process.env.BACKEND_BASE_URL}`);
|
|
241
|
+
console.log(`🔐 Auth Endpoint: POST /pusher/auth`);
|
|
242
|
+
console.log(`🪝 Webhook Endpoint: POST /pusher/webhooks`);
|
|
243
|
+
console.log(`⚡ Trigger Event: POST /trigger-event`);
|
|
244
|
+
console.log(`📊 Dashboard available at: ${process.env.BACKEND_BASE_URL}`);
|
|
245
|
+
console.log(`================================\n`);
|
|
246
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Bundle Test</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>Testing Bundled Libraries</h1>
|
|
9
|
+
<div id="results"></div>
|
|
10
|
+
|
|
11
|
+
<script src="public/dist/bundle.js"></script>
|
|
12
|
+
<script>
|
|
13
|
+
// Test if all libraries are available
|
|
14
|
+
const results = document.getElementById('results');
|
|
15
|
+
|
|
16
|
+
function addResult(text, success = true) {
|
|
17
|
+
const p = document.createElement('p');
|
|
18
|
+
p.textContent = text;
|
|
19
|
+
p.style.color = success ? 'green' : 'red';
|
|
20
|
+
results.appendChild(p);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check Pusher
|
|
24
|
+
if (typeof Pusher !== 'undefined') {
|
|
25
|
+
addResult('✓ Pusher loaded successfully');
|
|
26
|
+
addResult(` Version: ${Pusher.VERSION || 'unknown'}`);
|
|
27
|
+
} else {
|
|
28
|
+
addResult('✗ Pusher not found', false);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check fossil-delta
|
|
32
|
+
if (typeof fossilDelta !== 'undefined') {
|
|
33
|
+
addResult('✓ fossil-delta loaded successfully');
|
|
34
|
+
if (typeof fossilDelta.create === 'function' && typeof fossilDelta.apply === 'function') {
|
|
35
|
+
addResult(' Functions: create() and apply() available');
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
addResult('✗ fossil-delta not found', false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check vcdiff
|
|
42
|
+
if (typeof vcdiff !== 'undefined' && typeof vcdiff.decode === 'function') {
|
|
43
|
+
addResult('✓ vcdiff decoder loaded successfully');
|
|
44
|
+
addResult(' Function: decode() available');
|
|
45
|
+
} else {
|
|
46
|
+
addResult('✗ vcdiff decoder not found', false);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Quick test of fossil-delta
|
|
50
|
+
try {
|
|
51
|
+
const source = new TextEncoder().encode('Hello World');
|
|
52
|
+
const target = new TextEncoder().encode('Hello JavaScript');
|
|
53
|
+
const delta = fossilDelta.create(source, target);
|
|
54
|
+
const result = fossilDelta.apply(source, delta);
|
|
55
|
+
const resultText = new TextDecoder().decode(result);
|
|
56
|
+
if (resultText === 'Hello JavaScript') {
|
|
57
|
+
addResult('✓ fossil-delta test passed: ' + resultText);
|
|
58
|
+
} else {
|
|
59
|
+
addResult('✗ fossil-delta test failed', false);
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
addResult('✗ fossil-delta test error: ' + e.message, false);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Test connecting to Pusher
|
|
66
|
+
try {
|
|
67
|
+
const pusher = new Pusher('app-key', {
|
|
68
|
+
wsHost: 'localhost',
|
|
69
|
+
wsPort: 6001,
|
|
70
|
+
forceTLS: false,
|
|
71
|
+
disableStats: true,
|
|
72
|
+
enabledTransports: ['ws'],
|
|
73
|
+
cluster: 'mt1'
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
pusher.connection.bind('connected', () => {
|
|
77
|
+
addResult('✓ Successfully connected to Pusher/Sockudo');
|
|
78
|
+
pusher.disconnect();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
pusher.connection.bind('error', (err) => {
|
|
82
|
+
addResult('✗ Connection error: ' + err.message, false);
|
|
83
|
+
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
addResult('✗ Pusher initialization error: ' + e.message, false);
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
</body>
|
|
89
|
+
</html>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Test delta compression with bundled libraries
|
|
2
|
+
const http = require('http');
|
|
3
|
+
|
|
4
|
+
// Test configuration
|
|
5
|
+
const config = {
|
|
6
|
+
host: 'localhost',
|
|
7
|
+
port: 3000,
|
|
8
|
+
channel: 'test-channel'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Create a large message (512KB)
|
|
12
|
+
function createLargeMessage(iteration) {
|
|
13
|
+
const size = 512 * 1024; // 512KB
|
|
14
|
+
const data = {
|
|
15
|
+
iteration: iteration,
|
|
16
|
+
timestamp: new Date().toISOString(),
|
|
17
|
+
// Large payload - mostly the same content
|
|
18
|
+
payload: 'X'.repeat(size - 100) + `_ITERATION_${iteration}`
|
|
19
|
+
};
|
|
20
|
+
return JSON.stringify(data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Send a batch of identical messages
|
|
24
|
+
async function sendBatchMessages() {
|
|
25
|
+
console.log('Sending batch of 5 identical 512KB messages...');
|
|
26
|
+
|
|
27
|
+
const messages = [];
|
|
28
|
+
for (let i = 0; i < 5; i++) {
|
|
29
|
+
messages.push({
|
|
30
|
+
name: `large-event-${i}`,
|
|
31
|
+
channel: config.channel,
|
|
32
|
+
data: createLargeMessage(1) // Same content for all
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const options = {
|
|
37
|
+
hostname: config.host,
|
|
38
|
+
port: config.port,
|
|
39
|
+
path: '/trigger-batch',
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const req = http.request(options, (res) => {
|
|
48
|
+
let data = '';
|
|
49
|
+
res.on('data', chunk => data += chunk);
|
|
50
|
+
res.on('end', () => {
|
|
51
|
+
console.log(`Response: ${res.statusCode}`);
|
|
52
|
+
if (res.statusCode === 200) {
|
|
53
|
+
console.log('Batch messages sent successfully');
|
|
54
|
+
resolve();
|
|
55
|
+
} else {
|
|
56
|
+
console.log('Response body:', data);
|
|
57
|
+
reject(new Error(`Failed with status ${res.statusCode}`));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
req.on('error', reject);
|
|
63
|
+
req.write(JSON.stringify({ events: messages }));
|
|
64
|
+
req.end();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Send sequential messages
|
|
69
|
+
async function sendSequentialMessages() {
|
|
70
|
+
console.log('Sending 5 sequential identical 512KB messages...');
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < 5; i++) {
|
|
73
|
+
const options = {
|
|
74
|
+
hostname: config.host,
|
|
75
|
+
port: config.port,
|
|
76
|
+
path: '/trigger',
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: {
|
|
79
|
+
'Content-Type': 'application/json'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
await new Promise((resolve, reject) => {
|
|
84
|
+
const req = http.request(options, (res) => {
|
|
85
|
+
let data = '';
|
|
86
|
+
res.on('data', chunk => data += chunk);
|
|
87
|
+
res.on('end', () => {
|
|
88
|
+
if (res.statusCode === 200) {
|
|
89
|
+
console.log(` Message ${i+1} sent successfully`);
|
|
90
|
+
resolve();
|
|
91
|
+
} else {
|
|
92
|
+
reject(new Error(`Failed with status ${res.statusCode}`));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
req.on('error', reject);
|
|
98
|
+
req.write(JSON.stringify({
|
|
99
|
+
channel: config.channel,
|
|
100
|
+
event: `large-event-seq-${i}`,
|
|
101
|
+
data: createLargeMessage(1) // Same content for all
|
|
102
|
+
}));
|
|
103
|
+
req.end();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Small delay between messages
|
|
107
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Main test
|
|
112
|
+
async function runTest() {
|
|
113
|
+
console.log('Delta Compression Test');
|
|
114
|
+
console.log('======================');
|
|
115
|
+
console.log('Make sure you have:');
|
|
116
|
+
console.log('1. Sockudo running on port 6001');
|
|
117
|
+
console.log('2. Test server running on port 3000');
|
|
118
|
+
console.log('3. Browser open at http://localhost:3000');
|
|
119
|
+
console.log('4. Delta compression enabled in the browser');
|
|
120
|
+
console.log('');
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
// Test sequential messages (should work)
|
|
124
|
+
await sendSequentialMessages();
|
|
125
|
+
console.log('✓ Sequential messages test completed\n');
|
|
126
|
+
|
|
127
|
+
// Wait a bit
|
|
128
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
129
|
+
|
|
130
|
+
// Test batch messages (known issue - will likely fail with delta)
|
|
131
|
+
console.log('Testing batch messages (known limitation with delta compression)...');
|
|
132
|
+
await sendBatchMessages();
|
|
133
|
+
console.log('✓ Batch messages test completed\n');
|
|
134
|
+
|
|
135
|
+
console.log('Test completed! Check the browser console for results.');
|
|
136
|
+
console.log('Expected behavior:');
|
|
137
|
+
console.log('- Sequential messages: Should show high compression ratio (~95-99%)');
|
|
138
|
+
console.log('- Batch messages: May show "bad checksum" errors (known limitation)');
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error('Test failed:', error.message);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Run the test
|
|
146
|
+
runTest();
|
package/node.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/node/pusher');
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cendarsoss/pusher-js",
|
|
3
|
+
"version": "8.4.11",
|
|
4
|
+
"description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"main": "dist/node/pusher.js",
|
|
7
|
+
"module": "dist/web/pusher.mjs",
|
|
8
|
+
"browser": "dist/web/pusher.js",
|
|
9
|
+
"react-native": "dist/react-native/pusher.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"import": "./dist/web/pusher.mjs",
|
|
14
|
+
"require": "./dist/node/pusher.js",
|
|
15
|
+
"default": "./dist/web/pusher.js"
|
|
16
|
+
},
|
|
17
|
+
"./filter": {
|
|
18
|
+
"types": "./types/src/core/channels/filter.d.ts",
|
|
19
|
+
"import": "./dist/web/filter.mjs",
|
|
20
|
+
"require": "./dist/node/filter.js",
|
|
21
|
+
"default": "./dist/web/filter.mjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "vite build && vite build --config vite.config.node.js",
|
|
26
|
+
"build:web": "vite build",
|
|
27
|
+
"build:node": "vite build --config vite.config.node.js",
|
|
28
|
+
"build:watch": "vite build --watch",
|
|
29
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
30
|
+
"format": "prettier --config .prettierrc --write 'src/**/*.ts' 'webpack/**/*.js'",
|
|
31
|
+
"check-format": "prettier --config .prettierrc --check 'src/**/*.ts' 'webpack/**/*.js'"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/pusher/pusher-js.git"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"pusher",
|
|
39
|
+
"client",
|
|
40
|
+
"websocket",
|
|
41
|
+
"http",
|
|
42
|
+
"fallback",
|
|
43
|
+
"isomorphic",
|
|
44
|
+
"events",
|
|
45
|
+
"pubsub"
|
|
46
|
+
],
|
|
47
|
+
"author": "Pusher",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/pusher/pusher-js"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/pusher/pusher-js",
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@react-native-community/netinfo": "^5.9.7",
|
|
55
|
+
"@stablelib/base64": "^1.0.0",
|
|
56
|
+
"@stablelib/utf8": "^1.0.0",
|
|
57
|
+
"@types/express-serve-static-core": "4.17.28",
|
|
58
|
+
"@types/node": "^20.3.0",
|
|
59
|
+
"@vitejs/plugin-legacy": "^7.2.1",
|
|
60
|
+
"buffer": "^5.6.0",
|
|
61
|
+
"faye-websocket": "^0.11.3",
|
|
62
|
+
"fetch-mock": "git+https://git@github.com/jpatel531/fetch-mock.git",
|
|
63
|
+
"isomorphic-fetch": "^3.0.0",
|
|
64
|
+
"jasmine": "^4.5.0",
|
|
65
|
+
"jasmine-spec-reporter": "^7.0.0",
|
|
66
|
+
"karma": "^6.4.4",
|
|
67
|
+
"karma-browserstack-launcher": "^1.6.0",
|
|
68
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
69
|
+
"karma-firefox-launcher": "^2.1.3",
|
|
70
|
+
"karma-jasmine": "^4.0.1",
|
|
71
|
+
"karma-jasmine-web-worker": "git+https://git@github.com/pusher/karma-jasmine-web-worker.git#jasmine_3",
|
|
72
|
+
"karma-opera-launcher": "^1.0.0",
|
|
73
|
+
"karma-safari-launcher": "^1.0.0",
|
|
74
|
+
"karma-spec-reporter": "0.0.32",
|
|
75
|
+
"karma-verbose-reporter": "0.0.6",
|
|
76
|
+
"karma-webpack": "^4.0.2",
|
|
77
|
+
"prettier": "^3.4.2",
|
|
78
|
+
"source-map-loader": "^1.1.3",
|
|
79
|
+
"ts-loader": "^6.0.4",
|
|
80
|
+
"typescript": "^5.1.3",
|
|
81
|
+
"uglify-js": "^2.6.2",
|
|
82
|
+
"vite": "^7.2.7",
|
|
83
|
+
"webpack": "^4.46.0",
|
|
84
|
+
"webpack-cli": "^3.3.12",
|
|
85
|
+
"webpack-dev-server": "^4.11.1",
|
|
86
|
+
"webpack-merge": "^5.8.0",
|
|
87
|
+
"xmlhttprequest": "^1.8.0"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"@ably/vcdiff-decoder": "^1.0.6",
|
|
91
|
+
"fossil-delta": "^2.0.0",
|
|
92
|
+
"tweetnacl": "^1.0.3"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/web/pusher-with-encryption');
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
DeprecatedAuthOptions,
|
|
3
|
+
ChannelAuthorizerGenerator
|
|
4
|
+
} from '../types/src/core/auth/deprecated_channel_authorizer';
|
|
5
|
+
export {
|
|
6
|
+
UserAuthenticationOptions,
|
|
7
|
+
ChannelAuthorizationOptions,
|
|
8
|
+
ChannelAuthorizationHandler,
|
|
9
|
+
UserAuthenticationHandler,
|
|
10
|
+
ChannelAuthorizationCallback,
|
|
11
|
+
UserAuthenticationCallback
|
|
12
|
+
} from '../types/src/core/auth/options';
|
|
13
|
+
export { Options } from '../types/src/core/options';
|
|
14
|
+
|
|
15
|
+
export { default as Channel } from '../types/src/core/channels/channel';
|
|
16
|
+
export { default as PresenceChannel } from '../types/src/core/channels/presence_channel';
|
|
17
|
+
export { default as Members } from '../types/src/core/channels/members';
|
|
18
|
+
export { default as Runtime } from '../types/src/runtimes/interface';
|
|
19
|
+
export { default as ConnectionManager } from '../types/src/core/connection/connection_manager';
|
|
20
|
+
|
|
21
|
+
export { default } from '../types/src/core/pusher';
|
|
22
|
+
|
|
23
|
+
// The following types are provided for backward compatibility
|
|
24
|
+
export {
|
|
25
|
+
DeprecatedAuthOptions as AuthOptions,
|
|
26
|
+
DeprecatedChannelAuthorizer as Authorizer,
|
|
27
|
+
ChannelAuthorizerGenerator as AuthorizerGenerator
|
|
28
|
+
} from '../types/src/core/auth/deprecated_channel_authorizer';
|
|
29
|
+
export { ChannelAuthorizationCallback as AuthorizerCallback } from '../types/src/core/auth/options';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/react-native/pusher');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
|
2
|
+
|
|
3
|
+
jasmine.getEnv().clearReporters();
|
|
4
|
+
|
|
5
|
+
jasmine.getEnv().addReporter(
|
|
6
|
+
new SpecReporter({
|
|
7
|
+
spec: {
|
|
8
|
+
displayPending: true
|
|
9
|
+
},
|
|
10
|
+
summary: {
|
|
11
|
+
displayDuration: false
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spec_dir": "./tmp/node_integration",
|
|
3
|
+
"spec_files": [
|
|
4
|
+
"**/*spec.js"
|
|
5
|
+
],
|
|
6
|
+
"helpers": [
|
|
7
|
+
"../../spec/config/jasmine/helpers/**/*.js"
|
|
8
|
+
],
|
|
9
|
+
"failSpecWithNoExpectations": false,
|
|
10
|
+
"stopSpecOnExpectationFailure": false,
|
|
11
|
+
"stopOnSpecFailure": false,
|
|
12
|
+
"random": false
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spec_dir": "./tmp/node_unit",
|
|
3
|
+
"spec_files": [
|
|
4
|
+
"**/*spec.js"
|
|
5
|
+
],
|
|
6
|
+
"helpers": [
|
|
7
|
+
"../../spec/config/jasmine/helpers/**/*.js"
|
|
8
|
+
],
|
|
9
|
+
"failSpecWithNoExpectations": false,
|
|
10
|
+
"stopSpecOnExpectationFailure": false,
|
|
11
|
+
"stopOnSpecFailure": false,
|
|
12
|
+
"random": false
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const baseConfig = require('../../../webpack/config.node');
|
|
4
|
+
|
|
5
|
+
module.exports = merge({}, baseConfig, {
|
|
6
|
+
entry: {
|
|
7
|
+
pusher: path.join(
|
|
8
|
+
__dirname,
|
|
9
|
+
"..",
|
|
10
|
+
"..",
|
|
11
|
+
"javascripts",
|
|
12
|
+
"integration",
|
|
13
|
+
"index.node"
|
|
14
|
+
)
|
|
15
|
+
},
|
|
16
|
+
output: {
|
|
17
|
+
filename: "integration_tests_spec.js",
|
|
18
|
+
path: path.join(__dirname, "..", "..", "..", "tmp", "node_integration"),
|
|
19
|
+
libraryTarget: "var"
|
|
20
|
+
},
|
|
21
|
+
resolve: {
|
|
22
|
+
modules: ['spec/javascripts/helpers'],
|
|
23
|
+
alias: {
|
|
24
|
+
pusher_integration: 'core/pusher.js',
|
|
25
|
+
integration: 'node/integration',
|
|
26
|
+
'dom/dependencies': 'node/mock-dom-dependencies',
|
|
27
|
+
'dom/dependency_loader': 'node/mock-dom-dependencies'
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
externals: {
|
|
31
|
+
testenv: "'node'"
|
|
32
|
+
}
|
|
33
|
+
});
|