@emeryld/rrroutes-client 2.2.14 → 2.2.15

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.mjs CHANGED
@@ -26,30 +26,29 @@ var defaultFetcher = async (req) => {
26
26
  };
27
27
 
28
28
  // src/routesV3.client.index.ts
29
- import { useCallback, useRef } from "react";
29
+ import {
30
+ buildCacheKey,
31
+ compilePath,
32
+ lowProfileParse
33
+ } from "@emeryld/rrroutes-contract";
30
34
  import {
31
35
  keepPreviousData,
32
36
  useInfiniteQuery,
33
37
  useMutation,
34
38
  useQuery
35
39
  } from "@tanstack/react-query";
40
+ import { useCallback, useRef } from "react";
36
41
  import { z } from "zod";
37
- import {
38
- buildCacheKey,
39
- compilePath
40
- } from "@emeryld/rrroutes-contract";
41
42
  var toUpper = (m) => m.toUpperCase();
42
- var defaultFeedQuerySchema = z.object({
43
- cursor: z.string().optional(),
44
- limit: z.coerce.number().min(1).max(100).default(20)
45
- });
43
+ var paginationQueryShape = {
44
+ pagination_cursor: z.string().optional(),
45
+ pagination_limit: z.coerce.number().min(1).max(100).default(20)
46
+ };
47
+ var defaultFeedQuerySchema = z.object(paginationQueryShape);
46
48
  var defaultFeedOutputSchema = z.object({
47
49
  items: z.array(z.unknown()),
48
50
  nextCursor: z.string().optional()
49
51
  });
