@letscooee/web-sdk
Advanced tools
Comparing version 0.0.9 to 0.0.12
# Change Log | ||
# 0.0.9 | ||
## 0.0.11, 0.0.12 | ||
### Fixes | ||
1. Rendering condition for x(left) and y(top) position. | ||
2. Rotation of the text. | ||
## 0.0.10 (unreleased) | ||
### Improvement: | ||
1. Get trigger direction(gravity) for InAppTrigger. | ||
### Fixes | ||
1. Rename `prompt` to `pmpt`. | ||
2. Use device api instead of user api to send device data. | ||
## 0.0.9 | ||
1. Fix: glassmorphism on iOS. | ||
@@ -10,3 +26,3 @@ 2. Fix: Fix rendering scaled images. | ||
# 0.0.8 | ||
## 0.0.8 | ||
@@ -17,7 +33,7 @@ 1. Feature: Ability of InApp to be rendered inside an element. | ||
# 0.0.7 | ||
## 0.0.7 | ||
More feature support in the sdk. | ||
# 0.0.6 | ||
## 0.0.6 | ||
@@ -27,7 +43,7 @@ 1. Build: Upgrade TypeScript to 4.4. | ||
# 0.0.5 | ||
## 0.0.5 | ||
Supporting changes based on the in-app composer. | ||
# 0.0.3, 0.0.4 | ||
## 0.0.3, 0.0.4 | ||
@@ -37,4 +53,4 @@ 1. Fix generating token because of missing app version. | ||
# 0.0.2 | ||
## 0.0.2 | ||
First functional release. |
@@ -108,3 +108,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
ClickActionExecutor.prototype.prompt = function () { | ||
var permission = this.action.prompt; | ||
var permission = this.action.pmpt; | ||
if (!permission) { | ||
@@ -114,9 +114,9 @@ return; | ||
// TODO test in mobile browsers | ||
if (permission === Permission.Location) { | ||
if (permission === Permission.LOCATION) { | ||
this.promptLocationPermission(); | ||
} | ||
if (permission === Permission.Push) { | ||
if (permission === Permission.PUSH) { | ||
this.promptPushNotificationPermission(); | ||
} | ||
if (permission === Permission.Camera) { | ||
if (permission === Permission.CAMERA) { | ||
this.promptCameraPermission(); | ||
@@ -139,3 +139,3 @@ } | ||
if (this.action.ext || this.action.up || this.action.kv || | ||
this.action.iab || this.action.prompt || this.action.share) { | ||
this.action.iab || this.action.pmpt || this.action.share) { | ||
closeBehaviour = 'CTA'; | ||
@@ -185,3 +185,3 @@ } | ||
navigator.geolocation.getCurrentPosition(function (position) { | ||
_this.apiService.updateProfile({ 'coords': [position.coords.latitude, position.coords.longitude] }); | ||
_this.apiService.updateDeviceProps({ 'coords': [position.coords.latitude, position.coords.longitude] }); | ||
_this.sendPermissionData(); | ||
@@ -202,3 +202,3 @@ }); | ||
if (Notification.permission !== 'default') { | ||
this.apiService.updateProfile({ 'pnPerm': Notification.permission }); | ||
this.apiService.updateDeviceProps({ 'pnPerm': Notification.permission }); | ||
return; | ||
@@ -268,3 +268,3 @@ } | ||
this.checkAllPermission().then(function (permissions) { | ||
_this.apiService.updateProfile({ 'perm': permissions }); | ||
_this.apiService.updateDeviceProps({ 'perm': permissions }); | ||
}); | ||
@@ -271,0 +271,0 @@ }; |
export var Permission; | ||
(function (Permission) { | ||
// eslint-disable-next-line no-unused-vars | ||
Permission["Location"] = "LOCATION"; | ||
Permission[Permission["CAMERA"] = 1] = "CAMERA"; | ||
// eslint-disable-next-line no-unused-vars | ||
Permission["Push"] = "PUSH"; | ||
Permission[Permission["LOCATION"] = 2] = "LOCATION"; | ||
// eslint-disable-next-line no-unused-vars | ||
Permission["Camera"] = "CAMERA"; | ||
Permission[Permission["PUSH"] = 6] = "PUSH"; | ||
})(Permission || (Permission = {})); |
var Transform = /** @class */ (function () { | ||
function Transform() { | ||
function Transform(data) { | ||
if (data === null || data === void 0 ? void 0 : data.rot) | ||
this.rot = data.rot; | ||
} | ||
@@ -4,0 +6,0 @@ Object.defineProperty(Transform.prototype, "rotate", { |
@@ -1,2 +0,2 @@ | ||
import { Background, Border } from '../blocks'; | ||
import { Background, Border, Transform } from '../blocks'; | ||
var BaseElement = /** @class */ (function () { | ||
@@ -9,6 +9,6 @@ function BaseElement(data) { | ||
this.br = new Border(data.br); | ||
this.trf = new Transform(data.trf); | ||
this.clc = data.clc; | ||
this.shd = data.shd; | ||
this.spc = data.spc; | ||
this.trf = data.trf; | ||
this.w = data.w; | ||
@@ -15,0 +15,0 @@ this.h = data.h; |
@@ -25,66 +25,4 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
Container.prototype.getStyles = function () { | ||
var styles; | ||
if (this.o === ContainerOrigin.NW) { | ||
styles = { | ||
top: 0, | ||
left: 0, | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.N) { | ||
styles = { | ||
top: 0, | ||
left: '50%', | ||
transform: 'translateX(-50%)', | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.NE) { | ||
styles = { | ||
top: 0, | ||
right: 0, | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.E) { | ||
styles = { | ||
top: '50%', | ||
right: 0, | ||
transform: 'translateY(-50%)', | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.SE) { | ||
styles = { | ||
bottom: 0, | ||
right: 0, | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.S) { | ||
styles = { | ||
bottom: 0, | ||
left: '50%', | ||
transform: 'translateX(-50%)', | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.SW) { | ||
styles = { | ||
bottom: 0, | ||
left: 0, | ||
}; | ||
} | ||
else if (this.o === ContainerOrigin.W) { | ||
styles = { | ||
top: '50%', | ||
left: 0, | ||
transform: 'translateY(-50%)', | ||
}; | ||
} | ||
else { | ||
styles = { | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translateX(-50%) translateY(-50%)', | ||
}; | ||
} | ||
styles.position = 'absolute'; | ||
styles.overflow = 'hidden'; | ||
return styles; | ||
Container.prototype.getOrigin = function () { | ||
return this.o; | ||
}; | ||
@@ -91,0 +29,0 @@ return Container; |
@@ -15,2 +15,3 @@ import { Container } from './container'; | ||
this.cont = new Container(data.cont); | ||
this.gvt = data.gvt; | ||
data.elems.forEach(function (rawElement) { | ||
@@ -31,4 +32,81 @@ if (rawElement.t === ElementType.IMAGE) { | ||
} | ||
InAppTrigger.prototype.getStyles = function () { | ||
var styles; | ||
if (this.gvt === ContainerOrigin.NW) { | ||
styles = { | ||
top: 0, | ||
left: 0, | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.N) { | ||
styles = { | ||
top: 0, | ||
left: '50%', | ||
transform: 'translateX(-50%)', | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.NE) { | ||
styles = { | ||
top: 0, | ||
right: 0, | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.E) { | ||
styles = { | ||
top: '50%', | ||
right: 0, | ||
transform: 'translateY(-50%)', | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.SE) { | ||
styles = { | ||
bottom: 0, | ||
right: 0, | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.S) { | ||
styles = { | ||
bottom: 0, | ||
left: '50%', | ||
transform: 'translateX(-50%)', | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.SW) { | ||
styles = { | ||
bottom: 0, | ||
left: 0, | ||
}; | ||
} | ||
else if (this.gvt === ContainerOrigin.W) { | ||
styles = { | ||
top: '50%', | ||
left: 0, | ||
transform: 'translateY(-50%)', | ||
}; | ||
} | ||
else { | ||
styles = { | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translateX(-50%) translateY(-50%)', | ||
}; | ||
} | ||
styles.position = 'absolute'; | ||
styles.overflow = 'hidden'; | ||
return styles; | ||
}; | ||
return InAppTrigger; | ||
}()); | ||
export { InAppTrigger }; | ||
export var ContainerOrigin; | ||
(function (ContainerOrigin) { | ||
ContainerOrigin[ContainerOrigin["NW"] = 1] = "NW"; | ||
ContainerOrigin[ContainerOrigin["N"] = 2] = "N"; | ||
ContainerOrigin[ContainerOrigin["NE"] = 3] = "NE"; | ||
ContainerOrigin[ContainerOrigin["W"] = 4] = "W"; | ||
ContainerOrigin[ContainerOrigin["C"] = 5] = "C"; | ||
ContainerOrigin[ContainerOrigin["E"] = 6] = "E"; | ||
ContainerOrigin[ContainerOrigin["SW"] = 7] = "SW"; | ||
ContainerOrigin[ContainerOrigin["S"] = 8] = "S"; | ||
ContainerOrigin[ContainerOrigin["SE"] = 9] = "SE"; | ||
})(ContainerOrigin || (ContainerOrigin = {})); |
import { Renderer } from './renderer'; | ||
import { ClickActionExecutor } from '../models/trigger/action/click-action-executor'; | ||
import { Transform } from '../models/trigger/blocks'; | ||
import { getScalingFactor } from './index'; | ||
@@ -65,10 +66,7 @@ import { Container } from '../models/trigger/inapp/container'; | ||
BlockProcessor.prototype.processPositionBlock = function () { | ||
if (!this.inappElement.x) { | ||
return; | ||
} | ||
this.renderer.setStyle(this.inappHTMLEl, 'position', 'absolute'); | ||
if (this.inappElement.x) | ||
this.renderer.setStyle(this.inappHTMLEl, 'left', this.getSizePx(this.inappElement.x)); | ||
if (this.inappElement.y) | ||
this.renderer.setStyle(this.inappHTMLEl, 'top', this.getSizePx(this.inappElement.y)); | ||
if (this.inappElement.y) | ||
this.renderer.setStyle(this.inappHTMLEl, 'left', this.getSizePx(this.inappElement.x)); | ||
}; | ||
@@ -124,3 +122,3 @@ /** | ||
BlockProcessor.prototype.processTransformBlock = function () { | ||
var transform = this.inappElement.trf; | ||
var transform = new Transform(this.inappElement.trf); | ||
if (!transform) { | ||
@@ -127,0 +125,0 @@ return; |
@@ -41,3 +41,2 @@ var __extends = (this && this.__extends) || (function () { | ||
this.renderer.setStyle(this.inappHTMLEl, 'position', 'relative'); | ||
Object.assign(this.inappHTMLEl.style, this.inappElement.getStyles()); | ||
return this; | ||
@@ -44,0 +43,0 @@ }; |
@@ -78,2 +78,7 @@ import { Log } from '../utils/log'; | ||
.getHTMLElement(); | ||
// Forward compatibility | ||
if (!this.ian.gvt) { | ||
this.ian.gvt = this.ian.cont.getOrigin(); | ||
} | ||
Object.assign(containerHTMLElement.style, this.ian.getStyles()); | ||
(_b = this.ian.elems) === null || _b === void 0 ? void 0 : _b.forEach(function (element) { | ||
@@ -80,0 +85,0 @@ _this.renderElement(containerHTMLElement, element); |
@@ -165,2 +165,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Create/Send device property call to the server. | ||
* | ||
* @param {Props} data device property. | ||
*/ | ||
HttpAPIService.prototype.updateDeviceProps = function (data) { | ||
var headers = this.getDefaultHeaders(); | ||
headers.append('x-sdk-token', this.apiToken); | ||
this.doHTTP('PUT', '/v1/device/update', data, headers) | ||
.then(function () { | ||
Log.log('Updated device property'); | ||
}) | ||
.catch(function (error) { | ||
Log.error('Error saving device property', error); | ||
}); | ||
}; | ||
/** | ||
* Send conclude session events. | ||
@@ -167,0 +183,0 @@ * |
@@ -44,3 +44,3 @@ import { SessionManager } from '../session/session-manager'; | ||
/** | ||
* Queue events till the sdk token is fetch for safe call. | ||
* Queue sending user data/property till the sdk token is fetch for safe call. | ||
* | ||
@@ -56,2 +56,13 @@ * @param {Props} data user data and property. | ||
/** | ||
* Queue sending device property till the sdk token is fetch for safe call. | ||
* | ||
* @param {Props} data device property. | ||
*/ | ||
SafeHttpService.prototype.updateDeviceProps = function (data) { | ||
var _this = this; | ||
NewSessionExecutor.replaySubject.subscribe(function () { | ||
_this.httpApiService.updateDeviceProps({ 'props': data }); | ||
}); | ||
}; | ||
/** | ||
* Safely send conclude session events. | ||
@@ -58,0 +69,0 @@ * |
{ | ||
"name": "@letscooee/web-sdk", | ||
"description": "Hyperpersonalised Mobile/Web App Re-Engagement via Machine Learning", | ||
"version": "0.0.9", | ||
"version": "0.0.12", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "lint": "eslint 'src/**'", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
304901
3599