@applicaster/zapp-react-native-utils 15.0.0-alpha.7012242426 → 15.0.0-alpha.7122965878

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.
@@ -315,44 +315,6 @@ export function withActionExecutor(Component) {
315
315
  return ActionResult.Error;
316
316
  }
317
317
 
318
- const navigationAction = action.options?.navigationAction;
319
- const entrySource = action.options?.entry;
320
-
321
- const entry = entrySource
322
- ? entrySource === "@{entry/}"
323
- ? context?.entry
324
- : entrySource
325
- : null;
326
-
327
- if (entry) {
328
- if (typeof entry !== "object") {
329
- log_error(
330
- `navigateToScreen: entry option is not an object, entry: ${entry}`
331
- );
332
-
333
- return ActionResult.Error;
334
- }
335
-
336
- log_info(
337
- `navigateToScreen: navigating to screen type: ${screenType} with entry id: ${entry.id}`
338
- );
339
-
340
- const overriddenEntry = {
341
- ...entry,
342
- type: {
343
- value: screenType,
344
- },
345
- };
346
-
347
- if (navigationAction === "push") {
348
- navigator.push(overriddenEntry);
349
- } else {
350
- navigator.replace(overriddenEntry);
351
- }
352
-
353
- return ActionResult.Success;
354
- }
355
-
356
318
  const screenId = contentTypes?.[screenType]?.screen_id || null;
357
319
 
358
320
  if (!screenId) {
@@ -372,12 +334,7 @@ export function withActionExecutor(Component) {
372
334
  }
373
335
 
374
336
  context?.callback?.({ success: false, error: null, abort: true });
375
-
376
- if (navigationAction === "push") {
377
- navigator.push(river);
378
- } else {
379
- navigator.replace(river);
380
- }
337
+ navigator.replace(river);
381
338
 
382
339
  return ActionResult.Success;
383
340
  }
@@ -11,10 +11,6 @@ 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";
18
14
 
