@zeniai/client-epic-state 5.0.33-betaRR0 → 5.0.33

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/lib/esm/init.js CHANGED
@@ -26,11 +26,11 @@ let isPusherInitialized = false;
26
26
  /**
27
27
  * Call initializePusher before using pusher in web-app
28
28
  */
29
- export async function initializePusher(pusherClientSecret, options, headers, reInitialize = false) {
29
+ export function initializePusher(pusherClientSecret, options, headers, reInitialize = false) {
30
30
  // Pusher subscribes/decrypts only make sense in the browser. `pusher-js/
31
31
  // with-encryption` resolves to a browser-only bundle that references
32
- // `window` at module init, so even *importing* it on the server crashes.
33
- // Bail out early on SSR/Node so the dynamic import below never executes.
32
+ // `window` at module init, so even *requiring* it on the server crashes.
33
+ // Bail out early on SSR/Node so loading this module never triggers that.
34
34
  if (typeof window === 'undefined') {
35
35
  console.warn(`initializePusher called on server-side; pusher-js/with-encryption is browser-only — skipping.`);
36
36
  return undefined;
@@ -45,15 +45,13 @@ export async function initializePusher(pusherClientSecret, options, headers, reI
45
45
  console.warn(`Already initialized pusher`);
46
46
  return pusher;
47
47
  }
48
- // Dynamic import so the browser-only bundle is loaded only when this
49
- // function actually runs (browser path). Works in both build outputs:
50
- // ESM (lib/esm): preserved as native `import()` Vite/Rollup code-split
51
- // CJS (lib): TypeScript lowers to `Promise.resolve().then(() => require(...))`
52
- // The pusher-js UMD wrapper does `module.exports = factory()` for CJS, so
53
- // the module result is the Pusher class directly. Some bundlers wrap CJS in
54
- // `{ default: ... }` for ESM interop — fall back to the module itself when
55
- // `.default` is absent.
56
- const pusherModule = (await import('pusher-js/with-encryption'));
48
+ // Lazy-require so the browser-only bundle is loaded only when this function
49
+ // actually runs (browser path). The pusher-js UMD wrapper does
50
+ // `module.exports = factory()` for CJS, so the require result is the
51
+ // Pusher class directly. Some bundlers wrap CJS in `{ default: ... }` for
52
+ // ESM interop fall back to the module itself when `.default` is absent.
53
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
54
+ const pusherModule = require('pusher-js/with-encryption');
57
55
  const PusherConstructor = 'default' in pusherModule ? pusherModule.default : pusherModule;
58
56
  const endpoint = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/notifications/push_notification/auth`;
59
57
  pusher = new PusherConstructor(pusherClientSecret, {
package/lib/init.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare function initializePusher(pusherClientSecret: ID, options: Option
26
26
  sessionId: ID;
27
27
  tenantId: ID;
28
28
  userId: ID;
29
- }, reInitialize?: boolean): Promise<Pusher | undefined>;
29
+ }, reInitialize?: boolean): Pusher | undefined;
30
30
  export declare function disconnectPusher(): void;
31
31
  export { pusher };
32
32
  export { injectFeatureModules, injectFeatureEpics } from './configureStore';
package/lib/init.js CHANGED
@@ -70,11 +70,11 @@ let isPusherInitialized = false;
70
70
  /**
71
71
  * Call initializePusher before using pusher in web-app
72
72
  */
73
- async function initializePusher(pusherClientSecret, options, headers, reInitialize = false) {
73
+ function initializePusher(pusherClientSecret, options, headers, reInitialize = false) {
74
74
  // Pusher subscribes/decrypts only make sense in the browser. `pusher-js/
75
75
  // with-encryption` resolves to a browser-only bundle that references
76
- // `window` at module init, so even *importing* it on the server crashes.
77
- // Bail out early on SSR/Node so the dynamic import below never executes.
76
+ // `window` at module init, so even *requiring* it on the server crashes.
77
+ // Bail out early on SSR/Node so loading this module never triggers that.
78
78
  if (typeof window === 'undefined') {
79
79
  console.warn(`initializePusher called on server-side; pusher-js/with-encryption is browser-only — skipping.`);
80
80
  return undefined;
@@ -89,15 +89,13 @@ async function initializePusher(pusherClientSecret, options, headers, reInitiali
89
89
  console.warn(`Already initialized pusher`);
90
90
  return pusher;
91
91
  }
92
- // Dynamic import so the browser-only bundle is loaded only when this
93
- // function actually runs (browser path). Works in both build outputs:
94
- // ESM (lib/esm): preserved as native `import()` Vite/Rollup code-split
95
- // CJS (lib): TypeScript lowers to `Promise.resolve().then(() => require(...))`
96
- // The pusher-js UMD wrapper does `module.exports = factory()` for CJS, so
97
- // the module result is the Pusher class directly. Some bundlers wrap CJS in
98
- // `{ default: ... }` for ESM interop — fall back to the module itself when
99
- // `.default` is absent.
100
- const pusherModule = (await Promise.resolve().then(() => __importStar(require('pusher-js/with-encryption'))));
92
+ // Lazy-require so the browser-only bundle is loaded only when this function
93
+ // actually runs (browser path). The pusher-js UMD wrapper does
94
+ // `module.exports = factory()` for CJS, so the require result is the
95
+ // Pusher class directly. Some bundlers wrap CJS in `{ default: ... }` for
96
+ // ESM interop fall back to the module itself when `.default` is absent.
97
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
98
+ const pusherModule = require('pusher-js/with-encryption');
101
99
  const PusherConstructor = 'default' in pusherModule ? pusherModule.default : pusherModule;
102
100
  const endpoint = `${exports.zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/notifications/push_notification/auth`;
103
101
  exports.pusher = pusher = new PusherConstructor(pusherClientSecret, {