@applicaster/zapp-react-native-utils 14.0.20-rc.1 → 14.0.21-rc.0

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.
@@ -318,6 +318,44 @@ export function withActionExecutor(Component) {
318
318
  return ActionResult.Error;
319
319
  }
320
320
 
321
+ const navigationAction = action.options?.navigationAction;
322
+ const entrySource = action.options?.entry;
323
+
324
+ const entry = entrySource
325
+ ? entrySource === "@{entry/}"
326
+ ? context?.entry
327
+ : entrySource
328
+ : null;
329
+
330
+ if (entry) {
331
+ if (typeof entry !== "object") {
332
+ log_error(
333
+ `navigateToScreen: entry option is not an object, entry: ${entry}`
334
+ );
335
+
336
+ return ActionResult.Error;
337
+ }
338
+
339
+ log_info(
340
+ `navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
341
+ );
342
+
343
+ const overriddenEntry = {
344
+ ...entry,
345
+ type: {
346
+ value: screenType,
347
+ },
348
+ };
349
+
350
+ if (navigationAction === "push") {
351
+ navigator.push(overriddenEntry);
352
+ } else {
353
+ navigator.replace(overriddenEntry);
354
+ }
355
+
356
+ return ActionResult.Success;
357
+ }
358
+
321
359
  const screenId = contentTypes?.[screenType]?.screen_id || null;
322
360
 
323
361
  if (!screenId) {
@@ -337,7 +375,12 @@ export function withActionExecutor(Component) {
337
375
  }
338
376
 
339
377
  context?.callback?.({ success: false, error: null, abort: true });
340
- navigator.replace(river);
378
+
379
+ if (navigationAction === "push") {
380
+ navigator.push(river);
381
+ } else {
382
+ navigator.replace(river);
383
+ }
341
384
 
342
385
  return ActionResult.Success;
343
386
  }
@@ -11,6 +11,10 @@ import { HOOKS_EVENTS, HOOKS_TYPE } from "./constants";
11
11
 
12
12
  import { hooksManagerLogger } from "./logger";
13
13
  import { HookManager, HookManagerArgs } from "./types";
14
+ import {
15
+ actionExecutor,
16
+ ActionResult,
17
+ } from "../../actionsExecutor/ActionExecutor";
14
18
 
15
19
  /**
16
20
  * orders the hooks according to their weight
@@ -280,6 +284,8 @@ export function HooksManager({
280
284
  {}
281
285
  );
282
286
 
287
+ actionExecutor.unregisterAction("finishHook");
288
+
283
289
  return;
284
290
  }
285
291
 
@@ -294,6 +300,8 @@ export function HooksManager({
294
300
  }
295
301
  );
296
302
 
303
+ actionExecutor.unregisterAction("finishHook");
304
+
297
305
  return hookPlugin.setStateAndNotify(HOOKS_EVENTS.ERROR, {
298
306
  error,
299
307
  hookPlugin,
@@ -316,6 +324,8 @@ export function HooksManager({
316
324
  // TODO: Temporary hack to pass getLoginProtocol to other plugins to refresh in case token expired, need be deleted later
317
325
  delete payload.getLoginProtocol;
318
326
 
327
+ actionExecutor.unregisterAction("finishHook");
328
+
319
329
  hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
320
330
  hookPlugin,
321
331
  payload,
@@ -381,6 +391,27 @@ export function HooksManager({
381
391
  };
382
392
  }
383
393
 
394
+ function registerFinishHookAction(payload, callback) {
395
+ // Ensure no stale finishHook remains (e.g. presentUI re-entry from runInBackground)
396
+ actionExecutor.unregisterAction("finishHook");
397
+
398
+ actionExecutor.registerAction("finishHook", async (action: ActionType) => {
399
+ const { success, errorMessage, abort } = action.options;
400
+
401
+ actionExecutor.unregisterAction("finishHook");
402
+
403
+ if (errorMessage) {
404
+ callback({ success, error: new Error(errorMessage), payload, abort });
405
+ } else {
406
+ callback({ success, error: null, payload, abort });
407
+ }
408
+
409
+ hooksManagerLogger.info("finishHook action executed, finishing flow");
410
+
411
+ return ActionResult.Success;
412
+ });
413
+ }
414
+
384
415
  /**
385
416
  * presents a screen hook by triggering an event invoking the handler with
386
417
  * the appropriate route & payload
@@ -408,6 +439,8 @@ export function HooksManager({
408
439
  }
409
440
  );
410
441
 
442
+ registerFinishHookAction(payload, callback);
443
+
411
444
  hookPlugin.setStateAndNotify(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, {
412
445
  hookPlugin,
413
446
  route: targetScreenRoute,
@@ -467,6 +500,8 @@ export function HooksManager({
467
500
  }
468
501
  );
469
502
 
503
+ registerFinishHookAction(payload, callback);
504
+
470
505
  hookPlugin.module.runInBackground(
471
506
  payload,
472
507
  callback,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "14.0.20-rc.1",
3
+ "version": "14.0.21-rc.0",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "14.0.20-rc.1",
30
+ "@applicaster/applicaster-types": "14.0.21-rc.0",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",