@liberfi.io/react-predict 0.3.47 → 0.3.48

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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l as PriceHistoryResponse, m as ListCandlesticksParams, C as Candlestick, n as ListCommentsParams, o as PredictComment, p as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, q as ListOrdersParams, r as PredictOrder, s as ListOrdersMultiParams, t as PredictOrdersResponse, u as CancelOrderResult, M as MatchesParams, v as MatchGroupPage, w as MatchGroup, x as MatchMarketParams, y as MatchMarketPage, z as ListTradesParams, D as ListTradesMultiParams, F as DFlowQuoteRequest, G as DFlowQuoteResponse, H as DFlowSubmitResponse, I as DFlowSubmitRequest, J as DFlowKYCStatus, K as PolymarketSetupStatus, N as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, Q as WithdrawBuildRequest, R as WithdrawSubmitResponse, T as WithdrawSubmitRequest, U as WithdrawStatusResponse, V as PolymarketDepositAddresses, X as PolymarketSupportedAsset, Y as PolymarketWithdrawResponse, Z as PolymarketWithdrawRequest, _ as PolymarketWithdrawPrepareResponse, $ as PolymarketWithdrawPrepareRequest, a0 as PolymarketWithdrawQuoteResponse, a1 as PolymarketWithdrawQuoteRequest, a2 as PolymarketWithdrawRelayBuildResponse, a3 as PolymarketWithdrawRelayBuildRequest, a4 as PolymarketWithdrawRelaySubmitResponse, a5 as PolymarketWithdrawRelaySubmitRequest, a6 as PolymarketWithdrawBridgeStatusResponse, a7 as PolymarketRedeemResponse, a8 as TickSizeResponse, a9 as FeeRateResponse, aa as RebateConfig, ab as WsConnectionStatus, ac as WsDataMessage, ad as WsPriceEvent, ae as WsOrderbookEvent, af as WsTradeEvent, ag as CreateOrderInput } from './server-Byq4PK9C.mjs';
2
- export { bz as BuildClobAuthMessageInput, bN as BuildOrderMessageInput, bq as CLOB_AUTH_DOMAIN, br as CLOB_AUTH_TYPES, bA as CTF_EXCHANGE_ADDRESS, bF as CTF_ORDER_TYPES, bM as ClobOrderPayload, aD as DFlowOrderContext, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, aw as EventSummary, bw as HttpMethod, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, aS as MatchGroupEntry, aT as MatchGroupMarket, aY as MatchLeg, aZ as MatchMarketFlat, aU as MatchSortField, aR as MatchStatus, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, ar as OrderbookBatchItem, as as OrderbookBatchResult, aq as OrderbookLevel, at as OrderbooksBatchRequest, au as OrderbooksBatchResponse, bD as POLYGON_CHAIN_ID, aN as PolymarketBridgeToken, aG as PolymarketDepositWalletDeployRequest, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, ba as PolymarketRedeemInput, b8 as PolymarketRedeemPrepareInput, b9 as PolymarketRedeemPrepareResponse, aO as PolymarketSupportedAssetsResponse, aP as PolymarketTypedData, aQ as PolymarketTypedDataArg, aF as PolymarketWalletKind, ay as PredictCommentProfile, aA as PredictPosition, al as PredictTag, aj as PredictWsClientConfig, az as PricePoint, ak as ProviderMeta, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, b6 as WsErrorCode, b7 as WsErrorMessage, b2 as WsPingMessage, b4 as WsPongMessage, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, bs as buildClobAuthMessage, bK as buildClobPayload, bE as buildCtfExchangeDomain, bI as buildOrderMessage, bu as buildPolymarketL2Headers, bJ as buildSignedOrder, ah as createPredictClient, ai as createPredictWsClient, bv as derivePolymarketApiKey, bb as eventQueryKey, bc as fetchEvent, bg as fetchEventsPage, bk as fetchMarket, bp as fetchMatchMarketsPage, bn as fetchMatchesPage, bL as getPolymarketSharesPrecision, bt as hmacSha256Base64, bf as infiniteEventsQueryKey, bj as marketQueryKey, bo as matchMarketsQueryKey, bm as matchQueryKey, bl as matchesQueryKey, be as resolveEventsParams, bd as resolveTagSlug } from './server-Byq4PK9C.mjs';
1
+ import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l as PriceHistoryResponse, m as ListCandlesticksParams, C as Candlestick, n as ListCommentsParams, o as PredictComment, p as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, q as ListOrdersParams, r as PredictOrder, s as ListOrdersMultiParams, t as PredictOrdersResponse, u as CancelOrderResult, M as MatchesParams, v as MatchGroupPage, w as MatchGroup, x as MatchMarketParams, y as MatchMarketPage, z as ListTradesParams, D as ListTradesMultiParams, F as DFlowQuoteRequest, G as DFlowQuoteResponse, H as DFlowSubmitResponse, I as DFlowSubmitRequest, J as DFlowKYCStatus, K as PolymarketSetupStatus, N as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, Q as WithdrawBuildRequest, R as WithdrawSubmitResponse, T as WithdrawSubmitRequest, U as WithdrawStatusResponse, V as PolymarketDepositAddresses, X as PolymarketSupportedAsset, Y as PolymarketWithdrawResponse, Z as PolymarketWithdrawRequest, _ as PolymarketWithdrawPrepareResponse, $ as PolymarketWithdrawPrepareRequest, a0 as PolymarketWithdrawQuoteResponse, a1 as PolymarketWithdrawQuoteRequest, a2 as PolymarketWithdrawRelayBuildResponse, a3 as PolymarketWithdrawRelayBuildRequest, a4 as PolymarketWithdrawRelaySubmitResponse, a5 as PolymarketWithdrawRelaySubmitRequest, a6 as PolymarketWithdrawBridgeStatusResponse, a7 as PolymarketRedeemResponse, a8 as TickSizeResponse, a9 as FeeRateResponse, aa as RebateConfig, ab as WsConnectionStatus, ac as WsDataMessage, ad as WsPriceEvent, ae as WsOrderbookEvent, af as WsTradeEvent, ag as CreateOrderInput } from './server-DcZETqAE.mjs';
2
+ export { bz as BuildClobAuthMessageInput, bN as BuildOrderMessageInput, bq as CLOB_AUTH_DOMAIN, br as CLOB_AUTH_TYPES, bA as CTF_EXCHANGE_ADDRESS, bF as CTF_ORDER_TYPES, bM as ClobOrderPayload, aD as DFlowOrderContext, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, aw as EventSummary, bw as HttpMethod, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, aS as MatchGroupEntry, aT as MatchGroupMarket, aY as MatchLeg, aZ as MatchMarketFlat, aU as MatchSortField, aR as MatchStatus, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, ar as OrderbookBatchItem, as as OrderbookBatchResult, aq as OrderbookLevel, at as OrderbooksBatchRequest, au as OrderbooksBatchResponse, bD as POLYGON_CHAIN_ID, aN as PolymarketBridgeToken, aG as PolymarketDepositWalletDeployRequest, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, ba as PolymarketRedeemInput, b8 as PolymarketRedeemPrepareInput, b9 as PolymarketRedeemPrepareResponse, aO as PolymarketSupportedAssetsResponse, aP as PolymarketTypedData, aQ as PolymarketTypedDataArg, aF as PolymarketWalletKind, ay as PredictCommentProfile, aA as PredictPosition, al as PredictTag, aj as PredictWsClientConfig, az as PricePoint, ak as ProviderMeta, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, b6 as WsErrorCode, b7 as WsErrorMessage, b2 as WsPingMessage, b4 as WsPongMessage, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, bs as buildClobAuthMessage, bK as buildClobPayload, bE as buildCtfExchangeDomain, bI as buildOrderMessage, bu as buildPolymarketL2Headers, bJ as buildSignedOrder, ah as createPredictClient, ai as createPredictWsClient, bv as derivePolymarketApiKey, bb as eventQueryKey, bc as fetchEvent, bg as fetchEventsPage, bk as fetchMarket, bp as fetchMatchMarketsPage, bn as fetchMatchesPage, bL as getPolymarketSharesPrecision, bt as hmacSha256Base64, bf as infiniteEventsQueryKey, bj as marketQueryKey, bo as matchMarketsQueryKey, bm as matchQueryKey, bl as matchesQueryKey, be as resolveEventsParams, bd as resolveTagSlug } from './server-DcZETqAE.mjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { PropsWithChildren } from 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l as PriceHistoryResponse, m as ListCandlesticksParams, C as Candlestick, n as ListCommentsParams, o as PredictComment, p as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, q as ListOrdersParams, r as PredictOrder, s as ListOrdersMultiParams, t as PredictOrdersResponse, u as CancelOrderResult, M as MatchesParams, v as MatchGroupPage, w as MatchGroup, x as MatchMarketParams, y as MatchMarketPage, z as ListTradesParams, D as ListTradesMultiParams, F as DFlowQuoteRequest, G as DFlowQuoteResponse, H as DFlowSubmitResponse, I as DFlowSubmitRequest, J as DFlowKYCStatus, K as PolymarketSetupStatus, N as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, Q as WithdrawBuildRequest, R as WithdrawSubmitResponse, T as WithdrawSubmitRequest, U as WithdrawStatusResponse, V as PolymarketDepositAddresses, X as PolymarketSupportedAsset, Y as PolymarketWithdrawResponse, Z as PolymarketWithdrawRequest, _ as PolymarketWithdrawPrepareResponse, $ as PolymarketWithdrawPrepareRequest, a0 as PolymarketWithdrawQuoteResponse, a1 as PolymarketWithdrawQuoteRequest, a2 as PolymarketWithdrawRelayBuildResponse, a3 as PolymarketWithdrawRelayBuildRequest, a4 as PolymarketWithdrawRelaySubmitResponse, a5 as PolymarketWithdrawRelaySubmitRequest, a6 as PolymarketWithdrawBridgeStatusResponse, a7 as PolymarketRedeemResponse, a8 as TickSizeResponse, a9 as FeeRateResponse, aa as RebateConfig, ab as WsConnectionStatus, ac as WsDataMessage, ad as WsPriceEvent, ae as WsOrderbookEvent, af as WsTradeEvent, ag as CreateOrderInput } from './server-Byq4PK9C.js';
2
- export { bz as BuildClobAuthMessageInput, bN as BuildOrderMessageInput, bq as CLOB_AUTH_DOMAIN, br as CLOB_AUTH_TYPES, bA as CTF_EXCHANGE_ADDRESS, bF as CTF_ORDER_TYPES, bM as ClobOrderPayload, aD as DFlowOrderContext, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, aw as EventSummary, bw as HttpMethod, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, aS as MatchGroupEntry, aT as MatchGroupMarket, aY as MatchLeg, aZ as MatchMarketFlat, aU as MatchSortField, aR as MatchStatus, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, ar as OrderbookBatchItem, as as OrderbookBatchResult, aq as OrderbookLevel, at as OrderbooksBatchRequest, au as OrderbooksBatchResponse, bD as POLYGON_CHAIN_ID, aN as PolymarketBridgeToken, aG as PolymarketDepositWalletDeployRequest, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, ba as PolymarketRedeemInput, b8 as PolymarketRedeemPrepareInput, b9 as PolymarketRedeemPrepareResponse, aO as PolymarketSupportedAssetsResponse, aP as PolymarketTypedData, aQ as PolymarketTypedDataArg, aF as PolymarketWalletKind, ay as PredictCommentProfile, aA as PredictPosition, al as PredictTag, aj as PredictWsClientConfig, az as PricePoint, ak as ProviderMeta, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, b6 as WsErrorCode, b7 as WsErrorMessage, b2 as WsPingMessage, b4 as WsPongMessage, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, bs as buildClobAuthMessage, bK as buildClobPayload, bE as buildCtfExchangeDomain, bI as buildOrderMessage, bu as buildPolymarketL2Headers, bJ as buildSignedOrder, ah as createPredictClient, ai as createPredictWsClient, bv as derivePolymarketApiKey, bb as eventQueryKey, bc as fetchEvent, bg as fetchEventsPage, bk as fetchMarket, bp as fetchMatchMarketsPage, bn as fetchMatchesPage, bL as getPolymarketSharesPrecision, bt as hmacSha256Base64, bf as infiniteEventsQueryKey, bj as marketQueryKey, bo as matchMarketsQueryKey, bm as matchQueryKey, bl as matchesQueryKey, be as resolveEventsParams, bd as resolveTagSlug } from './server-Byq4PK9C.js';
1
+ import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as OrderbookOutcome, h as Orderbook, i as ListMarketTradesParams, j as PredictTrade, k as PriceHistoryRange, l as PriceHistoryResponse, m as ListCandlesticksParams, C as Candlestick, n as ListCommentsParams, o as PredictComment, p as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, q as ListOrdersParams, r as PredictOrder, s as ListOrdersMultiParams, t as PredictOrdersResponse, u as CancelOrderResult, M as MatchesParams, v as MatchGroupPage, w as MatchGroup, x as MatchMarketParams, y as MatchMarketPage, z as ListTradesParams, D as ListTradesMultiParams, F as DFlowQuoteRequest, G as DFlowQuoteResponse, H as DFlowSubmitResponse, I as DFlowSubmitRequest, J as DFlowKYCStatus, K as PolymarketSetupStatus, N as PolymarketDepositWalletDeployResponse, W as WithdrawBuildResponse, Q as WithdrawBuildRequest, R as WithdrawSubmitResponse, T as WithdrawSubmitRequest, U as WithdrawStatusResponse, V as PolymarketDepositAddresses, X as PolymarketSupportedAsset, Y as PolymarketWithdrawResponse, Z as PolymarketWithdrawRequest, _ as PolymarketWithdrawPrepareResponse, $ as PolymarketWithdrawPrepareRequest, a0 as PolymarketWithdrawQuoteResponse, a1 as PolymarketWithdrawQuoteRequest, a2 as PolymarketWithdrawRelayBuildResponse, a3 as PolymarketWithdrawRelayBuildRequest, a4 as PolymarketWithdrawRelaySubmitResponse, a5 as PolymarketWithdrawRelaySubmitRequest, a6 as PolymarketWithdrawBridgeStatusResponse, a7 as PolymarketRedeemResponse, a8 as TickSizeResponse, a9 as FeeRateResponse, aa as RebateConfig, ab as WsConnectionStatus, ac as WsDataMessage, ad as WsPriceEvent, ae as WsOrderbookEvent, af as WsTradeEvent, ag as CreateOrderInput } from './server-DcZETqAE.js';
2
+ export { bz as BuildClobAuthMessageInput, bN as BuildOrderMessageInput, bq as CLOB_AUTH_DOMAIN, br as CLOB_AUTH_TYPES, bA as CTF_EXCHANGE_ADDRESS, bF as CTF_ORDER_TYPES, bM as ClobOrderPayload, aD as DFlowOrderContext, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, aw as EventSummary, bw as HttpMethod, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, aS as MatchGroupEntry, aT as MatchGroupMarket, aY as MatchLeg, aZ as MatchMarketFlat, aU as MatchSortField, aR as MatchStatus, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, ar as OrderbookBatchItem, as as OrderbookBatchResult, aq as OrderbookLevel, at as OrderbooksBatchRequest, au as OrderbooksBatchResponse, bD as POLYGON_CHAIN_ID, aN as PolymarketBridgeToken, aG as PolymarketDepositWalletDeployRequest, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, ba as PolymarketRedeemInput, b8 as PolymarketRedeemPrepareInput, b9 as PolymarketRedeemPrepareResponse, aO as PolymarketSupportedAssetsResponse, aP as PolymarketTypedData, aQ as PolymarketTypedDataArg, aF as PolymarketWalletKind, ay as PredictCommentProfile, aA as PredictPosition, al as PredictTag, aj as PredictWsClientConfig, az as PricePoint, ak as ProviderMeta, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, b6 as WsErrorCode, b7 as WsErrorMessage, b2 as WsPingMessage, b4 as WsPongMessage, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, bs as buildClobAuthMessage, bK as buildClobPayload, bE as buildCtfExchangeDomain, bI as buildOrderMessage, bu as buildPolymarketL2Headers, bJ as buildSignedOrder, ah as createPredictClient, ai as createPredictWsClient, bv as derivePolymarketApiKey, bb as eventQueryKey, bc as fetchEvent, bg as fetchEventsPage, bk as fetchMarket, bp as fetchMatchMarketsPage, bn as fetchMatchesPage, bL as getPolymarketSharesPrecision, bt as hmacSha256Base64, bf as infiniteEventsQueryKey, bj as marketQueryKey, bo as matchMarketsQueryKey, bm as matchQueryKey, bl as matchesQueryKey, be as resolveEventsParams, bd as resolveTagSlug } from './server-DcZETqAE.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { PropsWithChildren } from 'react';
package/dist/index.js CHANGED
@@ -550,6 +550,13 @@ var DEFAULT_RECONNECT_BASE = 1e3;
550
550
  var DEFAULT_RECONNECT_MAX = 3e4;