50
- function zParse(value, schema) {
51
- return schema ? schema.parse(value) : value;
52
- }
53
52
  function toSearchString(query) {
54
53
  if (!query) return "";
55
54
  const params = new URLSearchParams();
@@ -148,41 +147,51 @@ function extractArgs(args) {
148
147
  function toArgsTuple(args) {
149
148
  return typeof args === "undefined" ? [] : [args];
150
149
  }
150
+ function getZodShape(schema) {
151
+ const shapeOrGetter = schema.shape ? schema.shape : schema._def?.shape?.();
152
+ if (!shapeOrGetter) return {};
153
+ return typeof shapeOrGetter === "function" ? shapeOrGetter.call(schema) : shapeOrGetter;
154
+ }
151
155
  function augmentFeedQuerySchema(schema) {
152
156
  if (!schema) return defaultFeedQuerySchema;
153
- if (schema instanceof z.ZodObject) {
154
- const shape = schema.shape ? schema.shape : schema._def?.shape?.();
155
- return schema.extend({
156
- ...shape ?? {},
157
- cursor: defaultFeedQuerySchema.shape.cursor,
158
- limit: defaultFeedQuerySchema.shape.limit
159
- });
157
+ if (!(schema instanceof z.ZodObject)) {
158
+ console.warn("Feed queries must be a ZodObject; default pagination applied.");
159
+ return defaultFeedQuerySchema;
160
160
  }
161
- return z.intersection(schema, defaultFeedQuerySchema);
161
+ return schema.extend(paginationQueryShape);
162
162
  }
163
163
  function augmentFeedOutputSchema(schema) {
164
164
  if (!schema) return defaultFeedOutputSchema;
165
- if (schema instanceof z.ZodObject) {
166
- const shape = schema.shape ? schema.shape : schema._def?.shape?.();
167
- const hasItems = Boolean(shape?.items);
168
- if (hasItems) return schema.extend({ nextCursor: z.string().optional() });
165
+ if (schema instanceof z.ZodArray) {
169
166
  return z.object({
170
- items: z.array(schema),
167
+ items: schema,
171
168
  nextCursor: z.string().optional()
172
169
  });
173
170
  }
174
- if (schema instanceof z.ZodArray) {
171
+ if (schema instanceof z.ZodObject) {
172
+ const shape = getZodShape(schema);
173
+ if (shape?.items) {
174
+ return schema.extend({
175
+ nextCursor: z.string().optional()
176
+ });
177
+ }
175
178
  return z.object({
176
- items: schema,
179
+ items: z.array(schema),
177
180
  nextCursor: z.string().optional()
178
181
  });
179
182
  }
180
- return defaultFeedOutputSchema;
183
+ return z.object({
184
+ items: z.array(schema),
185
+ nextCursor: z.string().optional()
186
+ });
181
187
  }
182
188
  function buildUrl(leaf, baseUrl, params, query) {
183
- const normalizedParams = zParse(params, leaf.cfg.paramsSchema);
184
- const normalizedQuery = zParse(query, leaf.cfg.querySchema);
185
- const path = compilePath(leaf.path, normalizedParams ?? {});
189
+ const normalizedParams = leaf.cfg.paramsSchema ? lowProfileParse(leaf.cfg.paramsSchema, params) : {};
190
+ const normalizedQuery = leaf.cfg.querySchema ? lowProfileParse(leaf.cfg.querySchema, query) : {};
191
+ const path = compilePath(
192
+ leaf.path,
193
+ normalizedParams ?? {}
194
+ );
186
195
  const url = `${baseUrl ?? ""}${path}${toSearchString(normalizedQuery)}`;
187
196
  return { url, normalizedQuery, normalizedParams };
188
197
  }
@@ -190,10 +199,13 @@ function createRouteClient(opts) {
190
199
  const queryClient = opts.queryClient;
191
200
  const fetcher = opts.fetcher ?? defaultFetcher;
192
201
  const baseUrl = opts.baseUrl;
193
- const cursorParam = opts.cursorParam ?? "cursor";
202
+ const cursorParam = opts.cursorParam ?? "pagination_cursor";
194
203
  const getNextCursor = opts.getNextCursor ?? defaultGetNextCursor;
195
204
  const environment = opts.environment ?? void 0;
196
- const { emit: emitDebug, mode: debugMode } = createDebugEmitter(opts.debug, environment);
205
+ const { emit: emitDebug, mode: debugMode } = createDebugEmitter(
206
+ opts.debug,
207
+ environment
208
+ );
197
209
  const isVerboseDebug = debugMode === "complete";
198
210
  const decorateDebugEvent = (event, details) => {
199
211
  if (!isVerboseDebug || !details) return event;
@@ -207,11 +219,12 @@ function createRouteClient(opts) {
207
219
  function buildInternal(leaf, rqOpts, meta) {
208
220
  const isGet = leaf.method === "get";
209
221
  const isFeed = !!leaf.cfg.feed;
222
+ const rawLeafCfg = leaf.cfg;
210
223
  const leafCfg = isFeed ? {
211
- ...leaf.cfg,
212
- querySchema: augmentFeedQuerySchema(leaf.cfg.querySchema),
213
- outputSchema: augmentFeedOutputSchema(leaf.cfg.outputSchema)
214
- } : leaf.cfg;
224
+ ...rawLeafCfg,
225
+ querySchema: augmentFeedQuerySchema(rawLeafCfg.querySchema),
226
+ outputSchema: augmentFeedOutputSchema(rawLeafCfg.outputSchema)
227
+ } : rawLeafCfg;
215
228
  const method = toUpper(leaf.method);
216
229
  const expectsArgs = Boolean(leafCfg.paramsSchema || leafCfg.querySchema);
217
230
  const leafLabel = `${leaf.method.toUpperCase()} ${String(leaf.path)}`;
@@ -267,9 +280,13 @@ function createRouteClient(opts) {
267
280
  const acceptsBody = Boolean(leafCfg.bodySchema);
268
281
  const requiresBody = options?.requireBody ?? (!isGet && acceptsBody);
269
282
  if (typeof options?.body !== "undefined") {
270
- const normalizedBody = zParse(options.body, leafCfg.bodySchema);
283
+ const normalizedBody = leafCfg.bodySchema ? lowProfileParse(leafCfg.bodySchema, options.body) : void 0;
271
284
  const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
272
- payload = isMultipart ? toFormData(normalizedBody) : normalizedBody;
285
+ if (isMultipart && normalizedBody && typeof normalizedBody === "object") {
286
+ payload = toFormData(normalizedBody);
287
+ } else {
288
+ payload = normalizedBody;
289
+ }
273
290
  } else if (requiresBody) {
274
291
  throw new Error("Body is required when invoking a mutation fetch.");
275
292
  }
@@ -292,7 +309,7 @@ function createRouteClient(opts) {
292
309
  const out = await fetcher(
293
310
  payload === void 0 ? { url, method } : { url, method, body: payload }
294
311
  );
295
- const parsed = zParse(out, leafCfg.outputSchema);
312
+ const parsed = leafCfg.outputSchema ? lowProfileParse(leafCfg.outputSchema, out) : void 0;
296
313
  emit(
297
314
  decorateDebugEvent(
298
315
  {
@@ -303,7 +320,11 @@ function createRouteClient(opts) {
303
320
  leaf: leafLabel,
304
321
  durationMs: Date.now() - startedAt
305
322
  },
306
- isVerboseDebug ? { params: normalizedParams, query: normalizedQuery, output: parsed } : void 0
323
+ isVerboseDebug ? {
324
+ params: normalizedParams,
325
+ query: normalizedQuery,
326
+ output: parsed
327
+ } : void 0
307
328
  )
308
329
  );
309
330
  options?.onReceive?.(parsed);
@@ -334,7 +355,11 @@ function createRouteClient(opts) {
334
355
  const hasBodyCandidate = acceptsBody && tupleLength > maybeBodyIndex;
335
356
  const body = hasBodyCandidate ? tupleWithBody[tupleLength - 1] : void 0;
336
357
  const tuple = hasBodyCandidate ? tupleWithBody.slice(0, tupleLength - 1) : tupleWithBody;
337
- return fetchEndpoint(tuple, { body, onReceive: buildOnReceive, requireBody: false });
358
+ return fetchEndpoint(tuple, {
359
+ body,
360
+ onReceive: buildOnReceive,
361
+ requireBody: false
362
+ });
338
363
  };
339
364
  if (isGet && isFeed) {
340
365
  const useEndpoint2 = (...useArgs) => {
@@ -345,13 +370,10 @@ function createRouteClient(opts) {
345
370
  const query = args?.query;
346
371
  const buildOptions = rqOpts ?? {};
347
372
  const listenersRef = useRef(/* @__PURE__ */ new Set());
348
- const notifyOnReceive = useCallback(
349
- (data) => {
350
- buildOptions?.onReceive?.(data);
351
- listenersRef.current.forEach((listener) => listener(data));
352
- },
353
- []
354
- );
373
+ const notifyOnReceive = useCallback((data) => {
374
+ buildOptions?.onReceive?.(data);
375
+ listenersRef.current.forEach((listener) => listener(data));
376
+ }, []);
355
377
  const registerOnReceive = useCallback(
356
378
  (listener) => {
357
379
  listenersRef.current.add(listener);
@@ -367,24 +389,27 @@ function createRouteClient(opts) {
367
389
  params,
368
390
  query
369
391
  );
370
- const queryResult = useInfiniteQuery({
371
- ...buildOptions,
372
- queryKey: getQueryKeys(...tuple),
373
- initialPageParam: void 0,
374
- getNextPageParam: (lastPage) => getNextCursor(lastPage),
375
- placeholderData: keepPreviousData,
376
- queryFn: ({ pageParam }) => {
377
- const pageQuery = {
378
- ...normalizedQuery,
379
- ...pageParam ? { [cursorParam]: pageParam } : {}
380
- };
381
- return fetchEndpoint(tuple, {
382
- queryOverride: pageQuery,
383
- onReceive: notifyOnReceive
384
- });
385
- }
386
- // NOTE: TData is InfiniteData<T>, so we don't need a select here.
387
- }, queryClient);
392
+ const queryResult = useInfiniteQuery(
393
+ {
394
+ ...buildOptions,
395
+ queryKey: getQueryKeys(...tuple),
396
+ initialPageParam: void 0,
397
+ getNextPageParam: (lastPage) => getNextCursor(lastPage),
398
+ placeholderData: keepPreviousData,
399
+ queryFn: ({ pageParam }) => {
400
+ const pageQuery = {
401
+ ...normalizedQuery,
402
+ ...pageParam ? { [cursorParam]: pageParam } : {}
403
+ };
404
+ return fetchEndpoint(tuple, {
405
+ queryOverride: pageQuery,
406
+ onReceive: notifyOnReceive
407
+ });
408
+ }
409
+ // NOTE: TData is InfiniteData<T>, so we don't need a select here.
410
+ },
411
+ queryClient
412
+ );
388
413
  return { ...queryResult, onReceive: registerOnReceive };
389
414
  };
390
415
  return {
@@ -404,13 +429,10 @@ function createRouteClient(opts) {
404
429
  const query = args?.query;
405
430
  const buildOptions = rqOpts ?? {};
406
431
  const listenersRef = useRef(/* @__PURE__ */ new Set());
407
- const notifyOnReceive = useCallback(
408
- (data) => {
409
- buildOptions?.onReceive?.(data);
410
- listenersRef.current.forEach((listener) => listener(data));
411
- },
412
- []
413
- );
432
+ const notifyOnReceive = useCallback((data) => {
433
+ buildOptions?.onReceive?.(data);
434
+ listenersRef.current.forEach((listener) => listener(data));
435
+ }, []);
414
436
  const registerOnReceive = useCallback(
415
437
  (listener) => {
416
438
  listenersRef.current.add(listener);
@@ -421,14 +443,17 @@ function createRouteClient(opts) {
421
443
  []
422
444
  );
423
445
  buildUrl({ ...leaf, cfg: leafCfg }, baseUrl, params, query);
424
- const queryResult = useQuery({
425
- ...buildOptions,
426
- queryKey: getQueryKeys(...tuple),
427
- placeholderData: keepPreviousData,
428
- queryFn: () => fetchEndpoint(tuple, {
429
- onReceive: notifyOnReceive
430
- })
431
- }, queryClient);
446
+ const queryResult = useQuery(
447
+ {
448
+ ...buildOptions,
449
+ queryKey: getQueryKeys(...tuple),
450
+ placeholderData: keepPreviousData,
451
+ queryFn: () => fetchEndpoint(tuple, {
452
+ onReceive: notifyOnReceive
453
+ })
454
+ },
455
+ queryClient
456
+ );
432
457
  return { ...queryResult, onReceive: registerOnReceive };
433
458
  };
434
459
  return {
@@ -462,21 +487,29 @@ function createRouteClient(opts) {
462
487
  const notifyListeners = useCallback((data) => {
463
488
  listenersRef.current.forEach((listener) => listener(data));
464
489
  }, []);
465
- const registerOnReceive = useCallback((listener) => {
466
- listenersRef.current.add(listener);
467
- return () => {
468
- listenersRef.current.delete(listener);
469
- };
470
- }, []);
471
- const mutationResult = useMutation({
472
- ...mutationBuildOptions,
473
- mutationKey: getQueryKeys(...tuple),
474
- mutationFn: async (body) => {
475
- const result = await fetchMutation(...[...tuple, body]);
476
- notifyListeners(result);
477
- return result;
478
- }
479
- }, queryClient);
490
+ const registerOnReceive = useCallback(
491
+ (listener) => {
492
+ listenersRef.current.add(listener);
493
+ return () => {
494
+ listenersRef.current.delete(listener);
495
+ };
496
+ },
497
+ []
498
+ );
499
+ const mutationResult = useMutation(
500
+ {
501
+ ...mutationBuildOptions,
502
+ mutationKey: getQueryKeys(...tuple),
503
+ mutationFn: async (body) => {
504
+ const result = await fetchMutation(
505
+ ...[...tuple, body]
506
+ );
507
+ notifyListeners(result);
508
+ return result;
509
+ }
510
+ },
511
+ queryClient
512
+ );
480
513
  return { ...mutationResult, onReceive: registerOnReceive };
481
514
  };
482
515
  return {
@@ -495,13 +528,18 @@ function createRouteClient(opts) {
495
528
  }
496
529
  function buildRouter(routeClient, routes) {
497
530
  const buildLeaf = routeClient.build;
498
- return ((key, opts, meta) => buildLeaf(routes[key], opts, meta));
531
+ return ((key, opts, meta) => buildLeaf(
532
+ routes[key],
533
+ opts,
534
+ meta
535
+ ));
499
536
  }
500
537
  function toFormData(body) {
501
538
  const fd = new FormData();
502
539
  for (const [k, v] of Object.entries(body ?? {})) {
503
540
  if (v == null) continue;
504
- if (Array.isArray(v)) v.forEach((item, i) => fd.append(`${k}[${i}]`, item));
541
+ if (Array.isArray(v))
542
+ v.forEach((item, i) => fd.append(`${k}[${i}]`, item));
505
543
  else fd.append(k, v);
506
544
  }
507
545
  return fd;
@@ -764,7 +802,21 @@ function roomsFromData(data, toRooms) {
764
802
  if (data == null) return { rooms: [] };
765
803
  let state = { rooms: [] };
766
804
  const add = (input) => {
767
- state = mergeRoomState(state, toRooms(input));
805
+ const mergeForValue = (value) => {
806
+ state = mergeRoomState(state, toRooms(value));
807
+ };
808
+ if (Array.isArray(input)) {
809
+ input.forEach((entry) => mergeForValue(entry));
810
+ return;
811
+ }
812
+ if (input && typeof input === "object") {
813
+ const maybeItems = input.items;
814
+ if (Array.isArray(maybeItems)) {
815
+ maybeItems.forEach((entry) => mergeForValue(entry));
816
+ return;
817
+ }
818
+ }
819
+ mergeForValue(input);
768
820
  };
769
821
  const maybePages = data?.pages;
770
822
  if (Array.isArray(maybePages)) {
@@ -778,22 +830,34 @@ function buildSocketedRoute(options) {
778
830
  const { built, toRooms, applySocket, useSocketClient: useSocketClient2 } = options;
779
831
  return (...useArgs) => {
780
832
  const client = useSocketClient2();
781
- const endpointResult = built.useEndpoint(...useArgs);
833
+ const endpointResult = built.useEndpoint(
834
+ ...useArgs
835
+ );
782
836
  const argsKey = useMemo2(() => JSON.stringify(useArgs[0] ?? null), [useArgs]);
783
837
  const [roomState, setRoomState] = useState2(
784
838
  () => roomsFromData(endpointResult.data, toRooms)
785
839
  );
786
840
  const roomsKey = useMemo2(() => roomState.rooms.join("|"), [roomState.rooms]);
787
- const joinMetaKey = useMemo2(() => JSON.stringify(roomState.joinMeta ?? null), [roomState.joinMeta]);
788
- const leaveMetaKey = useMemo2(() => JSON.stringify(roomState.leaveMeta ?? null), [roomState.leaveMeta]);
841
+ const joinMetaKey = useMemo2(
842
+ () => JSON.stringify(roomState.joinMeta ?? null),
843
+ [roomState.joinMeta]
844
+ );
845
+ const leaveMetaKey = useMemo2(
846
+ () => JSON.stringify(roomState.leaveMeta ?? null),
847
+ [roomState.leaveMeta]
848
+ );
789
849
  useEffect2(() => {
790
850
  const unsubscribe = endpointResult.onReceive((data) => {
791
- setRoomState((prev) => mergeRoomState(prev, toRooms(data)));
851
+ setRoomState(
852
+ (prev) => mergeRoomState(prev, toRooms(data))
853
+ );
792
854
  });
793
855
  return unsubscribe;
794
856
  }, [endpointResult, toRooms]);
795
857
  useEffect2(() => {
796
- setRoomState(roomsFromData(endpointResult.data, toRooms));
858
+ setRoomState(
859
+ roomsFromData(endpointResult.data, toRooms)
860
+ );
797
861
  }, [endpointResult.data, toRooms]);
798
862
  useEffect2(() => {
799
863
  if (roomState.rooms.length === 0) return;
@@ -812,7 +876,14 @@ function buildSocketedRoute(options) {
812
876
  void client.leaveRooms(roomState.rooms, leaveMeta).catch(() => {
813
877
  });
814
878
  };
815
- }, [client, roomsKey, roomState.joinMeta, roomState.leaveMeta, joinMetaKey, leaveMetaKey]);
879
+ }, [
880
+ client,
881
+ roomsKey,
882
+ roomState.joinMeta,
883
+ roomState.leaveMeta,
884
+ joinMetaKey,
885
+ leaveMetaKey
886
+ ]);
816
887
  useEffect2(() => {
817
888
  const entries = Object.entries(applySocket).filter(
818
889
  ([_event, fn]) => typeof fn === "function"
@@ -821,7 +892,9 @@ function buildSocketedRoute(options) {
821
892
  ([ev, fn]) => client.on(ev, (payload, meta) => {
822
893
  built.setData((prev) => {
823
894
  const next = fn(prev, payload, meta);
824
- setRoomState(roomsFromData(next, toRooms));
895
+ setRoomState(
896
+ roomsFromData(next, toRooms)
897
+ );
825
898
  return next;
826
899
  }, ...useArgs);
827
900
  })
@@ -870,7 +943,11 @@ var SocketClient = class {
870
943
  }
871
944
  this.onConnect = async () => {
872
945
  if (!this.socket) {
873
- this.dbg({ type: "connection", phase: "connect_event", err: "Socket is null" });
946
+ this.dbg({
947
+ type: "connection",
948
+ phase: "connect_event",
949
+ err: "Socket is null"
950
+ });
874
951
  throw new Error("Socket is null in onConnect handler");
875
952
  }
876
953
  this.dbg({
@@ -889,7 +966,11 @@ var SocketClient = class {
889
966
  };
890
967
  this.onReconnect = async (attempt) => {
891
968
  if (!this.socket) {
892
- this.dbg({ type: "connection", phase: "reconnect_event", err: "Socket is null" });
969
+ this.dbg({
970
+ type: "connection",
971
+ phase: "reconnect_event",
972
+ err: "Socket is null"
973
+ });
893
974
  throw new Error("Socket is null in onReconnect handler");
894
975
  }
895
976
  this.dbg({
@@ -910,7 +991,11 @@ var SocketClient = class {
910
991
  };
911
992
  this.onDisconnect = async (reason) => {
912
993
  if (!this.socket) {
913
- this.dbg({ type: "connection", phase: "disconnect_event", err: "Socket is null" });
994
+ this.dbg({
995
+ type: "connection",
996
+ phase: "disconnect_event",
997
+ err: "Socket is null"
998
+ });
914
999
  throw new Error("Socket is null in onDisconnect handler");
915
1000
  }
916
1001
  this.dbg({
@@ -930,7 +1015,11 @@ var SocketClient = class {
930
1015
  };
931
1016
  this.onConnectError = async (err) => {
932
1017
  if (!this.socket) {
933
- this.dbg({ type: "connection", phase: "connect_error_event", err: "Socket is null" });
1018
+ this.dbg({
1019
+ type: "connection",
1020
+ phase: "connect_error_event",
1021
+ err: "Socket is null"
1022
+ });
934
1023
  throw new Error("Socket is null in onConnectError handler");
935
1024
  }
936
1025
  this.dbg({
@@ -948,7 +1037,11 @@ var SocketClient = class {
948
1037
  };
949
1038
  this.onPong = async (raw) => {
950
1039
  if (!this.socket) {
951
- this.dbg({ type: "heartbeat", phase: "pong_recv", err: "Socket is null" });
1040
+ this.dbg({
1041
+ type: "heartbeat",
1042
+ phase: "pong_recv",
1043
+ err: "Socket is null"
1044
+ });
952
1045
  throw new Error("Socket is null in onPong handler");
953
1046
  }
954
1047
  const parsed = this.config.pongPayload.safeParse(raw);
@@ -1048,11 +1141,15 @@ var SocketClient = class {
1048
1141
  }
1049
1142
  /** internal stats snapshot */
1050
1143
  stats() {
1051
- const rooms = Array.from(this.roomCounts.entries()).map(([room, count]) => ({ room, count }));
1052
- const handlers = Array.from(this.handlerMap.entries()).map(([event, set]) => ({
1053
- event,
1054
- handlers: set.size
1055
- }));
1144
+ const rooms = Array.from(this.roomCounts.entries()).map(
1145
+ ([room, count]) => ({ room, count })
1146
+ );
1147
+ const handlers = Array.from(this.handlerMap.entries()).map(
1148
+ ([event, set]) => ({
1149
+ event,
1150
+ handlers: set.size
1151
+ })
1152
+ );
1056
1153
  return {
1057
1154
  roomsCount: rooms.length,
1058
1155
  totalHandlers: handlers.reduce((a, b) => a + b.handlers, 0),
@@ -1124,7 +1221,10 @@ var SocketClient = class {
1124
1221
  details: this.getValidationDetails(check.error)
1125
1222
  });
1126
1223
  if (this.environment === "development") {
1127
- console.warn("[socket] ping schema validation failed", check.error.issues);
1224
+ console.warn(
1225
+ "[socket] ping schema validation failed",
1226
+ check.error.issues
1227
+ );
1128
1228
  }
1129
1229
  return;
1130
1230
  }
@@ -1183,7 +1283,12 @@ var SocketClient = class {
1183
1283
  }
1184
1284
  async joinRooms(rooms, meta) {
1185
1285
  if (!this.socket) {
1186
- this.dbg({ type: "room", phase: "join", rooms: this.toArray(rooms), err: "Socket is null" });
1286
+ this.dbg({
1287
+ type: "room",
1288
+ phase: "join",
1289
+ rooms: this.toArray(rooms),
1290
+ err: "Socket is null"
1291
+ });
1187
1292
  throw new Error("Socket is null in joinRooms method");
1188
1293
  }
1189
1294
  if (!await this.getSysEvent("sys:room_join")({
@@ -1236,7 +1341,12 @@ var SocketClient = class {
1236
1341
  }
1237
1342
  async leaveRooms(rooms, meta) {
1238
1343
  if (!this.socket) {
1239
- this.dbg({ type: "room", phase: "leave", rooms: this.toArray(rooms), err: "Socket is null" });
1344
+ this.dbg({
1345
+ type: "room",
1346
+ phase: "leave",
1347
+ rooms: this.toArray(rooms),
1348
+ err: "Socket is null"
1349
+ });
1240
1350
  throw new Error("Socket is null in leaveRooms method");
1241
1351
  }
1242
1352
  if (!await this.getSysEvent("sys:room_leave")({
@@ -1288,7 +1398,12 @@ var SocketClient = class {
1288
1398
  const schema = this.events[event].message;
1289
1399
  this.dbg({ type: "register", phase: "register", event });
1290
1400
  if (!this.socket) {
1291
- this.dbg({ type: "register", phase: "register", event, err: "Socket is null" });
1401
+ this.dbg({
1402
+ type: "register",
1403
+ phase: "register",
1404
+ event,
1405
+ err: "Socket is null"
1406
+ });
1292
1407
  return () => {
1293
1408
  };
1294
1409
  }