@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 +10 -12
- package/lib/init.d.ts +1 -1
- package/lib/init.js +10 -12
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/package.json +1 -1
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
|
|
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 *
|
|
33
|
-
// Bail out early on SSR/Node so
|
|
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
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
|
|
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):
|
|
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
|
-
|
|
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 *
|
|
77
|
-
// Bail out early on SSR/Node so
|
|
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
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
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, {
|