@lolyjs/core 0.2.0-alpha.24 → 0.2.0-alpha.26
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/cli.cjs +21 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +21 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +21 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +21 -23
- package/dist/index.js.map +1 -1
- package/dist/react/sockets.cjs +0 -8
- package/dist/react/sockets.cjs.map +1 -1
- package/dist/react/sockets.js +0 -8
- package/dist/react/sockets.js.map +1 -1
- package/dist/runtime.cjs +0 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +0 -2
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -15859,7 +15859,7 @@ var DEFAULT_REALTIME_CONFIG = {
|
|
|
15859
15859
|
burst: 60
|
|
15860
15860
|
},
|
|
15861
15861
|
logging: {
|
|
15862
|
-
level: "info",
|
|
15862
|
+
level: process.env.NODE_ENV === "production" ? "warn" : "info",
|
|
15863
15863
|
pretty: process.env.NODE_ENV !== "production"
|
|
15864
15864
|
}
|
|
15865
15865
|
};
|
|
@@ -16662,7 +16662,6 @@ async function executeGuard(guardFn, ctx) {
|
|
|
16662
16662
|
const guardCtx = {
|
|
16663
16663
|
user: ctx.user,
|
|
16664
16664
|
req: ctx.req,
|
|
16665
|
-
socket: ctx.socket,
|
|
16666
16665
|
namespace: ctx.pathname
|
|
16667
16666
|
};
|
|
16668
16667
|
const result = await guardFn(guardCtx);
|
|
@@ -16697,13 +16696,24 @@ function validateSchema(schema, data) {
|
|
|
16697
16696
|
}
|
|
16698
16697
|
|
|
16699
16698
|
// modules/realtime/logging/index.ts
|
|
16700
|
-
|
|
16699
|
+
var LOG_LEVELS = {
|
|
16700
|
+
debug: 0,
|
|
16701
|
+
info: 1,
|
|
16702
|
+
warn: 2,
|
|
16703
|
+
error: 3
|
|
16704
|
+
};
|
|
16705
|
+
function createWssLogger(namespace, socket, baseLogger, minLevel = "info") {
|
|
16701
16706
|
const context = {
|
|
16702
16707
|
namespace,
|
|
16703
16708
|
socketId: socket.id,
|
|
16704
16709
|
userId: socket.data?.user?.id || null
|
|
16705
16710
|
};
|
|
16711
|
+
const minLevelNum = LOG_LEVELS[minLevel] ?? LOG_LEVELS.info;
|
|
16706
16712
|
const log = (level, message, meta) => {
|
|
16713
|
+
const levelNum = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
16714
|
+
if (levelNum < minLevelNum) {
|
|
16715
|
+
return;
|
|
16716
|
+
}
|
|
16707
16717
|
const fullMeta = {
|
|
16708
16718
|
...context,
|
|
16709
16719
|
...meta,
|
|
@@ -16769,9 +16779,6 @@ var generateActions = (socket, namespace, presence) => {
|
|
|
16769
16779
|
return {
|
|
16770
16780
|
emit: async (event, payload) => {
|
|
16771
16781
|
if (!presence) {
|
|
16772
|
-
console.warn(
|
|
16773
|
-
"[loly:realtime] toUser() requires presence manager. Make sure realtime is properly configured."
|
|
16774
|
-
);
|
|
16775
16782
|
return;
|
|
16776
16783
|
}
|
|
16777
16784
|
const socketIds = await presence.getSocketsForUser(userId);
|
|
@@ -16874,19 +16881,12 @@ async function setupWssEvents(options) {
|
|
|
16874
16881
|
const subClient = pubClient.duplicate();
|
|
16875
16882
|
io.adapter(createAdapter(pubClient, subClient));
|
|
16876
16883
|
} catch (error) {
|
|
16877
|
-
console.error(
|
|
16878
|
-
"[loly:realtime] Failed to setup Redis adapter:",
|
|
16879
|
-
error instanceof Error ? error.message : String(error)
|
|
16880
|
-
);
|
|
16881
16884
|
throw error;
|
|
16882
16885
|
}
|
|
16883
16886
|
}
|
|
16884
16887
|
for (const wssRoute of wssRoutes) {
|
|
16885
16888
|
const normalized = wssRoute.normalized;
|
|
16886
16889
|
if (!normalized) {
|
|
16887
|
-
console.warn(
|
|
16888
|
-
`[loly:realtime] Skipping route ${wssRoute.pattern}: No normalized route definition`
|
|
16889
|
-
);
|
|
16890
16890
|
continue;
|
|
16891
16891
|
}
|
|
16892
16892
|
let namespacePath = normalized.namespace || wssRoute.pattern.replace(/^\/wss/, "");
|
|
@@ -16897,12 +16897,11 @@ async function setupWssEvents(options) {
|
|
|
16897
16897
|
namespacePath = "/";
|
|
16898
16898
|
}
|
|
16899
16899
|
const namespace = io.of(namespacePath);
|
|
16900
|
-
console.log(`[loly:realtime] Registered namespace: ${namespacePath} (from pattern: ${wssRoute.pattern})`);
|
|
16901
16900
|
namespace.on("connection", async (socket) => {
|
|
16902
|
-
console.log(`[loly:realtime] Client connected to namespace ${namespacePath}, socket: ${socket.id}`);
|
|
16903
16901
|
const requestId = generateRequestId();
|
|
16904
16902
|
socket.requestId = requestId;
|
|
16905
|
-
const
|
|
16903
|
+
const logLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16904
|
+
const log = createWssLogger(namespacePath, socket, void 0, logLevel);
|
|
16906
16905
|
try {
|
|
16907
16906
|
const user = await executeAuth(normalized.auth, socket, namespacePath);
|
|
16908
16907
|
socket.data = socket.data || {};
|
|
@@ -16911,8 +16910,6 @@ async function setupWssEvents(options) {
|
|
|
16911
16910
|
await presence.addSocketForUser(String(user.id), socket.id);
|
|
16912
16911
|
}
|
|
16913
16912
|
const baseCtx = {
|
|
16914
|
-
socket,
|
|
16915
|
-
io: namespace.server,
|
|
16916
16913
|
req: {
|
|
16917
16914
|
headers: socket.handshake.headers,
|
|
16918
16915
|
ip: socket.handshake.address,
|
|
@@ -16939,7 +16936,8 @@ async function setupWssEvents(options) {
|
|
|
16939
16936
|
socket.on(eventName, async (data) => {
|
|
16940
16937
|
const eventRequestId = generateRequestId();
|
|
16941
16938
|
socket.requestId = eventRequestId;
|
|
16942
|
-
const
|
|
16939
|
+
const eventLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16940
|
+
const eventLog = createWssLogger(namespacePath, socket, void 0, eventLogLevel);
|
|
16943
16941
|
eventLog.debug(`Event received: ${eventName}`, { data });
|
|
16944
16942
|
try {
|
|
16945
16943
|
const ctx = {
|
|
@@ -16997,7 +16995,8 @@ async function setupWssEvents(options) {
|
|
|
16997
16995
|
await eventDef.handler(ctx);
|
|
16998
16996
|
eventLog.debug(`Event handled: ${eventName}`);
|
|
16999
16997
|
} catch (error) {
|
|
17000
|
-
const
|
|
16998
|
+
const errorLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
16999
|
+
const errorLog = createWssLogger(namespacePath, socket, void 0, errorLogLevel);
|
|
17001
17000
|
errorLog.error(`Error handling event ${eventName}`, {
|
|
17002
17001
|
error: error instanceof Error ? error.message : String(error),
|
|
17003
17002
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -17017,9 +17016,10 @@ async function setupWssEvents(options) {
|
|
|
17017
17016
|
}
|
|
17018
17017
|
if (normalized.onDisconnect) {
|
|
17019
17018
|
try {
|
|
17019
|
+
const disconnectLogLevel = realtimeConfig.logging?.level || (process.env.NODE_ENV === "production" ? "warn" : "info");
|
|
17020
17020
|
const disconnectCtx = {
|
|
17021
17021
|
...baseCtx,
|
|
17022
|
-
log: createWssLogger(namespacePath, socket)
|
|
17022
|
+
log: createWssLogger(namespacePath, socket, void 0, disconnectLogLevel)
|
|
17023
17023
|
};
|
|
17024
17024
|
await normalized.onDisconnect(disconnectCtx, reason);
|
|
17025
17025
|
} catch (error) {
|
|
@@ -18758,9 +18758,7 @@ function AppShell({
|
|
|
18758
18758
|
function setupHotReload2() {
|
|
18759
18759
|
const nodeEnv = process.env.NODE_ENV || "production";
|
|
18760
18760
|
const isDev = nodeEnv === "development";
|
|
18761
|
-
console.log(`[hot-reload] NODE_ENV: ${nodeEnv}, isDev: ${isDev}`);
|
|
18762
18761
|
if (!isDev) {
|
|
18763
|
-
console.log("[hot-reload] Skipping hot reload setup (not in development mode)");
|
|
18764
18762
|
return;
|
|
18765
18763
|
}
|
|
18766
18764
|
console.log("[hot-reload] Setting up hot reload client...");
|