@applicaster/zapp-react-native-utils 12.0.18-rc.0 → 12.0.19-alpha.2459140393
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
-
import React, { createContext, useMemo } from "react";
|
|
3
|
+
import React, { createContext, useEffect, useMemo } from "react";
|
|
4
4
|
import {
|
|
5
5
|
actionExecutor as _actionExecutor,
|
|
6
6
|
ActionResult,
|
|
@@ -19,7 +19,12 @@ import {
|
|
|
19
19
|
EntryResolver,
|
|
20
20
|
resolveObjectValues,
|
|
21
21
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
22
|
+
import { useNavigation } from "../reactHooks";
|
|
22
23
|
import { get } from "lodash";
|
|
24
|
+
import {
|
|
25
|
+
useContentTypes,
|
|
26
|
+
usePickFromState,
|
|
27
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
23
28
|
|
|
24
29
|
const { log_error, log_info } = createLogger({
|
|
25
30
|
subsystem: "ActionExecutorContext",
|
|
@@ -251,6 +256,10 @@ export function withActionExecutor(Component) {
|
|
|
251
256
|
prepareDefaultActions(_actionExecutor);
|
|
252
257
|
|
|
253
258
|
return function ActionExecutorComponent(props: Props) {
|
|
259
|
+
const navigator = useNavigation();
|
|
260
|
+
const { rivers } = usePickFromState(["rivers"]);
|
|
261
|
+
const contentTypes = useContentTypes();
|
|
262
|
+
|
|
254
263
|
const handlers = useMemo(() => {
|
|
255
264
|
return {
|
|
256
265
|
unregisterAction: _actionExecutor.unregisterAction,
|
|
@@ -261,6 +270,44 @@ export function withActionExecutor(Component) {
|
|
|
261
270
|
};
|
|
262
271
|
}, []);
|
|
263
272
|
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
return _actionExecutor.registerAction(
|
|
275
|
+
"navigateToScreen",
|
|
276
|
+
async (action: ActionType, context?: Record<string, any>) => {
|
|
277
|
+
const screenType = action.options?.typeMapping;
|
|
278
|
+
|
|
279
|
+
if (!screenType) {
|
|
280
|
+
log_error("navigateToScreen: typeMapping option is missing");
|
|
281
|
+
|
|
282
|
+
return ActionResult.Error;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const screenId = contentTypes?.[screenType]?.screen_id || null;
|
|
286
|
+
|
|
287
|
+
if (!screenId) {
|
|
288
|
+
log_error(
|
|
289
|
+
`navigateToScreen: can not resolve screen type mapping: ${screenType}`
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
return ActionResult.Error;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const river = rivers[screenId];
|
|
296
|
+
|
|
297
|
+
if (!river) {
|
|
298
|
+
log_error("navigateToScreen: can not resolve river");
|
|
299
|
+
|
|
300
|
+
return ActionResult.Error;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
context?.callback?.({ success: false, error: null, abort: true });
|
|
304
|
+
navigator.replace(river);
|
|
305
|
+
|
|
306
|
+
return ActionResult.Success;
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
}, [navigator, rivers, contentTypes]);
|
|
310
|
+
|
|
264
311
|
return (
|
|
265
312
|
<ActionExecutorContext.Provider value={handlers}>
|
|
266
313
|
<Component {...props} />
|
|
@@ -56,6 +56,10 @@ export class Hook {
|
|
|
56
56
|
* @param {Array<Any>} args variadic arguments to invoke the handler with
|
|
57
57
|
*/
|
|
58
58
|
setStateAndNotify(event, ...args) {
|
|
59
|
+
if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
this.state = hookState(event);
|
|
60
64
|
this.manager.invokeHandler(event, ...args);
|
|
61
65
|
}
|
|
@@ -230,6 +230,7 @@ export function HooksManager({
|
|
|
230
230
|
payload = initialPayload,
|
|
231
231
|
callback,
|
|
232
232
|
cancelled,
|
|
233
|
+
abort,
|
|
233
234
|
}) {
|
|
234
235
|
if (error) {
|
|
235
236
|
logHookEvent(
|
|
@@ -267,6 +268,7 @@ export function HooksManager({
|
|
|
267
268
|
hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
|
|
268
269
|
hookPlugin,
|
|
269
270
|
payload,
|
|
271
|
+
abort,
|
|
270
272
|
});
|
|
271
273
|
|
|
272
274
|
const isHookInHomescreen = payload?.home;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.19-alpha.2459140393",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.19-alpha.2459140393",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|