@zeniai/client-epic-state 5.0.34-betaRD1 → 5.0.34-betaRR0

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
@@ -57,19 +57,7 @@ export async function initializePusher(pusherClientSecret, options, headers, reI
57
57
  if (pusherInitPromise && !reInitialize) {
58
58
  return pusherInitPromise;
59
59
  }
60
- // The IIFE captures `currentInit` so that, when its `finally` runs, it can
61
- // identity-check before clearing the module-level `pusherInitPromise`. This
62
- // matters when a reInitialize=true call overwrites `pusherInitPromise`
63
- // while we're still in flight: without the identity check, our finally
64
- // would clobber the newer call's slot and the next concurrent caller
65
- // would bypass the dedup guard. Capture is safe because the first action
66
- // inside the try is `await import(...)`, which always yields control —
67
- // so the finally runs in a future microtask, after `currentInit` has
68
- // already been assigned below. We declare it as `let … | undefined` so
69
- // TS's definite-assignment analysis (which doesn't model the await) accepts
70
- // the closure read; at runtime it's always the IIFE promise by then.
71
- let currentInit = undefined;
72
- currentInit = (async () => {
60
+ pusherInitPromise = (async () => {
73
61
  try {
74
62
  // Dynamic import so the browser-only bundle is loaded only when this
75
63
  // function actually runs (browser path). Works in both build outputs:
@@ -96,13 +84,10 @@ export async function initializePusher(pusherClientSecret, options, headers, reI
96
84
  return pusher;
97
85
  }
98
86
  finally {
99
- if (pusherInitPromise === currentInit) {
100
- pusherInitPromise = undefined;
101
- }
87
+ pusherInitPromise = undefined;
102
88
  }
103
89
  })();
104
- pusherInitPromise = currentInit;
105
- return currentInit;
90
+ return pusherInitPromise;
106
91
  }
107
92
  const customHandler = async (params, headers, callback) => {
108
93
  const { socketId, channelName } = params;
@@ -1,5 +1,5 @@
1
1
  import { from, of } from 'rxjs';
2
- import { catchError, concatMap, exhaustMap, filter, mergeMap, } from 'rxjs/operators';
2
+ import { catchError, concatMap, filter, mergeMap, switchMap, } from 'rxjs/operators';
3
3
  import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
4
4
  import { createZeniAPIStatus } from '../../../responsePayload';
5
5
  import { approveOAuthConsent, approveOAuthConsentFailure, approveOAuthConsentSuccess, } from '../zeniOAuthReducer';
@@ -9,11 +9,10 @@ const failureSnackbar = (reason) => openSnackbar({
9
9
  type: 'error',
10
10
  variables: [{ variableName: '__reason__', variableValue: reason }],
11
11
  });
12
- export const approveOAuthConsentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(approveOAuthConsent.match),
13
- // `approveOAuthConsent` reducer sets fetchState to In-Progress before epics
14
- // run, so a guard on In-Progress would block every legitimate request.
15
- // exhaustMap drops duplicate approve clicks while the HTTP call is in flight.
16
- exhaustMap((action) => {
12
+ export const approveOAuthConsentEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(approveOAuthConsent.match), switchMap((action) => {
13
+ if (state$.value.zeniOAuthViewState.fetchState === 'In-Progress') {
14
+ return from([]);
15
+ }
17
16
  const { userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType, } = action.payload;
18
17
  const authHeaders = {
19
18
  'zeni-user-id': userId,
package/lib/init.js CHANGED
@@ -101,19 +101,7 @@ async function initializePusher(pusherClientSecret, options, headers, reInitiali
101
101
  if (pusherInitPromise && !reInitialize) {
102
102
  return pusherInitPromise;
103
103
  }
104
- // The IIFE captures `currentInit` so that, when its `finally` runs, it can
105
- // identity-check before clearing the module-level `pusherInitPromise`. This
106
- // matters when a reInitialize=true call overwrites `pusherInitPromise`
107
- // while we're still in flight: without the identity check, our finally
108
- // would clobber the newer call's slot and the next concurrent caller
109
- // would bypass the dedup guard. Capture is safe because the first action
110
- // inside the try is `await import(...)`, which always yields control —
111
- // so the finally runs in a future microtask, after `currentInit` has
112
- // already been assigned below. We declare it as `let … | undefined` so
113
- // TS's definite-assignment analysis (which doesn't model the await) accepts
114
- // the closure read; at runtime it's always the IIFE promise by then.
115
- let currentInit = undefined;
116
- currentInit = (async () => {
104
+ pusherInitPromise = (async () => {
117
105
  try {
118
106
  // Dynamic import so the browser-only bundle is loaded only when this
119
107
  // function actually runs (browser path). Works in both build outputs:
@@ -140,13 +128,10 @@ async function initializePusher(pusherClientSecret, options, headers, reInitiali
140
128
  return pusher;
141
129
  }
142
130
  finally {
143
- if (pusherInitPromise === currentInit) {
144
- pusherInitPromise = undefined;
145
- }
131
+ pusherInitPromise = undefined;
146
132
  }
147
133
  })();
148
- pusherInitPromise = currentInit;
149
- return currentInit;
134
+ return pusherInitPromise;
150
135
  }
151
136
  const customHandler = async (params, headers, callback) => {
152
137
  const { socketId, channelName } = params;
@@ -4,7 +4,7 @@ import { RootState } from '../../../reducer';
4
4
  import { ZeniAPI } from '../../../zeniAPI';
5
5
  import { approveOAuthConsent, approveOAuthConsentFailure, approveOAuthConsentSuccess } from '../zeniOAuthReducer';
6
6
  export type ActionType = ReturnType<typeof approveOAuthConsent> | ReturnType<typeof approveOAuthConsentSuccess> | ReturnType<typeof approveOAuthConsentFailure> | ReturnType<typeof openSnackbar>;
7
- export declare const approveOAuthConsentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
7
+ export declare const approveOAuthConsentEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
8
8
  payload: {
9
9
  messageSection: import("../../..").SnackbarMessageSections;
10
10
  messageText: import("../../..").SnackbarMessageSectionTexts;
@@ -12,11 +12,10 @@ const failureSnackbar = (reason) => (0, snackbarReducer_1.openSnackbar)({
12
12
  type: 'error',
13
13
  variables: [{ variableName: '__reason__', variableValue: reason }],
14
14
  });
15
- const approveOAuthConsentEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(zeniOAuthReducer_1.approveOAuthConsent.match),
16
- // `approveOAuthConsent` reducer sets fetchState to In-Progress before epics
17
- // run, so a guard on In-Progress would block every legitimate request.
18
- // exhaustMap drops duplicate approve clicks while the HTTP call is in flight.
19
- (0, operators_1.exhaustMap)((action) => {
15
+ const approveOAuthConsentEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(zeniOAuthReducer_1.approveOAuthConsent.match), (0, operators_1.switchMap)((action) => {
16
+ if (state$.value.zeniOAuthViewState.fetchState === 'In-Progress') {
17
+ return (0, rxjs_1.from)([]);
18
+ }
20
19
  const { userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType, } = action.payload;
21
20
  const authHeaders = {
22
21
  'zeni-user-id': userId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.34-betaRD1",
3
+ "version": "5.0.34-betaRR0",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",