@letscooee/web-sdk 0.0.9 → 0.0.12
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/CHANGELOG.md +23 -7
- package/dist/models/trigger/action/click-action-executor.js +8 -8
- package/dist/models/trigger/blocks/click-action.js +3 -3
- package/dist/models/trigger/blocks/transform.js +3 -1
- package/dist/models/trigger/elements/base-element.js +2 -2
- package/dist/models/trigger/inapp/container.js +2 -64
- package/dist/models/trigger/inapp/in-app-trigger.js +78 -0
- package/dist/renderer/block-processor.js +4 -6
- package/dist/renderer/container-renderer.js +0 -1
- package/dist/renderer/in-app-renderer.js +5 -0
- package/dist/sdk-preview.min.js +1 -1
- package/dist/sdk.min.js +1 -1
- package/dist/services/http-api.service.js +16 -0
- package/dist/services/safe-http-service.js +12 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 0.0.11, 0.0.12
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
1. Rendering condition for x(left) and y(top) position.
|
|
8
|
+
2. Rotation of the text.
|
|
9
|
+
|
|
10
|
+
## 0.0.10 (unreleased)
|
|
11
|
+
|
|
12
|
+
### Improvement:
|
|
13
|
+
1. Get trigger direction(gravity) for InAppTrigger.
|
|
14
|
+
|
|
15
|
+
### Fixes
|
|
16
|
+
1. Rename `prompt` to `pmpt`.
|
|
17
|
+
2. Use device api instead of user api to send device data.
|
|
18
|
+
|
|
19
|
+
## 0.0.9
|
|
4
20
|
|
|
5
21
|
1. Fix: glassmorphism on iOS.
|
|
6
22
|
2. Fix: Fix rendering scaled images.
|
|
7
23
|
3. Fix: Update in KPI for CTA.
|
|
8
24
|
4. Fix: Do not remove in-app if being used inside an element.
|
|
9
25
|
|
|
10
|
-
|
|
26
|
+
## 0.0.8
|
|
11
27
|
|
|
12
28
|
1. Feature: Ability of InApp to be rendered inside an element.
|
|
13
29
|
2. Fix: Overflowed content should not be rendered.
|
|
14
30
|
3. Fix: Placing in-app on east direction.
|
|
15
31
|
|
|
16
|
-
|
|
32
|
+
## 0.0.7
|
|
17
33
|
|
|
18
34
|
More feature support in the sdk.
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
## 0.0.6
|
|
21
37
|
|
|
22
38
|
1. Build: Upgrade TypeScript to 4.4.
|
|
23
39
|
2. Fix: Convert \n to `<br>` in texts.
|
|
24
40
|
|
|
25
|
-
|
|
41
|
+
## 0.0.5
|
|
26
42
|
|
|
27
43
|
Supporting changes based on the in-app composer.
|
|
28
44
|
|
|
29
|
-
|
|
45
|
+
## 0.0.3, 0.0.4
|
|
30
46
|
|
|
31
47
|
1. Fix generating token because of missing app version.
|
|
32
48
|
2. Handle scenario when `CooeeSDK` is not initialised.
|
|
33
49
|
|
|
34
|
-
|
|
50
|
+
## 0.0.2
|
|
35
51
|
|
|
36
52
|
First functional release.
|
|
@@ -105,18 +105,18 @@ var ClickActionExecutor = /** @class */ (function () {
|
|
|
105
105
|
* Performs prompt action i.e. ask for permission for location and notification.
|
|
106
106
|
*/
|
|
107
107
|
ClickActionExecutor.prototype.prompt = function () {
|
|
108
|
-
var permission = this.action.
|
|
108
|
+
var permission = this.action.pmpt;
|
|
109
109
|
if (!permission) {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
// TODO test in mobile browsers
|
|
113
|
-
if (permission === Permission.
|
|
113
|
+
if (permission === Permission.LOCATION) {
|
|
114
114
|
this.promptLocationPermission();
|
|
115
115
|
}
|
|
116
|
-
if (permission === Permission.
|
|
116
|
+
if (permission === Permission.PUSH) {
|
|
117
117
|
this.promptPushNotificationPermission();
|
|
118
118
|
}
|
|
119
|
-
if (permission === Permission.
|
|
119
|
+
if (permission === Permission.CAMERA) {
|
|
120
120
|
this.promptCameraPermission();
|
|
121
121
|
}
|
|
122
122
|
};
|
|
@@ -134,7 +134,7 @@ var ClickActionExecutor = /** @class */ (function () {
|
|
|
134
134
|
var diffInSeconds = (new Date().getTime() - startTime) / 1000;
|
|
135
135
|
var closeBehaviour;
|
|
136
136
|
if (this.action.ext || this.action.up || this.action.kv ||
|
|
137
|
-
this.action.iab || this.action.
|
|
137
|
+
this.action.iab || this.action.pmpt || this.action.share) {
|
|
138
138
|
closeBehaviour = 'CTA';
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
@@ -179,7 +179,7 @@ var ClickActionExecutor = /** @class */ (function () {
|
|
|
179
179
|
}
|
|
180
180
|
// TODO Need device endpoints to update this property
|
|
181
181
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
182
|
-
_this.apiService.
|
|
182
|
+
_this.apiService.updateDeviceProps({ 'coords': [position.coords.latitude, position.coords.longitude] });
|
|
183
183
|
_this.sendPermissionData();
|
|
184
184
|
});
|
|
185
185
|
};
|
|
@@ -195,7 +195,7 @@ var ClickActionExecutor = /** @class */ (function () {
|
|
|
195
195
|
}
|
|
196
196
|
// TODO Need device endpoints to update this property
|
|
197
197
|
if (Notification.permission !== 'default') {
|
|
198
|
-
this.apiService.
|
|
198
|
+
this.apiService.updateDeviceProps({ 'pnPerm': Notification.permission });
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
Notification.requestPermission()
|
|
@@ -260,7 +260,7 @@ var ClickActionExecutor = /** @class */ (function () {
|
|
|
260
260
|
ClickActionExecutor.prototype.sendPermissionData = function () {
|
|
261
261
|
var _this = this;
|
|
262
262
|
this.checkAllPermission().then(function (permissions) {
|
|
263
|
-
_this.apiService.
|
|
263
|
+
_this.apiService.updateDeviceProps({ 'perm': permissions });
|
|
264
264
|
});
|
|
265
265
|
};
|
|
266
266
|
return ClickActionExecutor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export var Permission;
|
|
2
2
|
(function (Permission) {
|
|
3
3
|
// eslint-disable-next-line no-unused-vars
|
|
4
|
-
Permission["
|
|
4
|
+
Permission[Permission["CAMERA"] = 1] = "CAMERA";
|
|
5
5
|
// eslint-disable-next-line no-unused-vars
|
|
6
|
-
Permission["
|
|
6
|
+
Permission[Permission["LOCATION"] = 2] = "LOCATION";
|
|
7
7
|
// eslint-disable-next-line no-unused-vars
|
|
8
|
-
Permission["
|
|
8
|
+
Permission[Permission["PUSH"] = 6] = "PUSH";
|
|
9
9
|
})(Permission || (Permission = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Background, Border } from '../blocks';
|
|
1
|
+
import { Background, Border, Transform } from '../blocks';
|
|
2
2
|
var BaseElement = /** @class */ (function () {
|
|
3
3
|
function BaseElement(data) {
|
|
4
4
|
this.t = data.t;
|
|
@@ -6,10 +6,10 @@ var BaseElement = /** @class */ (function () {
|
|
|
6
6
|
this.bg = new Background(data.bg);
|
|
7
7
|
if (data.br)
|
|
8
8
|
this.br = new Border(data.br);
|
|
9
|
+
this.trf = new Transform(data.trf);
|
|
9
10
|
this.clc = data.clc;
|
|
10
11
|
this.shd = data.shd;
|
|
11
12
|
this.spc = data.spc;
|
|
12
|
-
this.trf = data.trf;
|
|
13
13
|
this.w = data.w;
|
|
14
14
|
this.h = data.h;
|
|
15
15
|
this.x = data.x;
|
|
@@ -22,70 +22,8 @@ var Container = /** @class */ (function (_super) {
|
|
|
22
22
|
_this.o = (_a = data.o) !== null && _a !== void 0 ? _a : ContainerOrigin.C;
|
|
23
23
|
return _this;
|
|
24
24
|
}
|
|
25
|
-
Container.prototype.
|
|
26
|
-
|
|
27
|
-
if (this.o === ContainerOrigin.NW) {
|
|
28
|
-
styles = {
|
|
29
|
-
top: 0,
|
|
30
|
-
left: 0,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
else if (this.o === ContainerOrigin.N) {
|
|
34
|
-
styles = {
|
|
35
|
-
top: 0,
|
|
36
|
-
left: '50%',
|
|
37
|
-
transform: 'translateX(-50%)',
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
else if (this.o === ContainerOrigin.NE) {
|
|
41
|
-
styles = {
|
|
42
|
-
top: 0,
|
|
43
|
-
right: 0,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
else if (this.o === ContainerOrigin.E) {
|
|
47
|
-
styles = {
|
|
48
|
-
top: '50%',
|
|
49
|
-
right: 0,
|
|
50
|
-
transform: 'translateY(-50%)',
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
else if (this.o === ContainerOrigin.SE) {
|
|
54
|
-
styles = {
|
|
55
|
-
bottom: 0,
|
|
56
|
-
right: 0,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else if (this.o === ContainerOrigin.S) {
|
|
60
|
-
styles = {
|
|
61
|
-
bottom: 0,
|
|
62
|
-
left: '50%',
|
|
63
|
-
transform: 'translateX(-50%)',
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
else if (this.o === ContainerOrigin.SW) {
|
|
67
|
-
styles = {
|
|
68
|
-
bottom: 0,
|
|
69
|
-
left: 0,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
else if (this.o === ContainerOrigin.W) {
|
|
73
|
-
styles = {
|
|
74
|
-
top: '50%',
|
|
75
|
-
left: 0,
|
|
76
|
-
transform: 'translateY(-50%)',
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
styles = {
|
|
81
|
-
top: '50%',
|
|
82
|
-
left: '50%',
|
|
83
|
-
transform: 'translateX(-50%) translateY(-50%)',
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
styles.position = 'absolute';
|
|
87
|
-
styles.overflow = 'hidden';
|
|
88
|
-
return styles;
|
|
25
|
+
Container.prototype.getOrigin = function () {
|
|
26
|
+
return this.o;
|
|
89
27
|
};
|
|
90
28
|
return Container;
|
|
91
29
|
}(BaseElement));
|
|
@@ -12,6 +12,7 @@ var InAppTrigger = /** @class */ (function () {
|
|
|
12
12
|
var _this = this;
|
|
13
13
|
this.elems = [];
|
|
14
14
|
this.cont = new Container(data.cont);
|
|
15
|
+
this.gvt = data.gvt;
|
|
15
16
|
data.elems.forEach(function (rawElement) {
|
|
16
17
|
if (rawElement.t === ElementType.IMAGE) {
|
|
17
18
|
_this.elems.push(new ImageElement(rawElement));
|
|
@@ -27,6 +28,83 @@ var InAppTrigger = /** @class */ (function () {
|
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
}
|
|
31
|
+
InAppTrigger.prototype.getStyles = function () {
|
|
32
|
+
var styles;
|
|
33
|
+
if (this.gvt === ContainerOrigin.NW) {
|
|
34
|
+
styles = {
|
|
35
|
+
top: 0,
|
|
36
|
+
left: 0,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else if (this.gvt === ContainerOrigin.N) {
|
|
40
|
+
styles = {
|
|
41
|
+
top: 0,
|
|
42
|
+
left: '50%',
|
|
43
|
+
transform: 'translateX(-50%)',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else if (this.gvt === ContainerOrigin.NE) {
|
|
47
|
+
styles = {
|
|
48
|
+
top: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else if (this.gvt === ContainerOrigin.E) {
|
|
53
|
+
styles = {
|
|
54
|
+
top: '50%',
|
|
55
|
+
right: 0,
|
|
56
|
+
transform: 'translateY(-50%)',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else if (this.gvt === ContainerOrigin.SE) {
|
|
60
|
+
styles = {
|
|
61
|
+
bottom: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else if (this.gvt === ContainerOrigin.S) {
|
|
66
|
+
styles = {
|
|
67
|
+
bottom: 0,
|
|
68
|
+
left: '50%',
|
|
69
|
+
transform: 'translateX(-50%)',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else if (this.gvt === ContainerOrigin.SW) {
|
|
73
|
+
styles = {
|
|
74
|
+
bottom: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else if (this.gvt === ContainerOrigin.W) {
|
|
79
|
+
styles = {
|
|
80
|
+
top: '50%',
|
|
81
|
+
left: 0,
|
|
82
|
+
transform: 'translateY(-50%)',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
styles = {
|
|
87
|
+
top: '50%',
|
|
88
|
+
left: '50%',
|
|
89
|
+
transform: 'translateX(-50%) translateY(-50%)',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
styles.position = 'absolute';
|
|
93
|
+
styles.overflow = 'hidden';
|
|
94
|
+
return styles;
|
|
95
|
+
};
|
|
30
96
|
return InAppTrigger;
|
|
31
97
|
}());
|
|
32
98
|
export { InAppTrigger };
|
|
99
|
+
export var ContainerOrigin;
|
|
100
|
+
(function (ContainerOrigin) {
|
|
101
|
+
ContainerOrigin[ContainerOrigin["NW"] = 1] = "NW";
|
|
102
|
+
ContainerOrigin[ContainerOrigin["N"] = 2] = "N";
|
|
103
|
+
ContainerOrigin[ContainerOrigin["NE"] = 3] = "NE";
|
|
104
|
+
ContainerOrigin[ContainerOrigin["W"] = 4] = "W";
|
|
105
|
+
ContainerOrigin[ContainerOrigin["C"] = 5] = "C";
|
|
106
|
+
ContainerOrigin[ContainerOrigin["E"] = 6] = "E";
|
|
107
|
+
ContainerOrigin[ContainerOrigin["SW"] = 7] = "SW";
|
|
108
|
+
ContainerOrigin[ContainerOrigin["S"] = 8] = "S";
|
|
109
|
+
ContainerOrigin[ContainerOrigin["SE"] = 9] = "SE";
|
|
110
|
+
})(ContainerOrigin || (ContainerOrigin = {}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Renderer } from './renderer';
|
|
2
2
|
import { ClickActionExecutor } from '../models/trigger/action/click-action-executor';
|
|
3
|
+
import { Transform } from '../models/trigger/blocks';
|
|
3
4
|
import { getScalingFactor } from './index';
|
|
4
5
|
import { Container } from '../models/trigger/inapp/container';
|
|
5
6
|
/**
|
|
@@ -62,14 +63,11 @@ var BlockProcessor = /** @class */ (function () {
|
|
|
62
63
|
* Process position block of the element
|
|
63
64
|
*/
|
|
64
65
|
BlockProcessor.prototype.processPositionBlock = function () {
|
|
65
|
-
if (!this.inappElement.x) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
66
|
this.renderer.setStyle(this.inappHTMLEl, 'position', 'absolute');
|
|
69
67
|
if (this.inappElement.x)
|
|
70
|
-
this.renderer.setStyle(this.inappHTMLEl, 'top', this.getSizePx(this.inappElement.y));
|
|
71
|
-
if (this.inappElement.y)
|
|
72
68
|
this.renderer.setStyle(this.inappHTMLEl, 'left', this.getSizePx(this.inappElement.x));
|
|
69
|
+
if (this.inappElement.y)
|
|
70
|
+
this.renderer.setStyle(this.inappHTMLEl, 'top', this.getSizePx(this.inappElement.y));
|
|
73
71
|
};
|
|
74
72
|
/**
|
|
75
73
|
* Process border block of the element
|
|
@@ -120,7 +118,7 @@ var BlockProcessor = /** @class */ (function () {
|
|
|
120
118
|
* Process transform block of the element
|
|
121
119
|
*/
|
|
122
120
|
BlockProcessor.prototype.processTransformBlock = function () {
|
|
123
|
-
var transform = this.inappElement.trf;
|
|
121
|
+
var transform = new Transform(this.inappElement.trf);
|
|
124
122
|
if (!transform) {
|
|
125
123
|
return;
|
|
126
124
|
}
|
|
@@ -38,7 +38,6 @@ var ContainerRenderer = /** @class */ (function (_super) {
|
|
|
38
38
|
ContainerRenderer.prototype.render = function () {
|
|
39
39
|
this.processCommonBlocks();
|
|
40
40
|
this.renderer.setStyle(this.inappHTMLEl, 'position', 'relative');
|
|
41
|
-
Object.assign(this.inappHTMLEl.style, this.inappElement.getStyles());
|
|
42
41
|
return this;
|
|
43
42
|
};
|
|
44
43
|
return ContainerRenderer;
|
|
@@ -75,6 +75,11 @@ var InAppRenderer = /** @class */ (function () {
|
|
|
75
75
|
var containerHTMLElement = new ContainerRenderer(this.rootContainer, container)
|
|
76
76
|
.render()
|
|
77
77
|
.getHTMLElement();
|
|
78
|
+
// Forward compatibility
|
|
79
|
+
if (!this.ian.gvt) {
|
|
80
|
+
this.ian.gvt = this.ian.cont.getOrigin();
|
|
81
|
+
}
|
|
82
|
+
Object.assign(containerHTMLElement.style, this.ian.getStyles());
|
|
78
83
|
(_b = this.ian.elems) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
|
|
79
84
|
_this.renderElement(containerHTMLElement, element);
|
|
80
85
|
});
|