551
551
  var DEFAULT_PING_INTERVAL = 2e4;
552
552
  var DEFAULT_PONG_TIMEOUT = 1e4;
553
+ var MAX_SUBSCRIPTION_FRAME_BYTES = 3500;
554
+ function byteLength(str) {
555
+ if (typeof TextEncoder !== "undefined") {
556
+ return new TextEncoder().encode(str).length;
557
+ }
558
+ return str.length;
559
+ }
553
560
  var PredictWsClient = class {
554
561
  ws = null;
555
562
  wsUrl;
@@ -667,7 +674,7 @@ var PredictWsClient = class {
667
674
  const set = this.subs.channels.get(ch);
668
675
  for (const slug of marketSlugs) set.add(slug);
669
676
  }
670
- this.send({ type: "subscribe", channels, market_slugs: marketSlugs });
677
+ this.sendChunkedSubscription("subscribe", channels, marketSlugs);
671
678
  }
672
679
  /**
673
680
  * Unsubscribe from one or more channels for the given market slugs.
@@ -677,7 +684,7 @@ var PredictWsClient = class {
677
684
  const set = this.subs.channels.get(ch);
678
685
  for (const slug of marketSlugs) set.delete(slug);
679
686
  }
680
- this.send({ type: "unsubscribe", channels, market_slugs: marketSlugs });
687
+ this.sendChunkedSubscription("unsubscribe", channels, marketSlugs);
681
688
  }
682
689
  // -------------------------------------------------------------------------
683
690
  // Subscription — convenience (single channel)
@@ -833,13 +840,39 @@ var PredictWsClient = class {
833
840
  restoreSubscriptions() {
834
841
  for (const [channel, slugs] of this.subs.channels.entries()) {
835
842
  if (slugs.size > 0) {
836
- this.send({
837
- type: "subscribe",
838
- channels: [channel],
839
- market_slugs: Array.from(slugs)
840
- });
843
+ this.sendChunkedSubscription("subscribe", [channel], Array.from(slugs));
844
+ }
845
+ }
846
+ }
847
+ /**
848
+ * Send a subscribe/unsubscribe message, splitting `marketSlugs` across
849
+ * multiple frames so no single frame exceeds the server read limit.
850
+ */
851
+ sendChunkedSubscription(type, channels, marketSlugs) {
852
+ if (marketSlugs.length === 0) {
853
+ this.send({ type, channels, market_slugs: [] });
854
+ return;
855
+ }
856
+ const envelopeBytes = byteLength(
857
+ JSON.stringify({ type, channels, market_slugs: [] })
858
+ );
859
+ const budget = MAX_SUBSCRIPTION_FRAME_BYTES - envelopeBytes;
860
+ let chunk = [];
861
+ let chunkBytes = 0;
862
+ const flush = () => {
863
+ if (chunk.length > 0) {
864
+ this.send({ type, channels, market_slugs: chunk });
865
+ chunk = [];
866
+ chunkBytes = 0;
841
867
  }
868
+ };
869
+ for (const slug of marketSlugs) {
870
+ const slugBytes = byteLength(JSON.stringify(slug)) + 1;
871
+ if (chunk.length > 0 && chunkBytes + slugBytes > budget) flush();
872
+ chunk.push(slug);
873
+ chunkBytes += slugBytes;
842
874
  }
875
+ flush();
843
876
  }
844
877
  startPing() {
845
878
  this.stopPing();