@mundogamernetwork/shared-ui 1.16.2 → 1.16.4

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/nuxt.config.ts CHANGED
@@ -72,28 +72,20 @@ export default defineNuxtConfig({
72
72
  build: {
73
73
  transpile: ['@vue-leaflet/vue-leaflet'],
74
74
  },
75
- // pusher-js's browser build is a webpack-bundled UMD file: `module.exports
76
- // = factory()` where factory() internally does
77
- // `__webpack_exports__["default"] = Pusher` and returns that object. To a
78
- // real ES module consumer that looks exactly like "this CJS module wants
79
- // default-export interop", but esbuild's static CJS/ESM detection doesn't
80
- // reliably recognize that shape here on some dep-graph paths (this repo
81
- // doesn't import pusher-js directly, plugins/echo.client.ts here and in
82
- // several consuming apps' own copies of the same plugin do) the raw dist
83
- // file gets served to the browser as-is instead of through Vite's
84
- // optimized/interop-wrapped dep cache, and `import Pusher from
85
- // "pusher-js"` throws "does not provide an export named 'default'" at
86
- // evaluation time — before the plugin's own pusherKey guard ever runs, so
87
- // it takes the whole plugin down, and on hosts where that happens during
88
- // app bootstrap it silently breaks ALL click handling on the page (every
89
- // header dropdown, the sidebar toggle, everything — not just this
90
- // plugin's own WebSocket setup). needsInterop forces Vite to always
91
- // treat it as CJS needing the default-export wrapper, which is the fix
92
- // Vite ships for exactly this class of mismatch.
75
+ // pusher-js's browser build is a webpack-bundled UMD file
76
+ // (module.exports = factory(), no real ESM default export). needsInterop
77
+ // here was an earlier attempt at fixing plugins/echo.client.ts's import of
78
+ // it proven unreliable across consuming hosts (still crashed on a real,
79
+ // non-symlinked install even with this exact config). The actual fix now
80
+ // lives in echo.client.ts itself: it no longer imports pusher-js as a
81
+ // module at all, instead pulling its source in as a plain string
82
+ // (`?raw`) and executing it directly, letting the UMD wrapper's own
83
+ // browser-global fallback (`root["Pusher"] = factory()`) self-register
84
+ // window.Pusher. laravel-echo is still a real, safely-interoppable
85
+ // dynamic import, so it stays here.
93
86
  vite: {
94
87
  optimizeDeps: {
95
- include: ["pusher-js", "laravel-echo"],
96
- needsInterop: ["pusher-js"],
88
+ include: ["laravel-echo"],
97
89
  },
98
90
  },
99
91
  components: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mundogamernetwork/shared-ui",
3
- "version": "1.16.2",
3
+ "version": "1.16.4",
4
4
  "description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -1,6 +1,15 @@
1
- import Echo from "laravel-echo";
2
- import Pusher from "pusher-js";
3
1
  import axios from "axios";
2
+ // Raw source, not a real import: pusher-js ships only a webpack-UMD bundle
3
+ // (module.exports = factory(), no ESM default export), and Vite's CJS
4
+ // interop for it doesn't reliably kick in across every consuming host —
5
+ // including as a dynamic import, which still surfaced as an empty/unusable
6
+ // module namespace object in testing (`Pusher is not a constructor`). The
7
+ // UMD wrapper itself already knows how to self-register on `window` when no
8
+ // module system is present (`else root["Pusher"] = factory()`, with `root`
9
+ // passed in as `window` directly) — so instead of asking Vite/ESM to
10
+ // understand this file at all, its source is pulled in as a plain string
11
+ // and executed directly, letting that fallback branch do the work.
12
+ import pusherSrc from "pusher-js/dist/web/pusher.js?raw";
4
13
 
5
14
  declare global {
6
15
  interface Window {
@@ -13,7 +22,7 @@ export default defineNuxtPlugin({
13
22
  name: "shared-ui-echo",
14
23
  enforce: "post",
15
24
  parallel: true,
16
- setup(nuxtApp) {
25
+ async setup(nuxtApp) {
17
26
  // Skip if already provided by the extending frontend's own Echo plugin
18
27
  if (nuxtApp.$echo || window.Echo) {
19
28
  return;
@@ -28,6 +37,20 @@ export default defineNuxtPlugin({
28
37
  return;
29
38
  }
30
39
 
40
+ // laravel-echo is a real ESM/CJS-interoppable package; a plain dynamic
41
+ // import is enough (and, unlike the static import this plugin used to
42
+ // have, confines any future interop failure to this plugin instead of
43
+ // crashing the whole client bundle before Vue mounts).
44
+ const EchoModule = await import("laravel-echo");
45
+ const Echo = (EchoModule as any).default ?? EchoModule;
46
+
47
+ // See the pusherSrc import comment above — self-registers window.Pusher.
48
+ if (!window.Pusher) {
49
+ // eslint-disable-next-line no-new-func
50
+ new Function(pusherSrc)();
51
+ }
52
+ const Pusher = window.Pusher;
53
+
31
54
  const headers: Record<string, string> = {
32
55
  Accept: "application/json",
33
56
  };
@@ -0,0 +1,21 @@
1
+ import httpService from "./httpService";
2
+
3
+ // httpService's baseURL always ends with /api/v1 (see httpService.ts's
4
+ // getHttpService()), so the path here must NOT repeat that prefix — unlike
5
+ // the per-site copies of this file, whose own httpService.ts instances
6
+ // don't normalize it away.
7
+ export const getUserStatus = async () => {
8
+ const params = {
9
+ platform_id: import.meta.env.VITE_SYSTEM_ID,
10
+ };
11
+ return await httpService.get(`/public/user-status`, { params });
12
+ };
13
+
14
+ export const userChangeStatus = async (status: boolean) => {
15
+ const params = {
16
+ platform_id: import.meta.env.VITE_SYSTEM_ID,
17
+ hidden_status: status,
18
+ };
19
+
20
+ return await httpService.post(`/public/user-status`, params);
21
+ };
package/stores/auth.ts CHANGED
@@ -13,6 +13,8 @@ export const useAuthStore = defineStore({
13
13
  signedIn: false,
14
14
  initialized: false,
15
15
  loading: false,
16
+ showOnline: false,
17
+ statusLoaded: false,
16
18
  };
17
19
  },
18
20
  actions: {
@@ -65,6 +67,31 @@ export const useAuthStore = defineStore({
65
67
  this.signedIn = false;
66
68
  this.initialized = false;
67
69
  this.loading = false;
70
+ this.showOnline = false;
71
+ this.statusLoaded = false;
72
+ },
73
+ // Used by shop-frontend, the one site with no local stores/auth.ts of its
74
+ // own (it re-exports this store directly — see its own file for why).
75
+ // Every other site has its own copy of this same pattern in its local
76
+ // store, wired to its own services/userStatusService.ts.
77
+ async fetchOnlineStatus() {
78
+ if (this.statusLoaded || !this.signedIn) return;
79
+ try {
80
+ const { getUserStatus } = await import("../services/userStatusService");
81
+ const response = await getUserStatus();
82
+ this.showOnline = !response.data.data[0].user_status[0].hidden_status;
83
+ this.statusLoaded = true;
84
+ } catch (e: any) {
85
+ if (e?.response?.status !== 401) {
86
+ this.showOnline = false;
87
+ this.statusLoaded = true;
88
+ }
89
+ }
90
+ },
91
+ async toggleOnlineStatus() {
92
+ this.showOnline = !this.showOnline;
93
+ const { userChangeStatus } = await import("../services/userStatusService");
94
+ await userChangeStatus(!this.showOnline);
68
95
  },
69
96
  },
70
97
  getters: {