@letscooee/web-sdk 0.0.4 → 0.0.8
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 +20 -1
- package/README.md +6 -4
- package/dist/constants.js +11 -2
- package/dist/index-preview.js +3 -0
- package/dist/init/visibility-listener.js +2 -2
- 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/embedded-trigger.js +26 -0
- package/dist/models/trigger/inapp/container.js +104 -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 +9 -3
- package/dist/models/trigger/trigger-helper.js +52 -0
- package/dist/renderer/base-text-renderer.js +77 -0
- package/dist/renderer/block-processor.js +233 -0
- package/dist/renderer/block-renderer.js +44 -0
- package/dist/renderer/container-renderer.js +46 -0
- package/dist/renderer/group-renderer.js +44 -0
- package/dist/renderer/iFrame-renderer.js +82 -0
- package/dist/renderer/image-renderer.js +44 -0
- package/dist/renderer/in-app-renderer.js +84 -0
- package/dist/renderer/index.js +26 -0
- package/dist/renderer/renderer.js +97 -0
- package/dist/renderer/root-container-renderer.js +54 -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 +33 -9
- package/dist/services/user-auth.service.js +7 -7
- package/dist/session/new-session-executor.js +2 -2
- package/dist/session/session-manager.js +1 -0
- package/dist/utils/local-storage-helper.js +22 -0
- package/dist/utils/log.js +17 -13
- package/package.json +10 -7
- package/webpack-preview.config.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
# 0.0.8
|
|
4
|
+
|
|
5
|
+
1. Feature: Ability of InApp to be rendered inside an element.
|
|
6
|
+
2. Fix: Overflowed content should not be rendered.
|
|
7
|
+
3. Fix: Placing in-app on east direction.
|
|
8
|
+
|
|
9
|
+
# 0.0.7
|
|
10
|
+
|
|
11
|
+
More feature support in the sdk.
|
|
12
|
+
|
|
13
|
+
# 0.0.6
|
|
14
|
+
|
|
15
|
+
1. Build: Upgrade TypeScript to 4.4.
|
|
16
|
+
2. Fix: Convert \n to `<br>` in texts.
|
|
17
|
+
|
|
18
|
+
# 0.0.5
|
|
19
|
+
|
|
20
|
+
Supporting changes based on the in-app composer.
|
|
21
|
+
|
|
3
22
|
# 0.0.3, 0.0.4
|
|
4
23
|
|
|
5
24
|
1. Fix generating token because of missing app version.
|
|
@@ -7,4 +26,4 @@
|
|
|
7
26
|
|
|
8
27
|
# 0.0.2
|
|
9
28
|
|
|
10
|
-
First functional release.
|
|
29
|
+
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"
|
|
30
|
+
CooeeSDK.account.push({"appID": "MY_COOEE_APP_ID"});
|
|
31
31
|
</script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Replace `MY_COOEE_APP_ID`
|
|
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
|
|
|
@@ -72,7 +72,9 @@ Cooee SDK supports callback on the click of in-app notifications actions by retu
|
|
|
72
72
|
pairs i.e. objects in JavaScript.
|
|
73
73
|
|
|
74
74
|
```javascript
|
|
75
|
-
document.addEventListener('onCooeeCTA', function (
|
|
75
|
+
document.addEventListener('onCooeeCTA', function (event) {
|
|
76
|
+
const payload = event.detail;
|
|
77
|
+
|
|
76
78
|
if (!payload) return;
|
|
77
79
|
|
|
78
80
|
if (payload.actionType === "VIEW_ITEM") {
|
|
@@ -81,4 +83,4 @@ document.addEventListener('onCooeeCTA', function (payload) {
|
|
|
81
83
|
// Take user to the given screen name
|
|
82
84
|
}
|
|
83
85
|
}, false);
|
|
84
|
-
```
|
|
86
|
+
```
|
package/dist/constants.js
CHANGED
|
@@ -8,11 +8,12 @@ var Constants = /** @class */ (function () {
|
|
|
8
8
|
function Constants() {
|
|
9
9
|
}
|
|
10
10
|
Constants.API_URL = 'https://api.sdk.letscooee.com';
|
|
11
|
-
Constants.SDK_VERSION = '
|
|
12
|
-
Constants.SDK_VERSION_CODE = 4;
|
|
11
|
+
Constants.SDK_VERSION = require('../package.json').version;
|
|
13
12
|
Constants.SDK_DEBUG = false;
|
|
14
13
|
Constants.SDK = 'WEB';
|
|
15
14
|
Constants.LOG_PREFIX = 'CooeeSDK';
|
|
15
|
+
Constants.CANVAS_WIDTH = 1080;
|
|
16
|
+
Constants.CANVAS_HEIGHT = 1920;
|
|
16
17
|
// region Local Storage Keys
|
|
17
18
|
Constants.STORAGE_USER_ID = 'uid';
|
|
18
19
|
Constants.STORAGE_SDK_TOKEN = 'st';
|
|
@@ -23,8 +24,16 @@ var Constants = /** @class */ (function () {
|
|
|
23
24
|
Constants.STORAGE_SESSION_START_EVENT_SENT = 'sses';
|
|
24
25
|
Constants.STORAGE_FIRST_TIME_LAUNCH = 'ifl';
|
|
25
26
|
Constants.STORAGE_LAST_ACTIVE = 'la';
|
|
27
|
+
Constants.STORAGE_TRIGGER_START_TIME = 'tst';
|
|
28
|
+
Constants.STORAGE_ACTIVE_TRIGGER = 'at';
|
|
29
|
+
Constants.STORAGE_ACTIVE_TRIGGERS = 'ats';
|
|
26
30
|
// endregion
|
|
27
31
|
Constants.IDLE_TIME_IN_SECONDS = 30 * 60;
|
|
32
|
+
Constants.IN_APP_CONTAINER_NAME = 'cooee-wrapper';
|
|
33
|
+
(function () {
|
|
34
|
+
var rawCode = Constants.SDK_VERSION.split('.').map(function (item) { return item.padStart(2, '0'); }).join('');
|
|
35
|
+
Constants.SDK_VERSION_CODE = parseInt(rawCode, 10);
|
|
36
|
+
})();
|
|
28
37
|
return Constants;
|
|
29
38
|
}());
|
|
30
39
|
export { Constants };
|
|
@@ -89,7 +89,7 @@ var VisibilityListener = /** @class */ (function () {
|
|
|
89
89
|
}
|
|
90
90
|
props = {};
|
|
91
91
|
props[VisibilityListener.INACTIVE_DURATION] = duration;
|
|
92
|
-
event = new Event('CE
|
|
92
|
+
event = new Event('CE App Foreground', props);
|
|
93
93
|
_a = event;
|
|
94
94
|
return [4 /*yield*/, new DevicePropertiesCollector().get()];
|
|
95
95
|
case 1:
|
|
@@ -113,7 +113,7 @@ var VisibilityListener = /** @class */ (function () {
|
|
|
113
113
|
duration = this.runtimeData.getTimeForActiveInSeconds();
|
|
114
114
|
props = {};
|
|
115
115
|
props[VisibilityListener.ACTIVE_DURATION] = duration;
|
|
116
|
-
this.apiService.sendEvent(new Event('CE
|
|
116
|
+
this.apiService.sendEvent(new Event('CE App Background', props));
|
|
117
117
|
return [2 /*return*/];
|
|
118
118
|
});
|
|
119
119
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { Constants } from '../../../constants';
|
|
38
|
+
import { IFrameRenderer, RootContainerRenderer } from '../../../renderer';
|
|
39
|
+
import { SafeHttpService } from '../../../services/safe-http-service';
|
|
40
|
+
import { Log } from '../../../utils/log';
|
|
41
|
+
import { Event } from '../../event/event';
|
|
42
|
+
import { LocalStorageHelper } from '../../../utils/local-storage-helper';
|
|
43
|
+
import { Permission } from '../blocks/click-action';
|
|
44
|
+
/**
|
|
45
|
+
* Performs click to action on in-app elements
|
|
46
|
+
*
|
|
47
|
+
* @author Abhishek Taparia
|
|
48
|
+
* @version 0.0.5
|
|
49
|
+
*/
|
|
50
|
+
var ClickActionExecutor = /** @class */ (function () {
|
|
51
|
+
/**
|
|
52
|
+
* Constructor
|
|
53
|
+
* @param {ClickAction} action action data
|
|
54
|
+
*/
|
|
55
|
+
function ClickActionExecutor(action) {
|
|
56
|
+
this.action = action;
|
|
57
|
+
this.apiService = SafeHttpService.getInstance();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Execute CTAs on element click event
|
|
61
|
+
*/
|
|
62
|
+
ClickActionExecutor.prototype.execute = function () {
|
|
63
|
+
this.externalAction();
|
|
64
|
+
this.iabAction();
|
|
65
|
+
this.upAction();
|
|
66
|
+
this.kvAction();
|
|
67
|
+
this.prompt();
|
|
68
|
+
this.closeAction();
|
|
69
|
+
this.shareAction();
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Performs external action where url is opened in new tab/window.
|
|
73
|
+
*/
|
|
74
|
+
ClickActionExecutor.prototype.externalAction = function () {
|
|
75
|
+
var _a;
|
|
76
|
+
if (this.action.ext) {
|
|
77
|
+
(_a = window.open(this.action.ext.u, '_blank')) === null || _a === void 0 ? void 0 : _a.focus();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Performs in-app browser action i.e open url in <code>iFrame</code>
|
|
82
|
+
*/
|
|
83
|
+
ClickActionExecutor.prototype.iabAction = function () {
|
|
84
|
+
if (this.action.iab) {
|
|
85
|
+
new IFrameRenderer().render(this.action.iab.u);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Performs up action i.e. sending user properties back to server.
|
|
90
|
+
*/
|
|
91
|
+
ClickActionExecutor.prototype.upAction = function () {
|
|
92
|
+
if (this.action.up) {
|
|
93
|
+
this.apiService.updateProfile(this.action.up);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Performs kv action i.e. send key-value pair to the application.
|
|
98
|
+
*/
|
|
99
|
+
ClickActionExecutor.prototype.kvAction = function () {
|
|
100
|
+
if (this.action.kv) {
|
|
101
|
+
document.dispatchEvent(new CustomEvent('onCooeeCTA', { 'detail': this.action.kv }));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Performs prompt action i.e. ask for permission for location and notification.
|
|
106
|
+
*/
|
|
107
|
+
ClickActionExecutor.prototype.prompt = function () {
|
|
108
|
+
var permission = this.action.prompt;
|
|
109
|
+
if (!permission) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// TODO test in mobile browsers
|
|
113
|
+
if (permission === Permission.Location) {
|
|
114
|
+
this.promptLocationPermission();
|
|
115
|
+
}
|
|
116
|
+
if (permission === Permission.Push) {
|
|
117
|
+
this.promptPushNotificationPermission();
|
|
118
|
+
}
|
|
119
|
+
if (permission === Permission.Camera) {
|
|
120
|
+
this.promptCameraPermission();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Performs close action
|
|
125
|
+
*/
|
|
126
|
+
ClickActionExecutor.prototype.closeAction = function () {
|
|
127
|
+
var _a;
|
|
128
|
+
if (!this.action.close) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
new RootContainerRenderer().removeInApp();
|
|
132
|
+
var startTime = LocalStorageHelper.getNumber(Constants.STORAGE_TRIGGER_START_TIME, new Date().getTime());
|
|
133
|
+
var triggerID = (_a = LocalStorageHelper.getObject(Constants.STORAGE_ACTIVE_TRIGGER)) === null || _a === void 0 ? void 0 : _a.triggerID;
|
|
134
|
+
var diffInSeconds = (new Date().getTime() - startTime) / 1000;
|
|
135
|
+
var eventProps = {
|
|
136
|
+
'triggerID': triggerID,
|
|
137
|
+
'Close Behaviour': 'CTA',
|
|
138
|
+
'Duration': diffInSeconds,
|
|
139
|
+
};
|
|
140
|
+
this.apiService.sendEvent(new Event('CE Trigger Closed', eventProps));
|
|
141
|
+
LocalStorageHelper.remove(Constants.STORAGE_TRIGGER_START_TIME);
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Performs share action i.e. share some url on CTA.
|
|
145
|
+
*/
|
|
146
|
+
ClickActionExecutor.prototype.shareAction = function () {
|
|
147
|
+
// Navigator.share only works in mobile browsers and with https urls.
|
|
148
|
+
// {@link https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share}
|
|
149
|
+
if (!this.action.share) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// TODO test in mobile browsers
|
|
153
|
+
var share = navigator.share;
|
|
154
|
+
if (!share) {
|
|
155
|
+
Log.warning('Navigator.share is not compatible with this browser');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
navigator.share({ 'text': this.action.share.text, 'title': 'Share' })
|
|
159
|
+
.then(function (r) { return console.log(r); })
|
|
160
|
+
.catch(function (e) { return console.error(e); });
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* This prompts for the location permission from the user and if granted sends <code>coords</code>
|
|
164
|
+
* back to server as user properties.
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
ClickActionExecutor.prototype.promptLocationPermission = function () {
|
|
168
|
+
var _this = this;
|
|
169
|
+
if (!navigator.geolocation || !navigator.permissions) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// TODO Need device endpoints to update this property
|
|
173
|
+
navigator.geolocation.getCurrentPosition(function (position) {
|
|
174
|
+
_this.apiService.updateProfile({ 'coords': [position.coords.latitude, position.coords.longitude] });
|
|
175
|
+
_this.sendPermissionData();
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* This prompts for the push notification permission from the user.
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
ClickActionExecutor.prototype.promptPushNotificationPermission = function () {
|
|
183
|
+
var _this = this;
|
|
184
|
+
if (!('Notification' in window)) {
|
|
185
|
+
Log.warning('This browser does not support desktop notification');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// TODO Need device endpoints to update this property
|
|
189
|
+
if (Notification.permission !== 'default') {
|
|
190
|
+
this.apiService.updateProfile({ 'pnPerm': Notification.permission });
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
Notification.requestPermission()
|
|
194
|
+
.then(function () {
|
|
195
|
+
_this.sendPermissionData();
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* This prompts for the camera permission from the user.
|
|
200
|
+
* @private
|
|
201
|
+
*/
|
|
202
|
+
ClickActionExecutor.prototype.promptCameraPermission = function () {
|
|
203
|
+
var _this = this;
|
|
204
|
+
if (!navigator.mediaDevices) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
navigator.mediaDevices.getUserMedia({ video: true }).finally(function () {
|
|
208
|
+
_this.sendPermissionData();
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Check for a permission
|
|
213
|
+
* @param of permission of what
|
|
214
|
+
* @private
|
|
215
|
+
* @return permission state
|
|
216
|
+
*/
|
|
217
|
+
ClickActionExecutor.prototype.checkPermission = function (of) {
|
|
218
|
+
return navigator.permissions.query({ name: of })
|
|
219
|
+
.then(function (permission) {
|
|
220
|
+
return permission.state.toString();
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Check for all the permissions
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
227
|
+
ClickActionExecutor.prototype.checkAllPermission = function () {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var camera, location, notification;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0: return [4 /*yield*/, this.checkPermission('camera')];
|
|
233
|
+
case 1:
|
|
234
|
+
camera = _a.sent();
|
|
235
|
+
return [4 /*yield*/, this.checkPermission('geolocation')];
|
|
236
|
+
case 2:
|
|
237
|
+
location = _a.sent();
|
|
238
|
+
notification = Notification.permission;
|
|
239
|
+
return [2 /*return*/, {
|
|
240
|
+
camera: camera,
|
|
241
|
+
location: location,
|
|
242
|
+
notification: notification,
|
|
243
|
+
}];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Send permission data to device property
|
|
250
|
+
* @private
|
|
251
|
+
*/
|
|
252
|
+
ClickActionExecutor.prototype.sendPermissionData = function () {
|
|
253
|
+
var _this = this;
|
|
254
|
+
this.checkAllPermission().then(function (permissions) {
|
|
255
|
+
_this.apiService.updateProfile({ 'perm': permissions });
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
return ClickActionExecutor;
|
|
259
|
+
}());
|
|
260
|
+
export { ClickActionExecutor };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Color, Glossy } from './';
|
|
2
|
+
var Background = /** @class */ (function () {
|
|
3
|
+
function Background(data) {
|
|
4
|
+
if (data.s)
|
|
5
|
+
this.s = new Color(data.s);
|
|
6
|
+
if (data.g)
|
|
7
|
+
this.g = new Glossy(data.g);
|
|
8
|
+
this.i = data.i;
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(Background.prototype, "solid", {
|
|
11
|
+
get: function () {
|
|
12
|
+
return this.s;
|
|
13
|
+
},
|
|
14
|
+
enumerable: false,
|
|
15
|
+
configurable: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(Background.prototype, "glossy", {
|
|
18
|
+
get: function () {
|
|
19
|
+
return this.g;
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(Background.prototype, "img", {
|
|
25
|
+
get: function () {
|
|
26
|
+
return this.i;
|
|
27
|
+
},
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
return Background;
|
|
32
|
+
}());
|
|
33
|
+
export { Background };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Color } from './color';
|
|
2
|
+
var Border = /** @class */ (function () {
|
|
3
|
+
function Border(data) {
|
|
4
|
+
this.s = data.s;
|
|
5
|
+
this.r = data.r;
|
|
6
|
+
this.w = data.w;
|
|
7
|
+
if (data.c) {
|
|
8
|
+
this.c = new Color(data.c);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(Border.prototype, "radius", {
|
|
12
|
+
get: function () {
|
|
13
|
+
return this.r;
|
|
14
|
+
},
|
|
15
|
+
enumerable: false,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(Border.prototype, "width", {
|
|
19
|
+
get: function () {
|
|
20
|
+
return this.w;
|
|
21
|
+
},
|
|
22
|
+
enumerable: false,
|
|
23
|
+
configurable: true
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(Border.prototype, "color", {
|
|
26
|
+
get: function () {
|
|
27
|
+
return this.c;
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(Border.prototype, "style", {
|
|
33
|
+
get: function () {
|
|
34
|
+
var _a;
|
|
35
|
+
return BorderStyle[(_a = this.s) !== null && _a !== void 0 ? _a : BorderStyle.SOLID];
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
return Border;
|
|
41
|
+
}());
|
|
42
|
+
export { Border };
|
|
43
|
+
/* eslint-disable no-unused-vars */
|
|
44
|
+
export var BorderStyle;
|
|
45
|
+
(function (BorderStyle) {
|
|
46
|
+
BorderStyle[BorderStyle["SOLID"] = 1] = "SOLID";
|
|
47
|
+
BorderStyle[BorderStyle["DASHED"] = 2] = "DASHED";
|
|
48
|
+
})(BorderStyle || (BorderStyle = {}));
|
|
49
|
+
/* eslint-enable no-unused-vars */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var Permission;
|
|
2
|
+
(function (Permission) {
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
Permission["Location"] = "LOCATION";
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
6
|
+
Permission["Push"] = "PUSH";
|
|
7
|
+
// eslint-disable-next-line no-unused-vars
|
|
8
|
+
Permission["Camera"] = "CAMERA";
|
|
9
|
+
})(Permission || (Permission = {}));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import hexRgb from 'hex-rgb';
|
|
2
|
+
var Color = /** @class */ (function () {
|
|
3
|
+
function Color(props) {
|
|
4
|
+
/**
|
|
5
|
+
* The alpha/transparency
|
|
6
|
+
*/
|
|
7
|
+
this.a = 100;
|
|
8
|
+
this.h = props.h;
|
|
9
|
+
this.a = props.a;
|
|
10
|
+
this.g = props.g;
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(Color.prototype, "hex", {
|
|
13
|
+
get: function () {
|
|
14
|
+
return this.h;
|
|
15
|
+
},
|
|
16
|
+
enumerable: false,
|
|
17
|
+
configurable: true
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(Color.prototype, "grad", {
|
|
20
|
+
get: function () {
|
|
21
|
+
return this.g;
|
|
22
|
+
},
|
|
23
|
+
enumerable: false,
|
|
24
|
+
configurable: true
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(Color.prototype, "rgba", {
|
|
27
|
+
get: function () {
|
|
28
|
+
if (!this.hex) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return hexRgb(this.hex, { format: 'css', alpha: this.getAlpha() });
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error('Invalid hex', e);
|
|
36
|
+
return '#000000';
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
Color.prototype.getAlpha = function () {
|
|
43
|
+
var _a;
|
|
44
|
+
return ((_a = this.a) !== null && _a !== void 0 ? _a : 100) / 100;
|
|
45
|
+
};
|
|
46
|
+
return Color;
|
|
47
|
+
}());
|
|
48
|
+
export { Color };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Color } from './color';
|
|
2
|
+
var Glossy = /** @class */ (function () {
|
|
3
|
+
function Glossy(data) {
|
|
4
|
+
this.r = data.r;
|
|
5
|
+
if (data.c) {
|
|
6
|
+
this.c = new Color(data.c);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(Glossy.prototype, "radius", {
|
|
10
|
+
get: function () {
|
|
11
|
+
return this.r;
|
|
12
|
+
},
|
|
13
|
+
enumerable: false,
|
|
14
|
+
configurable: true
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(Glossy.prototype, "color", {
|
|
17
|
+
get: function () {
|
|
18
|
+
return this.c;
|
|
19
|
+
},
|
|
20
|
+
enumerable: false,
|
|
21
|
+
configurable: true
|
|
22
|
+
});
|
|
23
|
+
return Glossy;
|
|
24
|
+
}());
|
|
25
|
+
export { Glossy };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var Transform = /** @class */ (function () {
|
|
2
|
+
function Transform() {
|
|
3
|
+
}
|
|
4
|
+
Object.defineProperty(Transform.prototype, "rotate", {
|
|
5
|
+
get: function () {
|
|
6
|
+
return this.rot;
|
|
7
|
+
},
|
|
8
|
+
enumerable: false,
|
|
9
|
+
configurable: true
|
|
10
|
+
});
|
|
11
|
+
return Transform;
|
|
12
|
+
}());
|
|
13
|
+
export { Transform };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Background, Border } from '../blocks';
|
|
2
|
+
var BaseElement = /** @class */ (function () {
|
|
3
|
+
function BaseElement(data) {
|
|
4
|
+
this.t = data.t;
|
|
5
|
+
if (data.bg)
|
|
6
|
+
this.bg = new Background(data.bg);
|
|
7
|
+
if (data.br)
|
|
8
|
+
this.br = new Border(data.br);
|
|
9
|
+
this.clc = data.clc;
|
|
10
|
+
this.shd = data.shd;
|
|
11
|
+
this.spc = data.spc;
|
|
12
|
+
this.trf = data.trf;
|
|
13
|
+
this.w = data.w;
|
|
14
|
+
this.h = data.h;
|
|
15
|
+
this.x = data.x;
|
|
16
|
+
this.y = data.y;
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(BaseElement.prototype, "type", {
|
|
19
|
+
get: function () {
|
|
20
|
+
return this.t;
|
|
21
|
+
},
|
|
22
|
+
enumerable: false,
|
|
23
|
+
configurable: true
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(BaseElement.prototype, "typeAsString", {
|
|
26
|
+
get: function () {
|
|
27
|
+
return ElementType[this.t];
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(BaseElement.prototype, "click", {
|
|
33
|
+
get: function () {
|
|
34
|
+
return this.clc;
|
|
35
|
+
},
|
|
36
|
+
enumerable: false,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
return BaseElement;
|
|
40
|
+
}());
|
|
41
|
+
export { BaseElement };
|
|
42
|
+
/* eslint-disable no-unused-vars */
|
|
43
|
+
export var ElementType;
|
|
44
|
+
(function (ElementType) {
|
|
45
|
+
ElementType[ElementType["IMAGE"] = 1] = "IMAGE";
|
|
46
|
+
ElementType[ElementType["TEXT"] = 2] = "TEXT";
|
|
47
|
+
ElementType[ElementType["BUTTON"] = 3] = "BUTTON";
|
|
48
|
+
ElementType[ElementType["SHAPE"] = 100] = "SHAPE";
|
|
49
|
+
})(ElementType || (ElementType = {}));
|
|
50
|
+
/* eslint-disable no-unused-vars */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|