@gxp-dev/tools 2.0.54 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxp-dev/tools",
3
- "version": "2.0.54",
3
+ "version": "2.0.56",
4
4
  "description": "Dev tools to create platform plugins",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -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
- // Primary socket connection
268
- // Use the same protocol as the current page for Socket.IO connection
269
- const socketProtocol =
270
- typeof window !== "undefined" && window.location.protocol === "https:"
271
- ? "https"
272
- : "http";
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
- socketConnections.primary = primarySocket;
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
  /**
@@ -127,6 +127,10 @@ export default defineConfig(({ mode }) => {
127
127
  const useLocalIndex = env.USE_LOCAL_INDEX === "true" && hasLocalIndexHtml;
128
128
  const useLocalMain = env.USE_LOCAL_MAIN === "true" && hasLocalMainJs;
129
129
 
130
+ // Plugin enable/disable flags
131
+ const useSourceTracker = env.DISABLE_SOURCE_TRACKER !== "true";
132
+ const useInspector = env.DISABLE_INSPECTOR !== "true";
133
+
130
134
  // Log which files are being used
131
135
  console.log(`📄 index.html: ${useLocalIndex ? "local" : "runtime"}`);
132
136
  console.log(`📄 main.js: ${useLocalMain ? "local" : "runtime"}`);
@@ -235,14 +239,18 @@ export default defineConfig(({ mode }) => {
235
239
  "import.meta.env.VITE_SOCKET_IO_PORT": JSON.stringify(
236
240
  env.SOCKET_IO_PORT || "3069"
237
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
+ ),
238
246
  },
239
247
  plugins: [
240
248
  runtimeFilesPlugin,
241
249
  // Source tracker must run BEFORE vue() to transform templates before compilation
242
- gxpSourceTrackerPlugin(),
250
+ ...(useSourceTracker ? [gxpSourceTrackerPlugin()] : []),
243
251
  vue(),
244
252
  // GxP Inspector plugin for browser extension integration
245
- gxpInspectorPlugin(),
253
+ ...(useInspector ? [gxpInspectorPlugin()] : []),
246
254
  externalGlobals(
247
255
  {
248
256
  vue: "Vue",