@claspo/renderer 18.11.0-dsp3 → 18.12.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.
- package/action/ActionFactory.js +1 -1
- package/action/actions/GoToNextViewAction.d.ts +3 -2
- package/action/actions/GoToNextViewAction.js +1 -1
- package/action/actions/GoToViewAction.d.ts +3 -2
- package/action/actions/GoToViewAction.js +1 -1
- package/action/actions/interceptForwardNavigation.d.ts +1 -0
- package/action/actions/interceptForwardNavigation.js +1 -0
- package/package.json +2 -2
- package/sdk/source/sources/DataLayerSource.js +1 -1
- package/sdk/source/sources/transformDataLayerEvent.d.ts +2 -0
- package/sdk/source/sources/transformDataLayerEvent.interface.d.ts +9 -0
- package/sdk/source/sources/transformDataLayerEvent.interface.js +1 -0
- package/sdk/source/sources/transformDataLayerEvent.js +1 -0
package/action/ActionFactory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import SysActionTypes from"./SysActionTypes";import SubscribeContactAction from"./actions/SubscribeContactAction";import RequestAction from"./actions/RequestAction";import DispatchEventAction from"./actions/DispatchEventAction";import GoToPreviousViewAction from"./actions/GoToPreviousViewAction";import GoToNextViewAction from"./actions/GoToNextViewAction";import GoToViewAction from"./actions/GoToViewAction";import HttpClient from"@claspo/common/network/HttpClient";import ShowWidgetAction from"./actions/ShowWidgetAction";import OpenLinkAction from"./actions/OpenLinkAction";import CloseWidgetAction from"./actions/CloseWidgetAction";export default class ActionFactory{constructor(t,i,e,o,
|
|
1
|
+
import SysActionTypes from"./SysActionTypes";import SubscribeContactAction from"./actions/SubscribeContactAction";import RequestAction from"./actions/RequestAction";import DispatchEventAction from"./actions/DispatchEventAction";import GoToPreviousViewAction from"./actions/GoToPreviousViewAction";import GoToNextViewAction from"./actions/GoToNextViewAction";import GoToViewAction from"./actions/GoToViewAction";import HttpClient from"@claspo/common/network/HttpClient";import ShowWidgetAction from"./actions/ShowWidgetAction";import OpenLinkAction from"./actions/OpenLinkAction";import CloseWidgetAction from"./actions/CloseWidgetAction";export default class ActionFactory{constructor(t,i,e,o,s,c,n){this.eventEmitter=t,this.form=i,this.configService=e,this.tracking=o,this.stateService=s,this.context=c,this.getServices=n}get(t){switch(t.type){case SysActionTypes.SUBSCRIBE_CONTACT:return new SubscribeContactAction(this.eventEmitter,this.form,t,HttpClient,this.configService,this.tracking,this.stateService,this.context,this.getServices);case SysActionTypes.REQUEST:return new RequestAction(this.eventEmitter,this.form,t,HttpClient,this.configService,this.tracking,this.stateService,this.context,this.getServices);case SysActionTypes.DISPATCH_EVENT:return new DispatchEventAction(this.eventEmitter,t,this.form,this.configService,this.context);case SysActionTypes.GO_TO_VIEW:return new GoToViewAction(this.eventEmitter,t,this.configService,this.form,this.getServices().viewRouter,this.getServices().documentModel,this.tracking,this.getServices().activePathTracker,this.stateService);case SysActionTypes.GO_TO_PREVIOUS_VIEW:return new GoToPreviousViewAction(this.eventEmitter,t,this.tracking,this.getServices().activePathTracker);case SysActionTypes.GO_TO_NEXT_VIEW:return new GoToNextViewAction(this.eventEmitter,this.form,t,this.tracking,this.stateService);case SysActionTypes.SHOW_WIDGET:return new ShowWidgetAction(this.eventEmitter,t,this.tracking);case SysActionTypes.OPEN_LINK:return new OpenLinkAction(t,this.configService,this.tracking);case SysActionTypes.CLOSE_WIDGET:return new CloseWidgetAction(this.eventEmitter,t,this.configService,this.tracking);default:throw new Error(`Not supported action type ${t.type}`)}}}
|
|
@@ -4,7 +4,8 @@ export default class GoToNextViewAction {
|
|
|
4
4
|
form: any;
|
|
5
5
|
config: any;
|
|
6
6
|
tracking: any;
|
|
7
|
+
stateService: any;
|
|
7
8
|
type: SysActionTypes;
|
|
8
|
-
constructor(eventEmitter: any, form: any, config: any, tracking: any);
|
|
9
|
-
execute(): Promise<boolean>;
|
|
9
|
+
constructor(eventEmitter: any, form: any, config: any, tracking: any, stateService?: any);
|
|
10
|
+
execute(_state?: any, _event?: any, force?: boolean): Promise<boolean>;
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import SysActionTypes from"../SysActionTypes";export default class GoToNextViewAction{constructor(t,i,e,
|
|
1
|
+
import SysActionTypes from"../SysActionTypes";import interceptForwardNavigation from"./interceptForwardNavigation";export default class GoToNextViewAction{constructor(t,i,e,r,o){this.type=SysActionTypes.GO_TO_NEXT_VIEW,this.eventEmitter=t,this.form=i,this.config=e,this.tracking=r,this.stateService=o}async execute(t,i,e=!1){if(this.form.markAsTouched(),interceptForwardNavigation(this.stateService,this.eventEmitter,e))return!1;if(this.form.getControlsAsArray().length){if(!await this.form.waitForPendingValidationAndCheckIfValid())return this.eventEmitter.emit("INVALID_CONTACT_DATA_SUBMIT_ATTEMPT"),!1}return this.eventEmitter.emit(this.type),!0}}
|
|
@@ -7,9 +7,10 @@ export default class GoToViewAction {
|
|
|
7
7
|
documentModel: any;
|
|
8
8
|
tracking: any;
|
|
9
9
|
activePathTracker: any;
|
|
10
|
+
stateService: any;
|
|
10
11
|
type: SysActionTypes;
|
|
11
|
-
constructor(eventEmitter: any, actionConfig: any, configService: any, form: any, viewRouter: any, documentModel: any, tracking: any, activePathTracker: any);
|
|
12
|
-
execute(): Promise<boolean>;
|
|
12
|
+
constructor(eventEmitter: any, actionConfig: any, configService: any, form: any, viewRouter: any, documentModel: any, tracking: any, activePathTracker: any, stateService?: any);
|
|
13
|
+
execute(_state?: any, _event?: any, force?: boolean): Promise<boolean>;
|
|
13
14
|
private getTargetViewIndex;
|
|
14
15
|
private isForwardNavigation;
|
|
15
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import SysActionTypes from"../SysActionTypes";import ErrorLogger from"../../error/ErrorLogger";export default class GoToViewAction{constructor(t,i,e,r,o,
|
|
1
|
+
import SysActionTypes from"../SysActionTypes";import ErrorLogger from"../../error/ErrorLogger";import interceptForwardNavigation from"./interceptForwardNavigation";export default class GoToViewAction{constructor(t,i,e,r,a,o,n,s,c){this.type=SysActionTypes.GO_TO_VIEW,this.eventEmitter=t,this.config=i,this.form=r,this.viewRouter=a,this.documentModel=o,this.tracking=n,this.activePathTracker=s,this.stateService=c}async execute(t,i,e=!1){var r;try{this.form.markAsTouched();const t=this.isForwardNavigation(this.getTargetViewIndex());if(t&&interceptForwardNavigation(this.stateService,this.eventEmitter,e))return!1;if(t&&(null===(r=this.config.params.validateForm)||void 0===r||r)){if(!await this.form.waitForPendingValidationAndCheckIfValid())return this.eventEmitter.emit("INVALID_CONTACT_DATA_SUBMIT_ATTEMPT"),!1}return this.eventEmitter.emit(this.type,this.config.params.viewId||this.config.params.viewIndex,{isForward:t}),this.config.params.trackClick&&this.tracking.trackClick({params:this.config.params.trackClickParams,countAsTargetAction:this.config.params.countAsTargetAction}),!0}catch(t){return ErrorLogger.log(`GoToViewAction.execute failed: ${(null==t?void 0:t.stack)||t}`),!1}}getTargetViewIndex(){return this.config.params.viewId?this.documentModel.getViews().findIndex(t=>t.id===this.config.params.viewId):this.config.params.viewIndex}isForwardNavigation(t){var i,e,r;if("number"!=typeof t||t<0)return!1;const a=null!==(r=null===(e=null===(i=this.activePathTracker)||void 0===i?void 0:i.getActivePath)||void 0===e?void 0:e.call(i))&&void 0!==r?r:[];return a.length?!a.includes(t):this.viewRouter.getCurrentViewIndex()<t}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function interceptForwardNavigation(stateService: any, eventEmitter: any, force: boolean): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function interceptForwardNavigation(t,i,n){var o,e;const a=(null===(o=null==t?void 0:t.getState)||void 0===o?void 0:o.call(t))||{};if(!a.interceptForwardNavigationActions||n)return!1;const r=null===(e=a.emitActionOnForwardNavigation)||void 0===e?void 0:e.eventName;return r&&i.emit(r),!0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claspo/renderer",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.12.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": " tsc --project tsconfig.json --watch",
|
|
6
6
|
"build": "rm -rf out && tsc --project tsconfig.json && npm run minify",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"node": ">=18.16.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@claspo/common": "7.5.
|
|
18
|
+
"@claspo/common": "7.5.8",
|
|
19
19
|
"@testing-library/dom": "^10.4.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import isDictionary from"@claspo/common/object/isDictionary";import flatMap from"@claspo/common/utils/flatMap";function getPropPathArray(r){return r?flatMap(r.value.split(".").map(r=>r.trim()).map(r=>r.split(/[\[\]]/)),r=>r).filter(r=>!!r):[]}class DataLayerSource extends DefaultEventEmitter{constructor(){super()}subscribe(r){}getValue(r){return r?{processor:(r,
|
|
1
|
+
import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import isDictionary from"@claspo/common/object/isDictionary";import flatMap from"@claspo/common/utils/flatMap";import transformDataLayerEvent from"./transformDataLayerEvent";function getPropPathArray(r){return r?flatMap(r.value.split(".").map(r=>r.trim()).map(r=>r.split(/[\[\]]/)),r=>r).filter(r=>!!r):[]}class DataLayerSource extends DefaultEventEmitter{constructor(){super()}subscribe(r){}getValue(r){return r?{processor:(r,a)=>DataLayerSource.processModel(a)}:{}}static processModel(r,a){if(!r.arguments)return"";const t=r.arguments.find(r=>"dataLayerEventName"===r.name),e=r.arguments.find(r=>"dataLayerPropPath"===r.name),o=!!(null==t?void 0:t.value);if(!window.dataLayer)return"";let n;for(let s=window.dataLayer.length-1;s>=0;s--){const i=window.dataLayer[s];if(o){const r=transformDataLayerEvent(i,{eventName:null==t?void 0:t.value,allowAccessors:!0});if(r){n=r.data;break}}else{const t=getPropPathArray(e),o=DataLayerSource.getValueByPropPath(i,t,r,a);if(o)return o}}if(!n)return"";const s=getPropPathArray(e);return DataLayerSource.getValueByPropPath(n,s,r,a)}static getValueByPropPath(r,a,t,e){try{const t=a.reduce((r,a)=>{if(isDictionary(r)||Array.isArray(r))return r[a];throw new Error(`Tried to access non object data by propName "${a}". Data: ${r}`)},r);return Array.isArray(t)&&!e?t.join(", "):t}catch(r){return console.error("DataLayerSource: error while getting data by prop path. Model: ",t,"Error: ",r),""}}}DataLayerSource.sourceId="DATA_LAYER";export default DataLayerSource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function readProperty(e,r,t){if(t)return e[r];const o=Object.getOwnPropertyDescriptor(e,r);if(o){if(!("value"in o))throw new TypeError(`DataLayer event property "${r}" is an accessor`);return o.value}}export default function transformDataLayerEvent(e,r={}){if(null==e||!r.allowAccessors&&"object"!=typeof e)return;const t=readProperty(e,"event",r.allowAccessors);if("string"==typeof t&&(void 0===r.eventName||t===r.eventName))return{name:t,format:"object",data:e};if("event"!==readProperty(e,"0",r.allowAccessors))return;const o=readProperty(e,"1",r.allowAccessors);return"string"!=typeof o||void 0!==r.eventName&&o!==r.eventName?void 0:{name:o,format:"command",data:readProperty(e,"2",r.allowAccessors)}}
|