-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppKernel.js
62 lines (62 loc) · 1.35 KB
/
AppKernel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const APP_KERNEL_VERSION = 1;
class AppKernel {
constructor({ appId, debug }) {
this.DEBUG = debug === true; //$app.isDebugging;
this.AppConfig = JSON.parse($file.read("/config.json"));
this.AppInfo = this.AppConfig.info;
this.AppInfo.id = appId;
if (this.DEBUG) {
$console.info("AppKernel.init", this.AppInfo);
}
}
}
class AppUtil {
constructor() {}
isAppEnv() {
return $app.env == $env.app;
}
isActionEnv() {
return $app.env == $env.action;
}
isContextEnv() {
return $app.env == $env.action;
}
isSafariEnv() {
return $app.env == $env.safari;
}
isKeyboardEnv() {
return $app.env == $env.keyboard;
}
isWidgetEnv() {
return $app.env == $env.widget;
}
}
class GlobalStorage {
constructor(globalId) {
this.GLOBAL_ID = globalId;
}
getKeychain(key) {
return $keychain.get(key, this.GLOBAL_ID);
}
removeKeychain(key) {
return $keychain.remove(key, this.GLOBAL_ID);
}
setKeychain(key, value) {
return $keychain.set(key, value, this.GLOBAL_ID);
}
getCache(key) {
return $cache.get(`${this.GLOBAL_ID}.${key}`);
}
removeCache(key) {
return $cache.remove(`${this.GLOBAL_ID}.${key}`);
}
setCache(key, value) {
return $cache.set(`${this.GLOBAL_ID}.${key}`, value);
}
}
module.exports = {
APP_KERNEL_VERSION,
AppKernel,
AppUtil,
GlobalStorage
};