@lolyjs/core 0.2.0-alpha.16 → 0.2.0-alpha.18

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.
@@ -1,5 +1,4 @@
1
1
  import { Request, Response } from 'express';
2
- import { Socket, Server } from 'socket.io';
3
2
 
4
3
  type GenerateStaticParams = () => Array<Record<string, string>> | Promise<Array<Record<string, string>>>;
5
4
  interface ServerContext {
@@ -10,31 +9,55 @@ interface ServerContext {
10
9
  locals: Record<string, any>;
11
10
  }
12
11
  interface WssActions {
12
+ /**
13
+ * Emit to current socket only (reply)
14
+ */
15
+ reply(event: string, payload?: any): void;
13
16
  /**
14
17
  * Emit an event to all clients in the namespace
15
18
  */
16
19
  emit: (event: string, ...args: any[]) => void;
17
20
  /**
18
- * Emit an event to a specific socket by Socket.IO socket ID
21
+ * Emit to everyone except current socket
19
22
  */
20
- emitTo: (socketId: string, event: string, ...args: any[]) => void;
23
+ broadcast(event: string, payload?: any, opts?: {
24
+ excludeSelf?: boolean;
25
+ }): void;
21
26
  /**
22
- * Emit an event to a specific client by custom clientId
23
- * Requires clientId to be stored in socket.data.clientId during connection
27
+ * Join a room
24
28
  */
25
- emitToClient: (clientId: string, event: string, ...args: any[]) => void;
29
+ join(room: string): Promise<void>;
26
30
  /**
27
- * Broadcast an event to all clients in the namespace except the sender
31
+ * Leave a room
28
32
  */
29
- broadcast: (event: string, ...args: any[]) => void;
30
- }
31
- interface WssContext {
32
- socket: Socket;
33
- io: Server;
34
- params: Record<string, string>;
35
- pathname: string;
36
- data?: any;
37
- actions: WssActions;
33
+ leave(room: string): Promise<void>;
34
+ /**
35
+ * Emit to a specific room
36
+ */
37
+ toRoom(room: string): {
38
+ emit(event: string, payload?: any): void;
39
+ };
40
+ /**
41
+ * Emit to a specific user (by userId)
42
+ * Uses presence mapping to find user's sockets
43
+ */
44
+ toUser(userId: string): {
45
+ emit(event: string, payload?: any): void;
46
+ };
47
+ /**
48
+ * Emit error event (reserved event: __loly:error)
49
+ */
50
+ error(code: string, message: string, details?: any): void;
51
+ /**
52
+ * Emit an event to a specific socket by Socket.IO socket ID
53
+ * @deprecated Use toUser() for user targeting
54
+ */
55
+ emitTo?: (socketId: string, event: string, ...args: any[]) => void;
56
+ /**
57
+ * Emit an event to a specific client by custom clientId
58
+ * @deprecated Use toUser() for user targeting
59
+ */
60
+ emitToClient?: (clientId: string, event: string, ...args: any[]) => void;
38
61
  }
39
62
  /**
40
63
  * Route middleware function type.
@@ -195,4 +218,4 @@ interface ApiContext {
195
218
  */
196
219
  type ApiMiddleware = (ctx: ApiContext, next: () => Promise<void>) => void | Promise<void>;
197
220
 
198
- export type { ApiMiddleware as A, GenerateStaticParams as G, LoaderResult as L, MetadataLoader as M, PageMetadata as P, RouteMiddleware as R, ServerContext as S, WssContext as W, ApiContext as a, ServerLoader as b };
221
+ export type { ApiMiddleware as A, GenerateStaticParams as G, LoaderResult as L, MetadataLoader as M, PageMetadata as P, RouteMiddleware as R, ServerContext as S, WssActions as W, ApiContext as a, ServerLoader as b };
@@ -1,5 +1,4 @@
1
1
  import { Request, Response } from 'express';
2
- import { Socket, Server } from 'socket.io';
3
2
 
4
3
  type GenerateStaticParams = () => Array<Record<string, string>> | Promise<Array<Record<string, string>>>;
5
4
  interface ServerContext {
@@ -10,31 +9,55 @@ interface ServerContext {
10
9
  locals: Record<string, any>;
11
10
  }
12
11
  interface WssActions {
12
+ /**
13
+ * Emit to current socket only (reply)
14
+ */
15
+ reply(event: string, payload?: any): void;
13
16
  /**
14
17
  * Emit an event to all clients in the namespace
15
18
  */
16
19
  emit: (event: string, ...args: any[]) => void;
17
20
  /**
18
- * Emit an event to a specific socket by Socket.IO socket ID
21
+ * Emit to everyone except current socket
19
22
  */
20
- emitTo: (socketId: string, event: string, ...args: any[]) => void;
23
+ broadcast(event: string, payload?: any, opts?: {
24
+ excludeSelf?: boolean;
25
+ }): void;
21
26
  /**
22
- * Emit an event to a specific client by custom clientId
23
- * Requires clientId to be stored in socket.data.clientId during connection
27
+ * Join a room
24
28
  */
25
- emitToClient: (clientId: string, event: string, ...args: any[]) => void;
29
+ join(room: string): Promise<void>;
26
30
  /**
27
- * Broadcast an event to all clients in the namespace except the sender
31
+ * Leave a room
28
32
  */
29
- broadcast: (event: string, ...args: any[]) => void;
30
- }
31
- interface WssContext {
32
- socket: Socket;
33
- io: Server;
34
- params: Record<string, string>;
35
- pathname: string;
36
- data?: any;
37
- actions: WssActions;
33
+ leave(room: string): Promise<void>;
34
+ /**
35
+ * Emit to a specific room
36
+ */
37
+ toRoom(room: string): {
38
+ emit(event: string, payload?: any): void;
39
+ };
40
+ /**
41
+ * Emit to a specific user (by userId)
42
+ * Uses presence mapping to find user's sockets
43
+ */
44
+ toUser(userId: string): {
45
+ emit(event: string, payload?: any): void;
46
+ };
47
+ /**
48
+ * Emit error event (reserved event: __loly:error)
49
+ */
50
+ error(code: string, message: string, details?: any): void;
51
+ /**
52
+ * Emit an event to a specific socket by Socket.IO socket ID
53
+ * @deprecated Use toUser() for user targeting
54
+ */
55
+ emitTo?: (socketId: string, event: string, ...args: any[]) => void;
56
+ /**
57
+ * Emit an event to a specific client by custom clientId
58
+ * @deprecated Use toUser() for user targeting
59
+ */
60
+ emitToClient?: (clientId: string, event: string, ...args: any[]) => void;
38
61
  }
39
62
  /**
40
63
  * Route middleware function type.
@@ -195,4 +218,4 @@ interface ApiContext {
195
218
  */
196
219
  type ApiMiddleware = (ctx: ApiContext, next: () => Promise<void>) => void | Promise<void>;
197
220
 
198
- export type { ApiMiddleware as A, GenerateStaticParams as G, LoaderResult as L, MetadataLoader as M, PageMetadata as P, RouteMiddleware as R, ServerContext as S, WssContext as W, ApiContext as a, ServerLoader as b };
221
+ export type { ApiMiddleware as A, GenerateStaticParams as G, LoaderResult as L, MetadataLoader as M, PageMetadata as P, RouteMiddleware as R, ServerContext as S, WssActions as W, ApiContext as a, ServerLoader as b };
@@ -1,6 +1,5 @@
1
- import { P as PageMetadata } from '../index.types-BPX6IVAC.mjs';
1
+ import { P as PageMetadata } from '../index.types-DMOO-uvF.mjs';
2
2
  import 'express';
3
- import 'socket.io';
4
3
 
5
4
  /**
6
5
  * Response data structure from server for route data requests
@@ -1,6 +1,5 @@
1
- import { P as PageMetadata } from '../index.types-BPX6IVAC.js';
1
+ import { P as PageMetadata } from '../index.types-DMOO-uvF.js';
2
2
  import 'express';
3
- import 'socket.io';
4
3
 
5
4
  /**
6
5
  * Response data structure from server for route data requests
@@ -25,25 +25,26 @@ __export(sockets_exports, {
25
25
  module.exports = __toCommonJS(sockets_exports);
26
26
  var import_socket = require("socket.io-client");
27
27
  var lolySocket = (namespace, opts) => {
28
- const wsBaseUrl = process.env?.PUBLIC_WS_BASE_URL;
29
- let baseUrl;
30
- if (wsBaseUrl && wsBaseUrl.trim() !== "") {
31
- baseUrl = wsBaseUrl;
32
- } else if (typeof window !== "undefined") {
33
- baseUrl = window.location.origin;
34
- } else {
28
+ if (typeof window === "undefined") {
35
29
  throw new Error(
36
- "[loly:socket] Cannot determine base URL in server-side context. Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client."
30
+ "[loly:socket] lolySocket can only be called on the client side."
37
31
  );
38
32
  }
39
33
  const normalizedNamespace = namespace.startsWith("/") ? namespace : `/${namespace}`;
40
- const fullUrl = `${baseUrl}${normalizedNamespace}`;
41
- const socket = (0, import_socket.io)(fullUrl, {
34
+ console.log("[loly:socket] Connecting to namespace:", normalizedNamespace, "path:", "/wss");
35
+ const socket = (0, import_socket.io)(normalizedNamespace, {
42
36
  path: "/wss",
43
37
  transports: ["websocket", "polling"],
44
38
  autoConnect: true,
45
39
  ...opts
46
40
  });
41
+ socket.on("connect_error", (error) => {
42
+ console.error("[loly:socket] Connection error:", error.message);
43
+ console.error("[loly:socket] Namespace:", normalizedNamespace);
44
+ });
45
+ socket.on("connect", () => {
46
+ console.log("[loly:socket] \u2705 Connected to namespace:", normalizedNamespace);
47
+ });
47
48
  return socket;
48
49
  };
49
50
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // @ts-ignore - process.env.PUBLIC_WS_BASE_URL is replaced by DefinePlugin at build time\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const wsBaseUrl: string | undefined = (process as any).env?.PUBLIC_WS_BASE_URL;\r\n \r\n let baseUrl: string;\r\n if (wsBaseUrl && wsBaseUrl.trim() !== \"\") {\r\n baseUrl = wsBaseUrl;\r\n } else if (typeof window !== \"undefined\") {\r\n baseUrl = window.location.origin;\r\n } else {\r\n throw new Error(\r\n \"[loly:socket] Cannot determine base URL in server-side context. \" +\r\n \"Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client.\"\r\n );\r\n }\r\n\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n const fullUrl = `${baseUrl}${normalizedNamespace}`;\r\n\r\n const socket = io(fullUrl, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0D;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAGX,QAAM,YAAiC,QAAgB,KAAK;AAE5D,MAAI;AACJ,MAAI,aAAa,UAAU,KAAK,MAAM,IAAI;AACxC,cAAU;AAAA,EACZ,WAAW,OAAO,WAAW,aAAa;AACxC,cAAU,OAAO,SAAS;AAAA,EAC5B,OAAO;AACL,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAEA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AACjF,QAAM,UAAU,GAAG,OAAO,GAAG,mBAAmB;AAEhD,QAAM,aAAS,kBAAG,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // SIMPLIFICADO: Siempre usar el origin actual en el navegador\r\n // Socket.IO maneja el namespace automáticamente\r\n if (typeof window === \"undefined\") {\r\n throw new Error(\r\n \"[loly:socket] lolySocket can only be called on the client side.\"\r\n );\r\n }\r\n\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n \r\n // Socket.IO: io(namespace, { path: '/wss' })\r\n // Socket.IO usa window.location.origin automáticamente\r\n // El path '/wss' es el endpoint del engine de Socket.IO\r\n // El namespace se maneja en el handshake\r\n \r\n console.log(\"[loly:socket] Connecting to namespace:\", normalizedNamespace, \"path:\", \"/wss\");\r\n\r\n const socket = io(normalizedNamespace, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n // Add connection error logging\r\n socket.on(\"connect_error\", (error) => {\r\n console.error(\"[loly:socket] Connection error:\", error.message);\r\n console.error(\"[loly:socket] Namespace:\", normalizedNamespace);\r\n });\r\n \r\n socket.on(\"connect\", () => {\r\n console.log(\"[loly:socket] ✅ Connected to namespace:\", normalizedNamespace);\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0D;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAGX,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AAOjF,UAAQ,IAAI,0CAA0C,qBAAqB,SAAS,MAAM;AAE1F,QAAM,aAAS,kBAAG,qBAAqB;AAAA,IACrC,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAGD,SAAO,GAAG,iBAAiB,CAAC,UAAU;AACpC,YAAQ,MAAM,mCAAmC,MAAM,OAAO;AAC9D,YAAQ,MAAM,4BAA4B,mBAAmB;AAAA,EAC/D,CAAC;AAED,SAAO,GAAG,WAAW,MAAM;AACzB,YAAQ,IAAI,gDAA2C,mBAAmB;AAAA,EAC5E,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -1,25 +1,26 @@
1
1
  // modules/react/sockets/index.ts
2
2
  import { io } from "socket.io-client";
3
3
  var lolySocket = (namespace, opts) => {
4
- const wsBaseUrl = process.env?.PUBLIC_WS_BASE_URL;
5
- let baseUrl;
6
- if (wsBaseUrl && wsBaseUrl.trim() !== "") {
7
- baseUrl = wsBaseUrl;
8
- } else if (typeof window !== "undefined") {
9
- baseUrl = window.location.origin;
10
- } else {
4
+ if (typeof window === "undefined") {
11
5
  throw new Error(
12
- "[loly:socket] Cannot determine base URL in server-side context. Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client."
6
+ "[loly:socket] lolySocket can only be called on the client side."
13
7
  );
14
8
  }
15
9
  const normalizedNamespace = namespace.startsWith("/") ? namespace : `/${namespace}`;
16
- const fullUrl = `${baseUrl}${normalizedNamespace}`;
17
- const socket = io(fullUrl, {
10
+ console.log("[loly:socket] Connecting to namespace:", normalizedNamespace, "path:", "/wss");
11
+ const socket = io(normalizedNamespace, {
18
12
  path: "/wss",
19
13
  transports: ["websocket", "polling"],
20
14
  autoConnect: true,
21
15
  ...opts
22
16
  });
17
+ socket.on("connect_error", (error) => {
18
+ console.error("[loly:socket] Connection error:", error.message);
19
+ console.error("[loly:socket] Namespace:", normalizedNamespace);
20
+ });
21
+ socket.on("connect", () => {
22
+ console.log("[loly:socket] \u2705 Connected to namespace:", normalizedNamespace);
23
+ });
23
24
  return socket;
24
25
  };
25
26
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // @ts-ignore - process.env.PUBLIC_WS_BASE_URL is replaced by DefinePlugin at build time\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const wsBaseUrl: string | undefined = (process as any).env?.PUBLIC_WS_BASE_URL;\r\n \r\n let baseUrl: string;\r\n if (wsBaseUrl && wsBaseUrl.trim() !== \"\") {\r\n baseUrl = wsBaseUrl;\r\n } else if (typeof window !== \"undefined\") {\r\n baseUrl = window.location.origin;\r\n } else {\r\n throw new Error(\r\n \"[loly:socket] Cannot determine base URL in server-side context. \" +\r\n \"Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client.\"\r\n );\r\n }\r\n\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n const fullUrl = `${baseUrl}${normalizedNamespace}`;\r\n\r\n const socket = io(fullUrl, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";AAAA,SAAS,UAAiD;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAGX,QAAM,YAAiC,QAAgB,KAAK;AAE5D,MAAI;AACJ,MAAI,aAAa,UAAU,KAAK,MAAM,IAAI;AACxC,cAAU;AAAA,EACZ,WAAW,OAAO,WAAW,aAAa;AACxC,cAAU,OAAO,SAAS;AAAA,EAC5B,OAAO;AACL,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAEA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AACjF,QAAM,UAAU,GAAG,OAAO,GAAG,mBAAmB;AAEhD,QAAM,SAAS,GAAG,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // SIMPLIFICADO: Siempre usar el origin actual en el navegador\r\n // Socket.IO maneja el namespace automáticamente\r\n if (typeof window === \"undefined\") {\r\n throw new Error(\r\n \"[loly:socket] lolySocket can only be called on the client side.\"\r\n );\r\n }\r\n\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n \r\n // Socket.IO: io(namespace, { path: '/wss' })\r\n // Socket.IO usa window.location.origin automáticamente\r\n // El path '/wss' es el endpoint del engine de Socket.IO\r\n // El namespace se maneja en el handshake\r\n \r\n console.log(\"[loly:socket] Connecting to namespace:\", normalizedNamespace, \"path:\", \"/wss\");\r\n\r\n const socket = io(normalizedNamespace, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n // Add connection error logging\r\n socket.on(\"connect_error\", (error) => {\r\n console.error(\"[loly:socket] Connection error:\", error.message);\r\n console.error(\"[loly:socket] Namespace:\", normalizedNamespace);\r\n });\r\n \r\n socket.on(\"connect\", () => {\r\n console.log(\"[loly:socket] ✅ Connected to namespace:\", normalizedNamespace);\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";AAAA,SAAS,UAAiD;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAGX,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AAOjF,UAAQ,IAAI,0CAA0C,qBAAqB,SAAS,MAAM;AAE1F,QAAM,SAAS,GAAG,qBAAqB;AAAA,IACrC,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAGD,SAAO,GAAG,iBAAiB,CAAC,UAAU;AACpC,YAAQ,MAAM,mCAAmC,MAAM,OAAO;AAC9D,YAAQ,MAAM,4BAA4B,mBAAmB;AAAA,EAC/D,CAAC;AAED,SAAO,GAAG,WAAW,MAAM;AACzB,YAAQ,IAAI,gDAA2C,mBAAmB;AAAA,EAC5E,CAAC;AAED,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lolyjs/core",
3
- "version": "0.2.0-alpha.16",
3
+ "version": "0.2.0-alpha.18",
4
4
  "author": {
5
5
  "name": "Valentin Menvielle Candia",
6
6
  "url": "https://github.com/MenvielleValen"
@@ -93,6 +93,10 @@
93
93
  "socket.io": "^4.8.1",
94
94
  "zod": "^3.24.1"
95
95
  },
96
+ "optionalDependencies": {
97
+ "@socket.io/redis-adapter": "^8.3.1",
98
+ "ioredis": "^5.4.1"
99
+ },
96
100
  "peerDependencies": {
97
101
  "react": "^18.0.0 || ^19.0.0",
98
102
  "react-dom": "^18.0.0 || ^19.0.0",
@@ -134,6 +138,7 @@
134
138
  "type": "git",
135
139
  "url": "https://github.com/MenvielleValen/loly-framework"
136
140
  },
141
+ "homepage": "https://loly-framework.onrender.com",
137
142
  "scripts": {
138
143
  "build": "tsup",
139
144
  "dev": "node ./dev/dev-server.js"