@gxp-dev/tools 2.0.55 → 2.0.56
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/package.json
CHANGED
|
@@ -262,31 +262,56 @@ export const useGxpStore = defineStore("gxp-portal-app", () => {
|
|
|
262
262
|
/**
|
|
263
263
|
* Initialize primary WebSocket connection
|
|
264
264
|
* Called synchronously when store is created
|
|
265
|
+
*
|
|
266
|
+
* Controlled by env vars:
|
|
267
|
+
* SOCKET_DRIVER = "io" (default) | "echo" | "false"
|
|
268
|
+
* SOCKET_URL = explicit socket server URL (overrides auto-detected default)
|
|
265
269
|
*/
|
|
266
270
|
function initializeSockets() {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
const socketPort = import.meta.env.VITE_SOCKET_IO_PORT || 3069;
|
|
274
|
-
console.log(`[GxP Store] Connecting to Socket.IO on port ${socketPort}`);
|
|
275
|
-
const primarySocket = io(`${socketProtocol}://localhost:${socketPort}`);
|
|
276
|
-
|
|
277
|
-
sockets.primary = {
|
|
278
|
-
broadcast: function (event, data) {
|
|
279
|
-
primarySocket.emit(event, data);
|
|
280
|
-
},
|
|
281
|
-
listen: function (event, callback) {
|
|
282
|
-
return primarySocket.on(event, callback);
|
|
283
|
-
},
|
|
284
|
-
listenForStateChange: function (callback) {
|
|
285
|
-
return primarySocket.on("state-change", callback);
|
|
286
|
-
},
|
|
287
|
-
};
|
|
271
|
+
const socketDriver = import.meta.env.SOCKET_DRIVER || "io";
|
|
272
|
+
|
|
273
|
+
if (socketDriver !== "io") {
|
|
274
|
+
console.log(`[GxP Store] Sockets disabled (SOCKET_DRIVER=${socketDriver})`);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
288
277
|
|
|
289
|
-
|
|
278
|
+
// Resolve socket URL — explicit env var takes priority over auto-detected default
|
|
279
|
+
const socketUrl = (() => {
|
|
280
|
+
if (import.meta.env.SOCKET_URL) {
|
|
281
|
+
return import.meta.env.SOCKET_URL;
|
|
282
|
+
}
|
|
283
|
+
const protocol =
|
|
284
|
+
typeof window !== "undefined" && window.location.protocol === "https:"
|
|
285
|
+
? "https"
|
|
286
|
+
: "http";
|
|
287
|
+
const port = import.meta.env.VITE_SOCKET_IO_PORT || 3069;
|
|
288
|
+
return `${protocol}://localhost:${port}`;
|
|
289
|
+
})();
|
|
290
|
+
|
|
291
|
+
if (socketDriver === "io") {
|
|
292
|
+
console.log(`[GxP Store] Connecting via Socket.IO to ${socketUrl}`);
|
|
293
|
+
const primarySocket = io(socketUrl);
|
|
294
|
+
|
|
295
|
+
sockets.primary = {
|
|
296
|
+
broadcast: function (event, data) {
|
|
297
|
+
primarySocket.emit(event, data);
|
|
298
|
+
},
|
|
299
|
+
listen: function (event, callback) {
|
|
300
|
+
return primarySocket.on(event, callback);
|
|
301
|
+
},
|
|
302
|
+
listenForStateChange: function (callback) {
|
|
303
|
+
return primarySocket.on("state-change", callback);
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
socketConnections.primary = primarySocket;
|
|
308
|
+
} else if (socketDriver === "echo") {
|
|
309
|
+
console.log(`[GxP Store] Connecting via Laravel Echo to ${socketUrl}`);
|
|
310
|
+
// Echo driver — consumers can extend this via socketConnections.primary
|
|
311
|
+
console.warn("[GxP Store] Echo driver selected — configure Echo externally via socketConnections.primary");
|
|
312
|
+
} else {
|
|
313
|
+
console.warn(`[GxP Store] Unknown SOCKET_DRIVER "${socketDriver}", sockets not initialized`);
|
|
314
|
+
}
|
|
290
315
|
}
|
|
291
316
|
|
|
292
317
|
/**
|
package/runtime/vite.config.js
CHANGED
|
@@ -239,6 +239,10 @@ export default defineConfig(({ mode }) => {
|
|
|
239
239
|
"import.meta.env.VITE_SOCKET_IO_PORT": JSON.stringify(
|
|
240
240
|
env.SOCKET_IO_PORT || "3069"
|
|
241
241
|
),
|
|
242
|
+
"import.meta.env.SOCKET_URL": JSON.stringify(env.SOCKET_URL || ""),
|
|
243
|
+
"import.meta.env.SOCKET_DRIVER": JSON.stringify(
|
|
244
|
+
env.SOCKET_DRIVER || "io"
|
|
245
|
+
),
|
|
242
246
|
},
|
|
243
247
|
plugins: [
|
|
244
248
|
runtimeFilesPlugin,
|