@letscooee/web-sdk 0.0.7 → 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 CHANGED
@@ -1,23 +1,52 @@
1
1
  # Change Log
2
2
 
3
- # 0.0.7
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
20
+
21
+ 1. Fix: glassmorphism on iOS.
22
+ 2. Fix: Fix rendering scaled images.
23
+ 3. Fix: Update in KPI for CTA.
24
+ 4. Fix: Do not remove in-app if being used inside an element.
25
+
26
+ ## 0.0.8
27
+
28
+ 1. Feature: Ability of InApp to be rendered inside an element.
29
+ 2. Fix: Overflowed content should not be rendered.
30
+ 3. Fix: Placing in-app on east direction.
31
+
32
+ ## 0.0.7
4
33
 
5
34
  More feature support in the sdk.
6
35
 
7
- # 0.0.6
36
+ ## 0.0.6
8
37
 
9
38
  1. Build: Upgrade TypeScript to 4.4.
10
39
  2. Fix: Convert \n to `<br>` in texts.
11
40
 
12
- # 0.0.5
41
+ ## 0.0.5
13
42
 
14
43
  Supporting changes based on the in-app composer.
15
44
 
16
- # 0.0.3, 0.0.4
45
+ ## 0.0.3, 0.0.4
17
46
 
18
47
  1. Fix generating token because of missing app version.
19
48
  2. Handle scenario when `CooeeSDK` is not initialised.
20
49
 
21
- # 0.0.2
50
+ ## 0.0.2
22
51
 
23
52
  First functional release.
package/README.md CHANGED
@@ -27,11 +27,11 @@ code before calling any other CooeeSDK functions.
27
27
  <script src="https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@latest/dist/sdk.min.js" async></script>
28
28
  <script>
29
29
  window.CooeeSDK = window.CooeeSDK || {events: [], profile: [], account: []};
30
- CooeeSDK.account.push({"appID": "MY_COOEE_APP_ID", "appSecret": "MY_COOEE_APP_SECRET"});
30
+ CooeeSDK.account.push({"appID": "MY_COOEE_APP_ID"});
31
31
  </script>
