@@ -2,6 +2,7 @@ import type { Hooks, On, WalkerOS } from '@elbwalker/types';
22import type { SourceWalkerjs , DestinationWeb , Elb } from '../types' ;
33import {
44 Const ,
5+ addDestination ,
56 assign ,
67 isArray ,
78 isElementOrDocument ,
@@ -14,7 +15,6 @@ import {
1415} from '@elbwalker/utils' ;
1516import { initScopeTrigger , ready } from './trigger' ;
1617import { getState } from './state' ;
17- import { addDestination } from './destination' ;
1818import { run } from './run' ;
1919import { addHook } from './hooks' ;
2020
@@ -40,18 +40,21 @@ export async function handleCommand(
4040 ) . config ;
4141 break ;
4242 case Const . Commands . Consent :
43- if ( isObject ( data ) ) setConsent ( instance , data as WalkerOS . Consent ) ;
43+ if ( isObject ( data ) ) {
44+ const foo = await setConsent ( instance , data as WalkerOS . Consent ) ;
45+ }
4446 break ;
4547 case Const . Commands . Custom :
4648 if ( isObject ( data ) ) instance . custom = assign ( instance . custom , data ) ;
4749 break ;
4850 case Const . Commands . Destination :
49- isObject ( data ) &&
50- addDestination (
51+ if ( isObject ( data ) ) {
52+ await addDestination (
5153 instance ,
5254 data as DestinationWeb . Destination ,
5355 options as DestinationWeb . Config ,
5456 ) ;
57+ }
5558 break ;
5659 case Const . Commands . Globals :
5760 if ( isObject ( data ) ) instance . globals = assign ( instance . globals , data ) ;
@@ -71,16 +74,23 @@ export async function handleCommand(
7174 on ( instance , data as On . Types , options as On . Options ) ;
7275 break ;
7376 case Const . Commands . Run :
74- ready ( instance , run , instance , data as Partial < SourceWalkerjs . State > ) ;
77+ await ready (
78+ instance ,
79+ run ,
80+ instance ,
81+ data as Partial < SourceWalkerjs . State > ,
82+ ) ;
7583 break ;
7684 case Const . Commands . User :
7785 if ( isObject ( data ) ) assign ( instance . user , data , { shallow : false } ) ;
7886 break ;
7987 default :
8088 break ;
8189 }
90+
8291 result . status . ok = true ;
8392
93+ // @TODO return result
8494 return result ;
8595}
8696
@@ -105,11 +115,7 @@ export async function handleEvent(
105115 // Add event to internal queue
106116 instance . queue . push ( event ) ;
107117
108- const foo = await pushToDestinations (
109- instance ,
110- instance . destinations ,
111- event ,
112- ) ;
118+ await pushToDestinations ( instance , instance . destinations , event ) ;
113119
114120 result . status . ok = true ;
115121 } ) ( ) ;
0 commit comments