@letscooee/web-sdk 0.0.2 → 0.0.6
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 +15 -1
- package/README.md +4 -2
- package/dist/constants.js +10 -2
- package/dist/index-preview.js +3 -0
- package/dist/init/object-meddler.js +3 -0
- package/dist/models/event/event-response.js +1 -0
- package/dist/models/trigger/action/click-action-executor.js +260 -0
- package/dist/models/trigger/blocks/background.js +33 -0
- package/dist/models/trigger/blocks/border.js +49 -0
- package/dist/models/trigger/blocks/click-action.js +9 -0
- package/dist/models/trigger/blocks/color.js +48 -0
- package/dist/models/trigger/blocks/colour.js +1 -0
- package/dist/models/trigger/blocks/flex.js +1 -0
- package/dist/models/trigger/blocks/font.js +1 -0
- package/dist/models/trigger/blocks/glossy.js +25 -0
- package/dist/models/trigger/blocks/gradient.js +1 -0
- package/dist/models/trigger/blocks/image.js +1 -0
- package/dist/models/trigger/blocks/index.js +5 -0
- package/dist/models/trigger/blocks/position.js +1 -0
- package/dist/models/trigger/blocks/shadow.js +1 -0
- package/dist/models/trigger/blocks/spacing.js +1 -0
- package/dist/models/trigger/blocks/transform.js +13 -0
- package/dist/models/trigger/elements/base-element.js +50 -0
- package/dist/models/trigger/elements/base-text-element.js +1 -0
- package/dist/models/trigger/elements/group-element.js +1 -0
- package/dist/models/trigger/elements/image-element.js +26 -0
- package/dist/models/trigger/elements/index.js +4 -0
- package/dist/models/trigger/elements/shape-element.js +24 -0
- package/dist/models/trigger/elements/text-element.js +81 -0
- package/dist/models/trigger/inapp/container.js +24 -0
- package/dist/models/trigger/inapp/in-app-trigger.js +32 -0
- package/dist/models/trigger/inapp/layer.js +1 -0
- package/dist/models/trigger/trigger-data.js +7 -1
- package/dist/renderer/base-text-renderer.js +77 -0
- package/dist/renderer/block-processor.js +234 -0
- package/dist/renderer/block-renderer.js +44 -0
- package/dist/renderer/container-renderer.js +45 -0
- package/dist/renderer/group-renderer.js +44 -0
- package/dist/renderer/iFrame-renderer.js +85 -0
- package/dist/renderer/image-renderer.js +44 -0
- package/dist/renderer/in-app-renderer.js +76 -0
- package/dist/renderer/index.js +22 -0
- package/dist/renderer/renderer.js +77 -0
- package/dist/renderer/root-container-renderer.js +46 -0
- package/dist/renderer/shape-renderer.js +39 -0
- package/dist/renderer/text-renderer.js +48 -0
- package/dist/sdk-preview.min.js +2 -0
- package/dist/sdk-preview.min.js.LICENSE.txt +8 -0
- package/dist/sdk.min.js +1 -1
- package/dist/services/http-api.service.js +5 -1
- package/dist/utils/log.js +14 -10
- package/dist/utils/runtime-data.js +0 -1
- package/package.json +5 -3
- package/webpack-preview.config.js +10 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { BaseElement } from './base-element';
|
|
17
|
+
var ShapeElement = /** @class */ (function (_super) {
|
|
18
|
+
__extends(ShapeElement, _super);
|
|
19
|
+
function ShapeElement(data) {
|
|
20
|
+
return _super.call(this, data) || this;
|
|
21
|
+
}
|
|
22
|
+
return ShapeElement;
|
|
23
|
+
}(BaseElement));
|
|
24
|
+
export { ShapeElement };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { Color } from '../blocks';
|
|
17
|
+
import { BaseElement } from './base-element';
|
|
18
|
+
var TextElement = /** @class */ (function (_super) {
|
|
19
|
+
__extends(TextElement, _super);
|
|
20
|
+
function TextElement(data) {
|
|
21
|
+
var _this = _super.call(this, data) || this;
|
|
22
|
+
_this.alg = TextAlign.START;
|
|
23
|
+
_this.prs = data.prs;
|
|
24
|
+
_this.alg = data.alg;
|
|
25
|
+
if (data.f)
|
|
26
|
+
_this.f = data.f;
|
|
27
|
+
if (data.c)
|
|
28
|
+
_this.c = new Color(data.c);
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(TextElement.prototype, "parts", {
|
|
32
|
+
get: function () {
|
|
33
|
+
return this.prs;
|
|
34
|
+
},
|
|
35
|
+
enumerable: false,
|
|
36
|
+
configurable: true
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(TextElement.prototype, "color", {
|
|
39
|
+
get: function () {
|
|
40
|
+
return this.c;
|
|
41
|
+
},
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(TextElement.prototype, "font", {
|
|
46
|
+
get: function () {
|
|
47
|
+
return this.f;
|
|
48
|
+
},
|
|
49
|
+
enumerable: false,
|
|
50
|
+
configurable: true
|
|
51
|
+
});
|
|
52
|
+
return TextElement;
|
|
53
|
+
}(BaseElement));
|
|
54
|
+
export { TextElement };
|
|
55
|
+
var TextPart = /** @class */ (function () {
|
|
56
|
+
function TextPart(data) {
|
|
57
|
+
this.txt = data.text;
|
|
58
|
+
this.b = data.b;
|
|
59
|
+
this.i = data.i;
|
|
60
|
+
this.u = data.u;
|
|
61
|
+
this.st = data.st;
|
|
62
|
+
this.sc = data.sc;
|
|
63
|
+
}
|
|
64
|
+
return TextPart;
|
|
65
|
+
}());
|
|
66
|
+
export { TextPart };
|
|
67
|
+
/* eslint-disable no-unused-vars */
|
|
68
|
+
export var TextAlign;
|
|
69
|
+
(function (TextAlign) {
|
|
70
|
+
TextAlign[TextAlign["START"] = 0] = "START";
|
|
71
|
+
TextAlign[TextAlign["CENTER"] = 1] = "CENTER";
|
|
72
|
+
TextAlign[TextAlign["END"] = 2] = "END";
|
|
73
|
+
TextAlign[TextAlign["JUSTIFY"] = 3] = "JUSTIFY";
|
|
74
|
+
})(TextAlign || (TextAlign = {}));
|
|
75
|
+
export var TextScript;
|
|
76
|
+
(function (TextScript) {
|
|
77
|
+
TextScript[TextScript["NORMAL"] = 0] = "NORMAL";
|
|
78
|
+
TextScript[TextScript["SUPER"] = 1] = "SUPER";
|
|
79
|
+
TextScript[TextScript["SUB"] = 2] = "SUB";
|
|
80
|
+
})(TextScript || (TextScript = {}));
|
|
81
|
+
/* eslint-enable no-unused-vars */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { BaseElement } from '../elements';
|
|
17
|
+
var Container = /** @class */ (function (_super) {
|
|
18
|
+
__extends(Container, _super);
|
|
19
|
+
function Container(data) {
|
|
20
|
+
return _super.call(this, data) || this;
|
|
21
|
+
}
|
|
22
|
+
return Container;
|
|
23
|
+
}(BaseElement));
|
|
24
|
+
export { Container };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Container } from './container';
|
|
2
|
+
import { ImageElement, ShapeElement, TextElement } from '../elements';
|
|
3
|
+
import { ElementType } from '../elements/base-element';
|
|
4
|
+
/**
|
|
5
|
+
* Stores data present in ian (In App) block in {@link TriggerData}
|
|
6
|
+
*
|
|
7
|
+
* @author Abhishek Taparia
|
|
8
|
+
* @version 0.0.5
|
|
9
|
+
*/
|
|
10
|
+
var InAppTrigger = /** @class */ (function () {
|
|
11
|
+
function InAppTrigger(data) {
|
|
12
|
+
var _this = this;
|
|
13
|
+
this.elems = [];
|
|
14
|
+
this.cont = new Container(data.cont);
|
|
15
|
+
data.elems.forEach(function (rawElement) {
|
|
16
|
+
if (rawElement.t === ElementType.IMAGE) {
|
|
17
|
+
_this.elems.push(new ImageElement(rawElement));
|
|
18
|
+
}
|
|
19
|
+
else if (rawElement.t === ElementType.TEXT) {
|
|
20
|
+
_this.elems.push(new TextElement(rawElement));
|
|
21
|
+
}
|
|
22
|
+
else if (rawElement.t === ElementType.BUTTON) {
|
|
23
|
+
_this.elems.push(new TextElement(rawElement));
|
|
24
|
+
}
|
|
25
|
+
else if (rawElement.t === ElementType.SHAPE) {
|
|
26
|
+
_this.elems.push(new ShapeElement(rawElement));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return InAppTrigger;
|
|
31
|
+
}());
|
|
32
|
+
export { InAppTrigger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InAppTrigger } from './inapp/in-app-trigger';
|
|
1
2
|
/**
|
|
2
3
|
* This store the payload sent by server to render trigger.
|
|
3
4
|
*/
|
|
@@ -5,12 +6,17 @@ var TriggerData = /** @class */ (function () {
|
|
|
5
6
|
/**
|
|
6
7
|
* Public constructor
|
|
7
8
|
*
|
|
8
|
-
* @param {
|
|
9
|
+
* @param {Props} data payload
|
|
9
10
|
*/
|
|
10
11
|
function TriggerData(data) {
|
|
11
12
|
this.duration = 0;
|
|
12
13
|
this.id = data.id;
|
|
13
14
|
this.duration = data.duration;
|
|
15
|
+
this.version = data.version;
|
|
16
|
+
this.engagementID = data.engagementID;
|
|
17
|
+
this.internal = data.internal;
|
|
18
|
+
this.pn = data.pn;
|
|
19
|
+
this.ian = new InAppTrigger(data.ian);
|
|
14
20
|
}
|
|
15
21
|
return TriggerData;
|
|
16
22
|
}());
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { BlockProcessor } from './block-processor';
|
|
17
|
+
import { TextAlign } from '../models/trigger/elements/text-element';
|
|
18
|
+
/**
|
|
19
|
+
* Base class for rendering any text extending block from in-app.
|
|
20
|
+
*
|
|
21
|
+
* @author Abhishek Taparia
|
|
22
|
+
* @version 0.0.5
|
|
23
|
+
*/
|
|
24
|
+
var BaseTextRenderer = /** @class */ (function (_super) {
|
|
25
|
+
__extends(BaseTextRenderer, _super);
|
|
26
|
+
function BaseTextRenderer(parentElement, inappElement) {
|
|
27
|
+
return _super.call(this, parentElement, inappElement) || this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Process all the common block in in-app.
|
|
31
|
+
*/
|
|
32
|
+
BaseTextRenderer.prototype.processCommonBlocks = function () {
|
|
33
|
+
_super.prototype.processCommonBlocks.call(this);
|
|
34
|
+
this.processFontBlock();
|
|
35
|
+
this.processColourBlock(this.inappElement.color);
|
|
36
|
+
this.processAlignment();
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Process font block of the element
|
|
40
|
+
*/
|
|
41
|
+
BaseTextRenderer.prototype.processFontBlock = function () {
|
|
42
|
+
var font = this.inappElement.font;
|
|
43
|
+
if (!font) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.renderer.setStyle(this.inappHTMLEl, 'font-size', this.getSizePx(font.s));
|
|
47
|
+
this.renderer.setStyle(this.inappHTMLEl, 'font-family', font.ff);
|
|
48
|
+
this.renderer.setStyle(this.inappHTMLEl, 'line-height', font.lh);
|
|
49
|
+
};
|
|
50
|
+
BaseTextRenderer.prototype.processPart = function (partHTMLEl, part) {
|
|
51
|
+
var _a;
|
|
52
|
+
var decoration = [];
|
|
53
|
+
if (part.u)
|
|
54
|
+
decoration.push('underline');
|
|
55
|
+
if (part.st)
|
|
56
|
+
decoration.push('line-through');
|
|
57
|
+
if (!decoration.length)
|
|
58
|
+
decoration.push('normal');
|
|
59
|
+
this.renderer.setStyle(partHTMLEl, 'font-weight', part.b ? 'bold' : 'normal');
|
|
60
|
+
this.renderer.setStyle(partHTMLEl, 'font-style', part.i ? 'italic' : 'normal');
|
|
61
|
+
this.renderer.setStyle(partHTMLEl, 'text-decoration', decoration.join(' '));
|
|
62
|
+
this.renderer.setStyle(partHTMLEl, 'color', (_a = part.c) !== null && _a !== void 0 ? _a : 'inherit');
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Process text alignment block of the element
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
BaseTextRenderer.prototype.processAlignment = function () {
|
|
69
|
+
var _a;
|
|
70
|
+
var value = (_a = TextAlign[this.inappElement.alg]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
71
|
+
if (!value)
|
|
72
|
+
value = 'start';
|
|
73
|
+
this.renderer.setStyle(this.inappHTMLEl, 'text-align', value);
|
|
74
|
+
};
|
|
75
|
+
return BaseTextRenderer;
|
|
76
|
+
}(BlockProcessor));
|
|
77
|
+
export { BaseTextRenderer };
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Renderer } from './renderer';
|
|
2
|
+
import UAParser from 'ua-parser-js';
|
|
3
|
+
import { ClickActionExecutor } from '../models/trigger/action/click-action-executor';
|
|
4
|
+
import { getScalingFactor } from './index';
|
|
5
|
+
import { Container } from '../models/trigger/inapp/container';
|
|
6
|
+
/**
|
|
7
|
+
* Process all the block of in-app
|
|
8
|
+
*
|
|
9
|
+
* @author Abhishek Taparia
|
|
10
|
+
* @version 0.0.5
|
|
11
|
+
*/
|
|
12
|
+
var BlockProcessor = /** @class */ (function () {
|
|
13
|
+
function BlockProcessor(parentHTMLEl, inappElement) {
|
|
14
|
+
this.screenWidth = 0;
|
|
15
|
+
this.screenHeight = 0;
|
|
16
|
+
this.scalingFactor = getScalingFactor();
|
|
17
|
+
this.parentHTMLEl = parentHTMLEl;
|
|
18
|
+
this.inappElement = inappElement;
|
|
19
|
+
this.renderer = new Renderer();
|
|
20
|
+
this.screenWidth = this.renderer.getWidth();
|
|
21
|
+
this.screenHeight = this.renderer.getHeight();
|
|
22
|
+
}
|
|
23
|
+
BlockProcessor.prototype.getHTMLElement = function () {
|
|
24
|
+
return this.inappHTMLEl;
|
|
25
|
+
};
|
|
26
|
+
BlockProcessor.prototype.insertElement = function () {
|
|
27
|
+
this.renderer.appendChild(this.parentHTMLEl, this.inappHTMLEl);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Process all the common blocks that can be placed in layer and container
|
|
31
|
+
*/
|
|
32
|
+
BlockProcessor.prototype.processCommonBlocks = function () {
|
|
33
|
+
this.processWidthAndHeight();
|
|
34
|
+
this.processPositionBlock();
|
|
35
|
+
this.processBorderBlock();
|
|
36
|
+
this.processBackgroundBlock();
|
|
37
|
+
this.processSpaceBlock();
|
|
38
|
+
this.processTransformBlock();
|
|
39
|
+
this.registerAction();
|
|
40
|
+
this.renderer.setStyle(this.inappHTMLEl, 'overflow', 'visible');
|
|
41
|
+
this.renderer.setStyle(this.inappHTMLEl, 'outline', 'none');
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Process width and height
|
|
45
|
+
*/
|
|
46
|
+
BlockProcessor.prototype.processWidthAndHeight = function () {
|
|
47
|
+
this.renderer.setStyle(this.inappHTMLEl, 'box-sizing', 'border-box');
|
|
48
|
+
if (this.inappElement.w) {
|
|
49
|
+
this.renderer.setStyle(this.inappHTMLEl, 'width', this.getSizePx(this.inappElement.w));
|
|
50
|
+
}
|
|
51
|
+
if (this.inappElement.h) {
|
|
52
|
+
this.renderer.setStyle(this.inappHTMLEl, 'height', this.getSizePx(this.inappElement.h));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Get calculated size according to the device by multiplying it with scaling factor.
|
|
57
|
+
* @param {number} value size passed in payload
|
|
58
|
+
* @return number calculated size
|
|
59
|
+
*/
|
|
60
|
+
BlockProcessor.prototype.getSizePx = function (value) {
|
|
61
|
+
return (value * this.scalingFactor) + 'px';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Process position block of the element
|
|
65
|
+
*/
|
|
66
|
+
BlockProcessor.prototype.processPositionBlock = function () {
|
|
67
|
+
if (!this.inappElement.x) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.renderer.setStyle(this.inappHTMLEl, 'position', 'absolute');
|
|
71
|
+
if (this.inappElement.x)
|
|
72
|
+
this.renderer.setStyle(this.inappHTMLEl, 'top', this.getSizePx(this.inappElement.y));
|
|
73
|
+
if (this.inappElement.y)
|
|
74
|
+
this.renderer.setStyle(this.inappHTMLEl, 'left', this.getSizePx(this.inappElement.x));
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Process border block of the element
|
|
78
|
+
*/
|
|
79
|
+
BlockProcessor.prototype.processBorderBlock = function () {
|
|
80
|
+
var _a;
|
|
81
|
+
var border = this.inappElement.br;
|
|
82
|
+
if (!border) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Just to make sure radius is not a negative number
|
|
86
|
+
if (border.radius && border.radius > 0) {
|
|
87
|
+
this.renderer.setStyle(this.inappHTMLEl, 'border-radius', this.getSizePx(border.radius));
|
|
88
|
+
}
|
|
89
|
+
// Just to make sure width is not a negative number
|
|
90
|
+
if (border.width && border.width > 0) {
|
|
91
|
+
this.renderer.setStyle(this.inappHTMLEl, 'border-width', this.getSizePx(border.width));
|
|
92
|
+
this.renderer.setStyle(this.inappHTMLEl, 'border-style', (_a = border.style) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
93
|
+
if (border.color) {
|
|
94
|
+
this.processColourBlock(border.color, 'border-color');
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
this.renderer.setStyle(this.inappHTMLEl, 'border-color', 'black');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Process space block of the element which include margin and padding.
|
|
103
|
+
*/
|
|
104
|
+
BlockProcessor.prototype.processSpaceBlock = function () {
|
|
105
|
+
var space = this.inappElement.spc;
|
|
106
|
+
if (!space) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (space.p)
|
|
110
|
+
this.renderer.setStyle(this.inappHTMLEl, 'padding', this.getSizePx(space.p));
|
|
111
|
+
if (space.pt)
|
|
112
|
+
this.renderer.setStyle(this.inappHTMLEl, 'padding-top', this.getSizePx(space.pt));
|
|
113
|
+
if (space.pb)
|
|
114
|
+
this.renderer.setStyle(this.inappHTMLEl, 'padding-bottom', this.getSizePx(space.pb));
|
|
115
|
+
if (space.pl)
|
|
116
|
+
this.renderer.setStyle(this.inappHTMLEl, 'padding-left', this.getSizePx(space.pl));
|
|
117
|
+
if (space.pr)
|
|
118
|
+
this.renderer.setStyle(this.inappHTMLEl, 'padding-right', this.getSizePx(space.pr));
|
|
119
|
+
this.renderer.setStyle(this.inappHTMLEl, 'margin', '0 !important');
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Process transform block of the element
|
|
123
|
+
*/
|
|
124
|
+
BlockProcessor.prototype.processTransformBlock = function () {
|
|
125
|
+
var transform = this.inappElement.trf;
|
|
126
|
+
if (!transform) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (transform.rotate) {
|
|
130
|
+
this.renderer.setStyle(this.inappHTMLEl, 'transform', "rotate(" + transform.rotate + "deg)");
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Register click-to-action(CTA) block of the element
|
|
135
|
+
*/
|
|
136
|
+
BlockProcessor.prototype.registerAction = function () {
|
|
137
|
+
var action = this.inappElement.clc;
|
|
138
|
+
if (!action) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.inappHTMLEl.addEventListener('click', function () {
|
|
142
|
+
new ClickActionExecutor(action).execute();
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Process background block of the element
|
|
147
|
+
*/
|
|
148
|
+
BlockProcessor.prototype.processBackgroundBlock = function () {
|
|
149
|
+
var _a;
|
|
150
|
+
var bg = this.inappElement.bg;
|
|
151
|
+
if (!bg) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
var htmlElement = this.inappHTMLEl;
|
|
155
|
+
// For container, the background must be applied to its parent i.e. root container
|
|
156
|
+
if (this.inappElement instanceof Container) {
|
|
157
|
+
htmlElement = htmlElement.parentElement;
|
|
158
|
+
}
|
|
159
|
+
var prefix = '';
|
|
160
|
+
if ((_a = new UAParser().getBrowser().name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('safari')) {
|
|
161
|
+
prefix = '-webkit-';
|
|
162
|
+
}
|
|
163
|
+
if (bg.glossy) {
|
|
164
|
+
this.renderer.setStyle(htmlElement, prefix + 'backdrop-filter', "blur(" + bg.glossy.radius + "px)");
|
|
165
|
+
if (bg.glossy.color) {
|
|
166
|
+
this.processColourBlock(bg.glossy.color, 'background', htmlElement);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (bg.solid) {
|
|
170
|
+
if (bg.solid.grad) {
|
|
171
|
+
this.processGradient(bg.solid.grad, 'background');
|
|
172
|
+
}
|
|
173
|
+
else if (bg.solid.hex) {
|
|
174
|
+
this.renderer.setStyle(htmlElement, 'background', bg.solid.rgba);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (bg.img) {
|
|
178
|
+
if (!bg.img.src) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
var value = "url(\"" + bg.img.src + "\") no-repeat center";
|
|
182
|
+
this.renderer.setStyle(htmlElement, 'background', value);
|
|
183
|
+
this.renderer.setStyle(htmlElement, 'background-size', 'cover');
|
|
184
|
+
if (bg.img.a) {
|
|
185
|
+
this.renderer.setStyle(htmlElement, prefix + 'backdrop-filter', "opacity(" + bg.img.a + ")");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Process linear gradient and add to the element
|
|
191
|
+
* @param {Gradient} grad gradient value
|
|
192
|
+
* @param {string} attribute attribute on which gradient needs to be applied
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
BlockProcessor.prototype.processGradient = function (grad, attribute) {
|
|
196
|
+
if (grad.type === 'LINEAR') {
|
|
197
|
+
var linearFunctionString = "linear-gradient(" + grad.ang + "deg, " + grad.c1 + ", " + grad.c2;
|
|
198
|
+
if (grad.c3) {
|
|
199
|
+
linearFunctionString += ", " + grad.c3;
|
|
200
|
+
}
|
|
201
|
+
if (grad.c4) {
|
|
202
|
+
linearFunctionString += ", " + grad.c4;
|
|
203
|
+
}
|
|
204
|
+
if (grad.c5) {
|
|
205
|
+
linearFunctionString += ", " + grad.c5;
|
|
206
|
+
}
|
|
207
|
+
linearFunctionString += ")";
|
|
208
|
+
var gradient = linearFunctionString;
|
|
209
|
+
this.renderer.setStyle(this.inappHTMLEl, attribute, gradient);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Process colour block of the element
|
|
214
|
+
* @param {Color} colour colour data of the element
|
|
215
|
+
* @param {string} attribute attribute on which colour data need to be applied
|
|
216
|
+
* @param {HTMLElement} element Any other element to apply the color apart from {@link inappHTMLEl}
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
BlockProcessor.prototype.processColourBlock = function (colour, attribute, element) {
|
|
220
|
+
if (attribute === void 0) { attribute = 'color'; }
|
|
221
|
+
if (element === void 0) { element = this.inappHTMLEl; }
|
|
222
|
+
if (!colour) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (colour.grad) {
|
|
226
|
+
this.processGradient(colour.grad, attribute);
|
|
227
|
+
}
|
|
228
|
+
else if (colour.hex) {
|
|
229
|
+
this.renderer.setStyle(element, attribute, colour.rgba);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
return BlockProcessor;
|
|
233
|
+
}());
|
|
234
|
+
export { BlockProcessor };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { BlockProcessor } from './block-processor';
|
|
17
|
+
/**
|
|
18
|
+
* Base class for rendering any block from in-app.
|
|
19
|
+
*
|
|
20
|
+
* @author Abhishek Taparia
|
|
21
|
+
* @version 0.0.5
|
|
22
|
+
*/
|
|
23
|
+
var BlockRenderer = /** @class */ (function (_super) {
|
|
24
|
+
__extends(BlockRenderer, _super);
|
|
25
|
+
/**
|
|
26
|
+
* Public constructor
|
|
27
|
+
*/
|
|
28
|
+
function BlockRenderer() {
|
|
29
|
+
return _super.call(this) || this;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Process all the common block in in-app.
|
|
33
|
+
* @param {HTMLElement} element element to be processed
|
|
34
|
+
* @param {BaseElement} baseElement style and attributes data of the element
|
|
35
|
+
*/
|
|
36
|
+
BlockRenderer.prototype.commonRenderingFunction = function (element, baseElement) {
|
|
37
|
+
this.processCommonBlocks(element, baseElement);
|
|
38
|
+
if (baseElement.type) {
|
|
39
|
+
element.classList.add(baseElement.type);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return BlockRenderer;
|
|
43
|
+
}(BlockProcessor));
|
|
44
|
+
export { BlockRenderer };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { ShapeRenderer } from './shape-renderer';
|
|
17
|
+
/**
|
|
18
|
+
* Renders container element.
|
|
19
|
+
*
|
|
20
|
+
* @author Shashank Agrawal
|
|
21
|
+
* @version 0.0.5
|
|
22
|
+
*/
|
|
23
|
+
var ContainerRenderer = /** @class */ (function (_super) {
|
|
24
|
+
__extends(ContainerRenderer, _super);
|
|
25
|
+
function ContainerRenderer(parentElement, inappElement) {
|
|
26
|
+
var _this = _super.call(this, parentElement, inappElement) || this;
|
|
27
|
+
// Need to figure out the best way of doing this
|
|
28
|
+
_this.inappElement.w = 1080;
|
|
29
|
+
_this.inappElement.h = 1920;
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Render group element from layers list in {@link InAppTrigger} block.
|
|
34
|
+
* @return The instance of this renderer.
|
|
35
|
+
*/
|
|
36
|
+
ContainerRenderer.prototype.render = function () {
|
|
37
|
+
_super.prototype.render.call(this);
|
|
38
|
+
this.renderer.setStyle(this.inappHTMLEl, 'position', 'relative');
|
|
39
|
+
/* this.renderer.setStyle(this.inappHTMLEl, 'width', '100%');
|
|
40
|
+
this.renderer.setStyle(this.inappHTMLEl, 'height', '100%'); */
|
|
41
|
+
return this;
|
|
42
|
+
};
|
|
43
|
+
return ContainerRenderer;
|
|
44
|
+
}(ShapeRenderer));
|
|
45
|
+
export { ContainerRenderer };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { BlockRenderer } from './block-renderer';
|
|
17
|
+
/**
|
|
18
|
+
* Renders group element present in in-app layer block.
|
|
19
|
+
*
|
|
20
|
+
* @author Abhishek Taparia
|
|
21
|
+
* @version 0.0.5
|
|
22
|
+
*/
|
|
23
|
+
var GroupRenderer = /** @class */ (function (_super) {
|
|
24
|
+
__extends(GroupRenderer, _super);
|
|
25
|
+
function GroupRenderer() {
|
|
26
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Render group element from layers list in {@link InAppTrigger} block.
|
|
30
|
+
* @param {HTMLElement} parent
|
|
31
|
+
* @param {GroupElement} elementData style and attributes data of the group element
|
|
32
|
+
* @return {HTMLElement} rendered group element
|
|
33
|
+
*/
|
|
34
|
+
GroupRenderer.prototype.render = function (parent, elementData) {
|
|
35
|
+
var newElement = this.renderer.createElement('div');
|
|
36
|
+
// By default the parents will be relative
|
|
37
|
+
this.renderer.setStyle(newElement, 'position', 'relative');
|
|
38
|
+
this.commonRenderingFunction(newElement, elementData);
|
|
39
|
+
this.renderer.appendChild(parent, newElement);
|
|
40
|
+
return newElement;
|
|
41
|
+
};
|
|
42
|
+
return GroupRenderer;
|
|
43
|
+
}(BlockRenderer));
|
|
44
|
+
export { GroupRenderer };
|