@@ -5,6 +5,7 @@ import isString from 'lodash/isString';
55import isNumber from 'lodash/isNumber' ;
66import isFunction from 'lodash/isFunction' ;
77import isUndefined from 'lodash/isUndefined' ;
8+ import cloneDeep from 'lodash/cloneDeep' ;
89import { COMPONENT_TYPE , USER_FUNCTION_TYPE , DISPATCH_ERROR_TYPE } from './constants' ;
910import { getUserFunctionByName } from './sequences' ;
1011
@@ -76,45 +77,51 @@ function dispatchToComponent (props, payload, dispatch, helpers) {
7677 }
7778 }
7879 if ( process . env . NODE_ENV !== 'production' ) {
79- sendDebugMessage ( {
80- key : componentKey ,
81- eventType : constants . DEBUG_MSG_FORWARD_EVENT ,
82- forwardPath,
83- inputData : transformedPayload ,
84- propertyName,
85- pathString,
86- timestamp : Date . now ( ) ,
87- } ) ;
80+ if ( window . __webcodeskIsListeningToFramework && window . __sendFrameworkMessage ) {
81+ sendDebugMessage ( {
82+ key : componentKey ,
83+ eventType : constants . DEBUG_MSG_FORWARD_EVENT ,
84+ forwardPath,
85+ inputData : cloneDeep ( transformedPayload ) ,
86+ propertyName,
87+ pathString,
88+ timestamp : Date . now ( ) ,
89+ } ) ;
90+ }
8891 }
8992 history . push ( pathString ) ;
9093 } else if ( propertyName ) {
9194 // hmmm... why there can not be the history helper?
9295 const targetKey = `${ componentName } _${ componentInstance } ` ;
9396 if ( process . env . NODE_ENV !== 'production' ) {
97+ if ( window . __webcodeskIsListeningToFramework && window . __sendFrameworkMessage ) {
98+ sendDebugMessage ( {
99+ key : componentKey ,
100+ eventType : constants . DEBUG_MSG_REDUCE_DATA_EVENT ,
101+ inputData : cloneDeep ( transformedPayload ) ,
102+ componentName,
103+ componentInstance,
104+ propertyName,
105+ timestamp : Date . now ( ) ,
106+ } ) ;
107+ }
108+ }
109+ dispatch ( { type : targetKey , payload : { [ propertyName ] : transformedPayload } } ) ;
110+ }
111+ } else {
112+ const targetKey = `${ componentName } _${ componentInstance } ` ;
113+ if ( process . env . NODE_ENV !== 'production' ) {
114+ if ( window . __webcodeskIsListeningToFramework && window . __sendFrameworkMessage ) {
94115 sendDebugMessage ( {
95116 key : componentKey ,
96117 eventType : constants . DEBUG_MSG_REDUCE_DATA_EVENT ,
97- inputData : transformedPayload ,
118+ inputData : cloneDeep ( transformedPayload ) ,
98119 componentName,
99120 componentInstance,
100121 propertyName,
101122 timestamp : Date . now ( ) ,
102123 } ) ;
103124 }
104- dispatch ( { type : targetKey , payload : { [ propertyName ] : transformedPayload } } ) ;
105- }
106- } else {
107- const targetKey = `${ componentName } _${ componentInstance } ` ;
108- if ( process . env . NODE_ENV !== 'production' ) {
109- sendDebugMessage ( {
110- key : componentKey ,
111- eventType : constants . DEBUG_MSG_REDUCE_DATA_EVENT ,
112- inputData : transformedPayload ,
113- componentName,
114- componentInstance,
115- propertyName,
116- timestamp : Date . now ( ) ,
117- } ) ;
118125 }
119126 dispatch ( { type : targetKey , payload : { [ propertyName ] : transformedPayload } } ) ;
120127 }
@@ -151,14 +158,16 @@ function executeUserFunctionDispatch (
151158 if ( eventTargets && eventTargets . length > 0 ) {
152159 payload = dispatchPayloads [ dispatchType ] ;
153160 if ( process . env . NODE_ENV !== 'production' ) {
154- sendDebugMessage ( {
155- key : functionKey ,
156- eventType : constants . DEBUG_MSG_FUNCTION_FIRE_EVENT ,
157- eventName : dispatchType ,
158- outputData : payload ,
159- functionName : functionName ,
160- timestamp : Date . now ( ) ,
161- } ) ;
161+ if ( window . __webcodeskIsListeningToFramework && window . __sendFrameworkMessage ) {
162+ sendDebugMessage ( {
163+ key : functionKey ,
164+ eventType : constants . DEBUG_MSG_FUNCTION_FIRE_EVENT ,
165+ eventName : dispatchType ,
166+ outputData : cloneDeep ( payload ) ,
167+ functionName : functionName ,
168+ timestamp : Date . now ( ) ,
169+ } ) ;
170+ }
162171 }
163172 eventTargets . forEach ( eventTarget => {
164173 const { type : eventTargetType , props : eventTargetProps } = eventTarget ;
@@ -240,13 +249,15 @@ function createTasks (targets) {
240249 transformFirstArgument ( props . functionKey , props . transformScript , args [ 0 ] ) ;
241250 // execute user function with passed in args
242251 if ( process . env . NODE_ENV !== 'production' ) {
243- sendDebugMessage ( {
244- key : props . functionKey ,
245- eventType : constants . DEBUG_MSG_FUNCTION_CALL_EVENT ,
246- inputData : firstArgument ,
247- functionName : props . functionName ,
248- timestamp : Date . now ( ) ,
249- } ) ;
252+ if ( window . __webcodeskIsListeningToFramework && window . __sendFrameworkMessage ) {
253+ sendDebugMessage ( {
254+ key : props . functionKey ,
255+ eventType : constants . DEBUG_MSG_FUNCTION_CALL_EVENT ,
256+ inputData : cloneDeep ( firstArgument ) ,
257+ functionName : props . functionName ,
258+ timestamp : Date . now ( ) ,
259+ } ) ;
260+ }
250261 }
251262 // the secondary argument is used in the store items function
252263 // to determine if we are reading from the store item or writing to it
0 commit comments