19
15
  /**
20
16
  * orders the hooks according to their weight
@@ -284,8 +280,6 @@ export function HooksManager({
284
280
  {}
285
281
  );
286
282
 
287
- actionExecutor.unregisterAction("finishHook");
288
-
289
283
  return;
290
284
  }
291
285
 
@@ -300,8 +294,6 @@ export function HooksManager({
300
294
  }
301
295
  );
302
296
 
303
- actionExecutor.unregisterAction("finishHook");
304
-
305
297
  return hookPlugin.setStateAndNotify(HOOKS_EVENTS.ERROR, {
306
298
  error,
307
299
  hookPlugin,
@@ -324,8 +316,6 @@ export function HooksManager({
324
316
  // TODO: Temporary hack to pass getLoginProtocol to other plugins to refresh in case token expired, need be deleted later
325
317
  delete payload.getLoginProtocol;
326
318
 
327
- actionExecutor.unregisterAction("finishHook");
328
-
329
319
  hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
330
320
  hookPlugin,
331
321
  payload,
@@ -391,27 +381,6 @@ export function HooksManager({
391
381
  };
392
382
  }
393
383
 
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
-
415
384
  /**
416
385
  * presents a screen hook by triggering an event invoking the handler with
417
386
  * the appropriate route & payload
@@ -439,8 +408,6 @@ export function HooksManager({
439
408
  }
440
409
  );
441
410
 
442
- registerFinishHookAction(payload, callback);
443
-
444
411
  hookPlugin.setStateAndNotify(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, {
445
412
  hookPlugin,
446
413
  route: targetScreenRoute,
@@ -500,8 +467,6 @@ export function HooksManager({
500
467
  }
501
468
  );
502
469
 
503
- registerFinishHookAction(payload, callback);
504
-
505
470
  hookPlugin.module.runInBackground(
506
471
  payload,
507
472
  callback,
@@ -123,6 +123,12 @@ function getPlayerConfiguration({ platform, version }) {
123
123
  key: "skip_button_localization_text_skip_intro",
124
124
  initial_value: "Skip Intro",
125
125
  },
126
+ {
127
+ type: "text_input",
128
+ label: "Stream error message",
129
+ key: "stream_error_message",
130
+ initial_value: "Cannot play stream",
131
+ },
126
132
  {
127
133
  type: "text_input",
128
134
  label: "Locked message",
@@ -11,16 +11,6 @@ describe("toNumber", () => {
11
11
  });
12
12
  });
13
13
 
14
- it("return number if input is BigInt", () => {
15
- const inputs = [5n, -5n];
16
- expect.assertions(inputs.length);
17
-
18
- inputs.forEach((input) => {
19
- const output = toNumber(input);
20
- expect(output).toBe(Number(input));
21
- });
22
- });
23
-
24
14
  it("return number if input is string as number", () => {
25
15
  const inputs = ["-1", "0", "1", "100", "0.2"];
26
16
  expect.assertions(inputs.length);
@@ -34,6 +24,8 @@ describe("toNumber", () => {
34
24
  it("return undefined if input is not a number", () => {
35
25
  const inputs = [
36
26
  "vfdvf",
27
+ "5n",
28
+ "-5n",
37
29
  null,
38
30
  undefined,
39
31
  NaN,
@@ -42,8 +34,6 @@ describe("toNumber", () => {
42
34
  { test: 1 },
43
35
  [],
44
36
  [1],
45
- "5n",
46
- "-5n",
47
37
  ];
48
38
 
49
39
  expect.assertions(inputs.length);
@@ -53,4 +43,29 @@ describe("toNumber", () => {
53
43
  expect(output).toBeUndefined();
54
44
  });
55
45
  });
46
+
47
+ describe("BigInt support", () => {
48
+ // Conditional test based on BigInt availability
49
+ const isBigIntSupported = typeof BigInt !== "undefined";
50
+
51
+ if (isBigIntSupported) {
52
+ it("converts BigInt to number when BigInt is supported", () => {
53
+ expect(toNumber(BigInt(5))).toBe(5);
54
+ expect(toNumber(BigInt(0))).toBe(0);
55
+ expect(toNumber(BigInt(-10))).toBe(-10);
56
+ expect(toNumber(BigInt(1000))).toBe(1000);
57
+ });
58
+
59
+ it("handles large BigInt values that may lose precision", () => {
60
+ const largeBigInt = BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1);
61
+ const result = toNumber(largeBigInt);
62
+ expect(result).toBe(Number(largeBigInt));
63
+ });
64
+ } else {
65
+ it("skips BigInt tests when BigInt is not supported", () => {
66
+ // Placeholder test to indicate BigInt is not available
67
+ expect(typeof BigInt).toBe("undefined");
68
+ });
69
+ }
70
+ });
56
71
  });
@@ -156,10 +156,38 @@ describe("toPositiveNumber", () => {
156
156
  it("handles Symbol values", () => {
157
157
  expect(toPositiveNumber(Symbol("test"))).toBeUndefined();
158
158
  });
159
+ });
159
160
 
160
- it("converts BigInt values", () => {
161
- expect(toPositiveNumber(5n)).toBe(5);
162
- expect(toPositiveNumber(-5n)).toBeUndefined();
163
- });
161
+ describe("BigInt support", () => {
162
+ // Conditional test based on BigInt availability
163
+ const isBigIntSupported = typeof BigInt !== "undefined";
164
+
165
+ if (isBigIntSupported) {
166
+ it("converts positive BigInt values to numbers when BigInt is supported", () => {
167
+ expect(toPositiveNumber(BigInt(5))).toBe(5);
168
+ expect(toPositiveNumber(BigInt(100))).toBe(100);
169
+ expect(toPositiveNumber(BigInt(1000))).toBe(1000);
170
+ });
171
+
172
+ it("returns undefined for zero BigInt", () => {
173
+ expect(toPositiveNumber(BigInt(0))).toBeUndefined();
174
+ });
175
+
176
+ it("returns undefined for negative BigInt values", () => {
177
+ expect(toPositiveNumber(BigInt(-5))).toBeUndefined();
178
+ expect(toPositiveNumber(BigInt(-100))).toBeUndefined();
179
+ });
180
+
181
+ it("handles large positive BigInt values", () => {
182
+ const largeBigInt = BigInt(Number.MAX_SAFE_INTEGER);
183
+ const result = toPositiveNumber(largeBigInt);
184
+ expect(result).toBe(Number(largeBigInt));
185
+ });
186
+ } else {
187
+ it("skips BigInt tests when BigInt is not supported", () => {
188
+ // Placeholder test to indicate BigInt is not available
189
+ expect(typeof BigInt).toBe("undefined");
190
+ });
191
+ }
164
192
  });
165
193
  });
@@ -8,7 +8,11 @@ export const toNumber = (value: unknown): number | undefined => {
8
8
  return undefined;
9
9
  }
10
10
 
11
- if (R.is(Number, value) || R.is(BigInt, value) || R.is(String, value)) {
11
+ // Feature-detect BigInt support to avoid ReferenceError on older runtimes
12
+ const isBigIntSupported = typeof BigInt !== "undefined";
13
+ const isBigIntValue = isBigIntSupported && R.is(BigInt, value);
14
+
15
+ if (R.is(Number, value) || isBigIntValue || R.is(String, value)) {
12
16
  const numberOrNan = Number(value);
13
17
 
14
18
  return Number.isNaN(numberOrNan) ? undefined : numberOrNan;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.0.0-alpha.7012242426",
3
+ "version": "15.0.0-alpha.7122965878",
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": "15.0.0-alpha.7012242426",
30
+ "@applicaster/applicaster-types": "15.0.0-alpha.7122965878",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",