@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.
@@ -1540,6 +1540,11 @@ declare class PredictWsClient {
1540
1540
  private scheduleReconnect;
1541
1541
  private clearReconnectTimer;
1542
1542
  private restoreSubscriptions;
1543
+ /**
1544
+ * Send a subscribe/unsubscribe message, splitting `marketSlugs` across
1545
+ * multiple frames so no single frame exceeds the server read limit.
1546
+ */
1547
+ private sendChunkedSubscription;
1543
1548
  private startPing;
1544
1549
  private stopPing;
1545
1550
  /**
@@ -1540,6 +1540,11 @@ declare class PredictWsClient {
1540
1540
  private scheduleReconnect;
1541
1541
  private clearReconnectTimer;
1542
1542
  private restoreSubscriptions;
1543
+ /**
1544
+ * Send a subscribe/unsubscribe message, splitting `marketSlugs` across
1545
+ * multiple frames so no single frame exceeds the server read limit.
1546
+ */
1547
+ private sendChunkedSubscription;
1543
1548
  private startPing;
1544
1549
  private stopPing;
1545
1550
  /**
package/dist/server.d.mts CHANGED
@@ -1 +1 @@
1
- export { B as BalanceResponse, 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, u as CancelOrderResult, C as Candlestick, bM as ClobOrderPayload, ag as CreateOrderInput, bQ as DEFAULT_PAGE_SIZE, aD as DFlowOrderContext, F as DFlowQuoteRequest, G as DFlowQuoteResponse, I as DFlowSubmitRequest, H as DFlowSubmitResponse, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, f as EventSortField, e as EventStatus, aw as EventSummary, bw as HttpMethod, m as ListCandlesticksParams, L as ListEventsParams, i as ListMarketTradesParams, q as ListOrdersParams, z as ListTradesParams, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, w as MatchGroup, aS as MatchGroupEntry, aT as MatchGroupMarket, v as MatchGroupPage, aY as MatchLeg, aZ as MatchMarketFlat, y as MatchMarketPage, x as MatchMarketParams, aU as MatchSortField, aR as MatchStatus, M as MatchesParams, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, h as Orderbook, aq as OrderbookLevel, bD as POLYGON_CHAIN_ID, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, p as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, r as PredictOrder, b as PredictPage, aA as PredictPosition, al as PredictTag, j as PredictTrade, a as PredictWsClient, aj as PredictWsClientConfig, k as PriceHistoryRange, l as PriceHistoryResponse, az as PricePoint, ak as ProviderMeta, d as ProviderSource, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, S as SimilarEventsParams, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, ab as WsConnectionStatus, ac as WsDataMessage, b6 as WsErrorCode, b7 as WsErrorMessage, ae as WsOrderbookEvent, b2 as WsPingMessage, b4 as WsPongMessage, ad as WsPriceEvent, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, af as WsTradeEvent, 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, 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
+ export { B as BalanceResponse, 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, u as CancelOrderResult, C as Candlestick, bM as ClobOrderPayload, ag as CreateOrderInput, bQ as DEFAULT_PAGE_SIZE, aD as DFlowOrderContext, F as DFlowQuoteRequest, G as DFlowQuoteResponse, I as DFlowSubmitRequest, H as DFlowSubmitResponse, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, f as EventSortField, e as EventStatus, aw as EventSummary, bw as HttpMethod, m as ListCandlesticksParams, L as ListEventsParams, i as ListMarketTradesParams, q as ListOrdersParams, z as ListTradesParams, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, w as MatchGroup, aS as MatchGroupEntry, aT as MatchGroupMarket, v as MatchGroupPage, aY as MatchLeg, aZ as MatchMarketFlat, y as MatchMarketPage, x as MatchMarketParams, aU as MatchSortField, aR as MatchStatus, M as MatchesParams, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, h as Orderbook, aq as OrderbookLevel, bD as POLYGON_CHAIN_ID, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, p as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, r as PredictOrder, b as PredictPage, aA as PredictPosition, al as PredictTag, j as PredictTrade, a as PredictWsClient, aj as PredictWsClientConfig, k as PriceHistoryRange, l as PriceHistoryResponse, az as PricePoint, ak as ProviderMeta, d as ProviderSource, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, S as SimilarEventsParams, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, ab as WsConnectionStatus, ac as WsDataMessage, b6 as WsErrorCode, b7 as WsErrorMessage, ae as WsOrderbookEvent, b2 as WsPingMessage, b4 as WsPongMessage, ad as WsPriceEvent, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, af as WsTradeEvent, 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, 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';
package/dist/server.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as BalanceResponse, 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, u as CancelOrderResult, C as Candlestick, bM as ClobOrderPayload, ag as CreateOrderInput, bQ as DEFAULT_PAGE_SIZE, aD as DFlowOrderContext, F as DFlowQuoteRequest, G as DFlowQuoteResponse, I as DFlowSubmitRequest, H as DFlowSubmitResponse, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, f as EventSortField, e as EventStatus, aw as EventSummary, bw as HttpMethod, m as ListCandlesticksParams, L as ListEventsParams, i as ListMarketTradesParams, q as ListOrdersParams, z as ListTradesParams, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, w as MatchGroup, aS as MatchGroupEntry, aT as MatchGroupMarket, v as MatchGroupPage, aY as MatchLeg, aZ as MatchMarketFlat, y as MatchMarketPage, x as MatchMarketParams, aU as MatchSortField, aR as MatchStatus, M as MatchesParams, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, h as Orderbook, aq as OrderbookLevel, bD as POLYGON_CHAIN_ID, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, p as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, r as PredictOrder, b as PredictPage, aA as PredictPosition, al as PredictTag, j as PredictTrade, a as PredictWsClient, aj as PredictWsClientConfig, k as PriceHistoryRange, l as PriceHistoryResponse, az as PricePoint, ak as ProviderMeta, d as ProviderSource, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, S as SimilarEventsParams, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, ab as WsConnectionStatus, ac as WsDataMessage, b6 as WsErrorCode, b7 as WsErrorMessage, ae as WsOrderbookEvent, b2 as WsPingMessage, b4 as WsPongMessage, ad as WsPriceEvent, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, af as WsTradeEvent, 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, 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
+ export { B as BalanceResponse, 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, u as CancelOrderResult, C as Candlestick, bM as ClobOrderPayload, ag as CreateOrderInput, bQ as DEFAULT_PAGE_SIZE, aD as DFlowOrderContext, F as DFlowQuoteRequest, G as DFlowQuoteResponse, I as DFlowSubmitRequest, H as DFlowSubmitResponse, aH as DepositBuildRequest, aI as DepositBuildResponse, aL as DepositStatusResponse, aJ as DepositSubmitRequest, aK as DepositSubmitResponse, f as EventSortField, e as EventStatus, aw as EventSummary, bw as HttpMethod, m as ListCandlesticksParams, L as ListEventsParams, i as ListMarketTradesParams, q as ListOrdersParams, z as ListTradesParams, ap as MarketOutcome, ao as MarketResult, an as MarketStatus, ax as MarketSummary, aW as MatchConfidenceTier, w as MatchGroup, aS as MatchGroupEntry, aT as MatchGroupMarket, v as MatchGroupPage, aY as MatchLeg, aZ as MatchMarketFlat, y as MatchMarketPage, x as MatchMarketParams, aU as MatchSortField, aR as MatchStatus, M as MatchesParams, aV as MatchesStats, bB as NEG_RISK_CTF_EXCHANGE_ADDRESS, bG as ORDER_TYPE, bO as OrderMessage, aC as OrderSide, aB as OrderStatus, h as Orderbook, aq as OrderbookLevel, bD as POLYGON_CHAIN_ID, by as PolymarketL2Headers, bx as PolymarketL2HeadersInput, aE as PolymarketOrderType, p as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, r as PredictOrder, b as PredictPage, aA as PredictPosition, al as PredictTag, j as PredictTrade, a as PredictWsClient, aj as PredictWsClientConfig, k as PriceHistoryRange, l as PriceHistoryResponse, az as PricePoint, ak as ProviderMeta, d as ProviderSource, bh as ResolveEventsParamsInput, bH as SIDE, am as SettlementSource, aX as SignalTag, bP as SignedOrder, S as SimilarEventsParams, bi as TagSlugSelection, av as TradeType, bC as USDC_ADDRESS, aM as UnsignedTx, a_ as WsChannel, a$ as WsChannelEvent, b0 as WsClientMessage, ab as WsConnectionStatus, ac as WsDataMessage, b6 as WsErrorCode, b7 as WsErrorMessage, ae as WsOrderbookEvent, b2 as WsPingMessage, b4 as WsPongMessage, ad as WsPriceEvent, b3 as WsServerMessage, b1 as WsSubscribeMessage, b5 as WsSubscribedMessage, af as WsTradeEvent, 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, 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';
package/dist/server.js CHANGED
@@ -627,6 +627,13 @@ var DEFAULT_RECONNECT_BASE = 1e3;
627
627
  var DEFAULT_RECONNECT_MAX = 3e4;
628
628
  var DEFAULT_PING_INTERVAL = 2e4;
629
629
  var DEFAULT_PONG_TIMEOUT = 1e4;
630
+ var MAX_SUBSCRIPTION_FRAME_BYTES = 3500;
631
+ function byteLength(str) {
632
+ if (typeof TextEncoder !== "undefined") {
633
+ return new TextEncoder().encode(str).length;
634
+ }
635
+ return str.length;
636
+ }
630
637
  var PredictWsClient = class {
631
638
  ws = null;
632
639
  wsUrl;
@@ -744,7 +751,7 @@ var PredictWsClient = class {
744
751
  const set = this.subs.channels.get(ch);
745
752
  for (const slug of marketSlugs) set.add(slug);
746
753
  }
747
- this.send({ type: "subscribe", channels, market_slugs: marketSlugs });
754
+ this.sendChunkedSubscription("subscribe", channels, marketSlugs);
748
755
  }
749
756
  /**
750
757
  * Unsubscribe from one or more channels for the given market slugs.
@@ -754,7 +761,7 @@ var PredictWsClient = class {
754
761
  const set = this.subs.channels.get(ch);
755
762
  for (const slug of marketSlugs) set.delete(slug);
756
763
  }
757
- this.send({ type: "unsubscribe", channels, market_slugs: marketSlugs });
764
+ this.sendChunkedSubscription("unsubscribe", channels, marketSlugs);
758
765
  }
759
766
  // -------------------------------------------------------------------------
760
767
  // Subscription — convenience (single channel)
@@ -910,14 +917,40 @@ var PredictWsClient = class {
910
917
  restoreSubscriptions() {
911
918
  for (const [channel, slugs] of this.subs.channels.entries()) {
912
919
  if (slugs.size > 0) {
913
- this.send({
914
- type: "subscribe",
915
- channels: [channel],
916
- market_slugs: Array.from(slugs)
917
- });
920
+ this.sendChunkedSubscription("subscribe", [channel], Array.from(slugs));
918
921
  }
919
922
  }
920
923
  }
924
+ /**
925
+ * Send a subscribe/unsubscribe message, splitting `marketSlugs` across
926
+ * multiple frames so no single frame exceeds the server read limit.
927
+ */
928
+ sendChunkedSubscription(type, channels, marketSlugs) {
929
+ if (marketSlugs.length === 0) {
930
+ this.send({ type, channels, market_slugs: [] });
931
+ return;
932
+ }
933
+ const envelopeBytes = byteLength(
934
+ JSON.stringify({ type, channels, market_slugs: [] })
935
+ );
936
+ const budget = MAX_SUBSCRIPTION_FRAME_BYTES - envelopeBytes;
937
+ let chunk = [];
938
+ let chunkBytes = 0;
939
+ const flush = () => {
940
+ if (chunk.length > 0) {
941
+ this.send({ type, channels, market_slugs: chunk });
942
+ chunk = [];
943
+ chunkBytes = 0;
944
+ }
945
+ };
946
+ for (const slug of marketSlugs) {
947
+ const slugBytes = byteLength(JSON.stringify(slug)) + 1;
948
+ if (chunk.length > 0 && chunkBytes + slugBytes > budget) flush();
949
+ chunk.push(slug);
950
+ chunkBytes += slugBytes;
951
+ }
952
+ flush();
953
+ }
921
954
  startPing() {
922
955
  this.stopPing();
923
956
  this.pingTimer = setInterval(() => {