32
32
  ```
33
33
 
34
- Replace `MY_COOEE_APP_ID` & `MY_COOEE_APP_SECRET` with the app id & secret given to you.
34
+ Replace `MY_COOEE_APP_ID` with the app id as seen in your Cooee dashboard.
35
35
 
36
36
  #### Step 2: Track Custom Events
37
37
 
@@ -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.prompt;
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.Location) {
113
+ if (permission === Permission.LOCATION) {
114
114
  this.promptLocationPermission();
115
115
  }
116
- if (permission === Permission.Push) {
116
+ if (permission === Permission.PUSH) {
117
117
  this.promptPushNotificationPermission();
118
118
  }
119
- if (permission === Permission.Camera) {
119
+ if (permission === Permission.CAMERA) {
120
120
  this.promptCameraPermission();
121
121
  }
122
122
  };
@@ -132,10 +132,18 @@ var ClickActionExecutor = /** @class */ (function () {
132
132
  var startTime = LocalStorageHelper.getNumber(Constants.STORAGE_TRIGGER_START_TIME, new Date().getTime());
133
133
  var triggerID = (_a = LocalStorageHelper.getObject(Constants.STORAGE_ACTIVE_TRIGGER)) === null || _a === void 0 ? void 0 : _a.triggerID;
134
134
  var diffInSeconds = (new Date().getTime() - startTime) / 1000;
135
+ var closeBehaviour;
136
+ if (this.action.ext || this.action.up || this.action.kv ||
137
+ this.action.iab || this.action.pmpt || this.action.share) {
138
+ closeBehaviour = 'CTA';
139
+ }
140
+ else {
141
+ closeBehaviour = 'Close';
142
+ }
135
143
  var eventProps = {
136
144
  'triggerID': triggerID,
137
- 'Close Behaviour': 'CTA',
138
- 'Duration': diffInSeconds,
145
+ 'closeBehaviour': closeBehaviour,
146
+ 'duration': diffInSeconds,
139
147
  };
140
148
  this.apiService.sendEvent(new Event('CE Trigger Closed', eventProps));
141
149
  LocalStorageHelper.remove(Constants.STORAGE_TRIGGER_START_TIME);
@@ -171,7 +179,7 @@ var ClickActionExecutor = /** @class */ (function () {
171
179
  }
172
180
  // TODO Need device endpoints to update this property
173
181
  navigator.geolocation.getCurrentPosition(function (position) {
174
- _this.apiService.updateProfile({ 'coords': [position.coords.latitude, position.coords.longitude] });
182
+ _this.apiService.updateDeviceProps({ 'coords': [position.coords.latitude, position.coords.longitude] });
175
183
  _this.sendPermissionData();
176
184
  });
177
185
  };
@@ -187,7 +195,7 @@ var ClickActionExecutor = /** @class */ (function () {
187
195
  }
188
196
  // TODO Need device endpoints to update this property
189
197
  if (Notification.permission !== 'default') {
190
- this.apiService.updateProfile({ 'pnPerm': Notification.permission });
198
+ this.apiService.updateDeviceProps({ 'pnPerm': Notification.permission });
191
199
  return;
192
200
  }
193
201
  Notification.requestPermission()
@@ -252,7 +260,7 @@ var ClickActionExecutor = /** @class */ (function () {
252
260
  ClickActionExecutor.prototype.sendPermissionData = function () {
253
261
  var _this = this;
254
262
  this.checkAllPermission().then(function (permissions) {
255
- _this.apiService.updateProfile({ 'perm': permissions });
263
+ _this.apiService.updateDeviceProps({ 'perm': permissions });
256
264
  });
257
265
  };
258
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["Location"] = "LOCATION";
4
+ Permission[Permission["CAMERA"] = 1] = "CAMERA";
5
5
  // eslint-disable-next-line no-unused-vars
6
- Permission["Push"] = "PUSH";
6
+ Permission[Permission["LOCATION"] = 2] = "LOCATION";
7
7
  // eslint-disable-next-line no-unused-vars
8
- Permission["Camera"] = "CAMERA";
8
+ Permission[Permission["PUSH"] = 6] = "PUSH";
9
9
  })(Permission || (Permission = {}));
@@ -1,5 +1,7 @@
1
1
  var Transform = /** @class */ (function () {
2
- function Transform() {
2
+ function Transform(data) {
3
+ if (data === null || data === void 0 ? void 0 : data.rot)
4
+ this.rot = data.rot;
3
5
  }
4
6
  Object.defineProperty(Transform.prototype, "rotate", {
5
7
  get: function () {
@@ -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,69 +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.getStyles = function () {
26
- var styles;
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
- left: 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
- return styles;
25
+ Container.prototype.getOrigin = function () {
26
+ return this.o;
88
27
  };
89
28
  return Container;
90
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 = {}));
@@ -15,6 +15,9 @@ var TriggerHelper = /** @class */ (function () {
15
15
  * @param triggerData trigger data
16
16
  */
17
17
  TriggerHelper.storeActiveTrigger = function (triggerData) {
18
+ if (triggerData.id === 'test') {
19
+ return;
20
+ }
18
21
  var activeTriggers = LocalStorageHelper.getObject(Constants.STORAGE_ACTIVE_TRIGGERS);
19
22
  if (!activeTriggers) {
20
23
  activeTriggers = [];
@@ -1,6 +1,6 @@
1
1
  import { Renderer } from './renderer';
2
- import UAParser from 'ua-parser-js';
3
2
  import { ClickActionExecutor } from '../models/trigger/action/click-action-executor';
3
+ import { Transform } from '../models/trigger/blocks';
4
4
  import { getScalingFactor } from './index';
5
5
  import { Container } from '../models/trigger/inapp/container';
6
6
  /**
@@ -11,12 +11,12 @@ import { Container } from '../models/trigger/inapp/container';
11
11
  */
12
12
  var BlockProcessor = /** @class */ (function () {
13
13
  function BlockProcessor(parentHTMLEl, inappElement) {
14
+ this.renderer = Renderer.get();
14
15
  this.screenWidth = 0;
15
16
  this.screenHeight = 0;
16
17
  this.scalingFactor = getScalingFactor();
17
18
  this.parentHTMLEl = parentHTMLEl;
18
19
  this.inappElement = inappElement;
19
- this.renderer = new Renderer();
20
20
  this.screenWidth = this.renderer.getWidth();
21
21
  this.screenHeight = this.renderer.getHeight();
22
22
  }
@@ -37,7 +37,6 @@ var BlockProcessor = /** @class */ (function () {
37
37
  this.processSpaceBlock();
38
38
  this.processTransformBlock();
39
39
  this.registerAction();
40
- this.renderer.setStyle(this.inappHTMLEl, 'overflow', 'visible');
41
40
  this.renderer.setStyle(this.inappHTMLEl, 'outline', 'none');
42
41
  };
43
42
  /**
@@ -64,14 +63,11 @@ var BlockProcessor = /** @class */ (function () {
64
63
  * Process position block of the element
65
64
  */
66
65
  BlockProcessor.prototype.processPositionBlock = function () {
67
- if (!this.inappElement.x) {
68
- return;
69
- }
70
66
  this.renderer.setStyle(this.inappHTMLEl, 'position', 'absolute');
71
67
  if (this.inappElement.x)
72
- this.renderer.setStyle(this.inappHTMLEl, 'top', this.getSizePx(this.inappElement.y));
73
- if (this.inappElement.y)
74
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));
75
71
  };
76
72
  /**
77
73
  * Process border block of the element
@@ -122,7 +118,7 @@ var BlockProcessor = /** @class */ (function () {
122
118
  * Process transform block of the element
123
119
  */
124
120
  BlockProcessor.prototype.processTransformBlock = function () {
125
- var transform = this.inappElement.trf;
121
+ var transform = new Transform(this.inappElement.trf);
126
122
  if (!transform) {
127
123
  return;
128
124
  }
@@ -138,7 +134,8 @@ var BlockProcessor = /** @class */ (function () {
138
134
  if (!action) {
139
135
  return;
140
136
  }
141
- this.inappHTMLEl.addEventListener('click', function () {
137
+ this.inappHTMLEl.addEventListener('click', function (event) {
138
+ event.stopPropagation();
142
139
  new ClickActionExecutor(action).execute();
143
140
  });
144
141
  };
@@ -146,7 +143,6 @@ var BlockProcessor = /** @class */ (function () {
146
143
  * Process background block of the element
147
144
  */
148
145
  BlockProcessor.prototype.processBackgroundBlock = function () {
149
- var _a;
150
146
  var bg = this.inappElement.bg;
151
147
  if (!bg) {
152
148
  return;
@@ -156,12 +152,11 @@ var BlockProcessor = /** @class */ (function () {
156
152
  if (this.inappElement instanceof Container) {
157
153
  htmlElement = htmlElement.parentElement;
158
154
  }
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
155
  if (bg.glossy) {
164
- this.renderer.setStyle(htmlElement, prefix + 'backdrop-filter', "blur(" + bg.glossy.radius + "px)");
156
+ // Style for Apple devices
157
+ this.renderer.setStyle(htmlElement, '-webkit-backdrop-filter', "blur(" + bg.glossy.radius + "px)");
158
+ // Style for other devices
159
+ this.renderer.setStyle(htmlElement, 'backdrop-filter', "blur(" + bg.glossy.radius + "px)");
165
160
  if (bg.glossy.color) {
166
161
  this.processColourBlock(bg.glossy.color, 'background', htmlElement);
167
162
  }
@@ -182,7 +177,10 @@ var BlockProcessor = /** @class */ (function () {
182
177
  this.renderer.setStyle(htmlElement, 'background', value);
183
178
  this.renderer.setStyle(htmlElement, 'background-size', 'cover');
184
179
  if (bg.img.a) {
185
- this.renderer.setStyle(htmlElement, prefix + 'backdrop-filter', "opacity(" + bg.img.a + ")");
180
+ // Style for Apple devices
181
+ this.renderer.setStyle(htmlElement, '-webkit-backdrop-filter', "opacity(" + bg.img.a + ")");
182
+ // Style for other devices
183
+ this.renderer.setStyle(htmlElement, 'backdrop-filter', "opacity(" + bg.img.a + ")");
186
184
  }
187
185
  }
188
186
  };
@@ -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;
@@ -7,11 +7,8 @@ import { Constants } from '../constants';
7
7
  * @version 0.0.5
8
8
  */
9
9
  var IFrameRenderer = /** @class */ (function () {
10
- /**
11
- * Constructor
12
- */
13
10
  function IFrameRenderer() {
14
- this.renderer = new Renderer();
11
+ this.renderer = Renderer.get();
15
12
  }
16
13
  /**
17
14
  * Render iFrame element on CTAs.
@@ -20,7 +17,7 @@ var IFrameRenderer = /** @class */ (function () {
20
17
  * @private
21
18
  */
22
19
  IFrameRenderer.prototype.render = function (url) {
23
- var root = this.renderer.getElementById(Constants.IN_APP_CONTAINER_NAME);
20
+ var root = document.querySelector("." + Constants.IN_APP_CONTAINER_NAME);
24
21
  var iFrameDiv = this.createIFrameContainer();
25
22
  this.createIFrameElement(iFrameDiv, url);
26
23
  // Create and render close button for iFrame with anchor tag
@@ -33,8 +33,8 @@ var ImageRenderer = /** @class */ (function (_super) {
33
33
  */
34
34
  ImageRenderer.prototype.render = function () {
35
35
  this.renderer.setAttribute(this.inappHTMLEl, 'src', this.inappElement.src);
36
- this.renderer.setStyle(this.inappHTMLEl, 'max-width', '100%');
37
- this.renderer.setStyle(this.inappHTMLEl, 'max-height', '100%');
36
+ this.renderer.setStyle(this.inappHTMLEl, 'max-width', 'none');
37
+ this.renderer.setStyle(this.inappHTMLEl, 'max-height', 'none');
38
38
  this.renderer.setStyle(this.inappHTMLEl, 'display', 'block');
39
39
  this.renderer.setStyle(this.inappHTMLEl, 'margin', '0 auto');
40
40
  this.processCommonBlocks();
@@ -16,10 +16,13 @@ import { Event } from '../models/event/event';
16
16
  */
17
17
  var InAppRenderer = /** @class */ (function () {
18
18
  /**
19
- * Public constructor
19
+ * Public constructor.
20
+ *
21
+ * @param parent Place the in-app in the given parent instead of the document.body.
20
22
  */
21
- function InAppRenderer() {
22
- this.rootContainer = new RootContainerRenderer().render();
23
+ function InAppRenderer(parent) {
24
+ this.parent = parent;
25
+ this.rootContainer = new RootContainerRenderer(parent).render();
23
26
  }
24
27
  /**
25
28
  * Renders in-app trigger from payload received
@@ -72,6 +75,11 @@ var InAppRenderer = /** @class */ (function () {
72
75
  var containerHTMLElement = new ContainerRenderer(this.rootContainer, container)
73
76
  .render()
74
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());
75
83
  (_b = this.ian.elems) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
76
84
  _this.renderElement(containerHTMLElement, element);
77
85
  });
@@ -1,16 +1,17 @@
1
1
  import { Constants } from '../constants';
2
+ import { Renderer } from './renderer';
2
3
  export { TextRenderer } from './text-renderer';
3
4
  export { ShapeRenderer } from './shape-renderer';
4
5
  export { ImageRenderer } from './image-renderer';
5
6
  export { RootContainerRenderer } from './root-container-renderer';
6
7
  export { IFrameRenderer } from './iFrame-renderer';
7
8
  /**
8
- * Calculate scaling factor according to screen sizes
9
+ * Calculate scaling factor according to parent most container where the in-app's root container will be rendered.
9
10
  * @return number scaling factor
10
11
  */
11
12
  export function getScalingFactor() {
12
- var screenWidth = document.documentElement.clientWidth;
13
- var screenHeight = document.documentElement.clientHeight;
13
+ var screenWidth = Renderer.get().getWidth();
14
+ var screenHeight = Renderer.get().getHeight();
14
15
  var scalingFactor;
15
16
  if (screenWidth < screenHeight) {
16
17
  var shortEdge = Math.min(Constants.CANVAS_WIDTH, Constants.CANVAS_HEIGHT);
@@ -5,21 +5,34 @@
5
5
  * @version 0.0.5
6
6
  */
7
7
  var Renderer = /** @class */ (function () {
8
+ // No need to instantiate this class.
8
9
  function Renderer() {
9
10
  this.doc = document;
10
11
  }
12
+ Renderer.get = function () {
13
+ if (!Renderer._instance) {
14
+ Renderer._instance = new Renderer();
15
+ }
16
+ return Renderer._instance;
17
+ };
11
18
  /**
12
- * Get width of the browser
13
- * @return {number} inner width of the browser
19
+ * Get width of the parent most container where the Cooee's root div will render.
20
+ * @return width of the parent most container.
14
21
  */
15
22
  Renderer.prototype.getWidth = function () {
23
+ if (this.parentContainer) {
24
+ return this.parentContainer.clientWidth;
25
+ }
16
26
  return document.documentElement.clientWidth;
17
27
  };
18
28
  /**
19
- * Get height of the browser
20
- * @return {number} inner height of the browser
29
+ * Get height of the parent most container where the Cooee's root div will render.
30
+ * @return height of the parent most container.
21
31
  */
22
32
  Renderer.prototype.getHeight = function () {
33
+ if (this.parentContainer) {
34
+ return this.parentContainer.clientHeight;
35
+ }
23
36
  return document.documentElement.clientHeight;
24
37
  };
25
38
  /**
@@ -53,7 +66,7 @@ var Renderer = /** @class */ (function () {
53
66
  element.style.removeProperty(styleName);
54
67
  return;
55
68
  }
56
- element.style.setProperty(styleName, value);
69
+ element.style.setProperty(styleName, value, 'important');
57
70
  };
58
71
  /**
59
72
  * Set style of the element
@@ -65,12 +78,11 @@ var Renderer = /** @class */ (function () {
65
78
  element.setAttribute(attrName, value);
66
79
  };
67
80
  /**
68
- * Get element by tag id
69
- * @param {string} id id of the element
70
- * @return {HTMLElement | null} returns element if present, otherwise null
81
+ * Set the parent most container where the Cooee's In-App's root div will render.
82
+ * @param container The HTML holder element.
71
83
  */
72
- Renderer.prototype.getElementById = function (id) {
73
- return this.doc.getElementById(id);
84
+ Renderer.prototype.setParentContainer = function (container) {
85
+ this.parentContainer = container;
74
86
  };
75
87
  return Renderer;
76
88
  }());