esoftplay 0.0.140-e → 0.0.140-g
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/config.json +26 -24
- package/global.ts +2 -2
- package/modules/lib/object.ts +35 -37
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"config": {
|
|
3
3
|
"timezone": "Asia/Jakarta",
|
|
4
|
-
"protocol": "http",
|
|
5
|
-
"domain": "esoftplay.com",
|
|
6
|
-
"api": "api",
|
|
7
|
-
"data": "data",
|
|
8
|
-
"uri": "/",
|
|
9
|
-
"home": {
|
|
10
|
-
"member": "content/member",
|
|
11
|
-
"public": "content"
|
|
4
|
+
"protocol": "http", // http or https
|
|
5
|
+
"domain": "esoftplay.com", // naked domain to website
|
|
6
|
+
"api": "api", // optional: subdomain to access web API
|
|
7
|
+
"data": "data", // optional: subdomain to access web content / article
|
|
8
|
+
"uri": "/", // relatif path to main website
|
|
9
|
+
"home": { // define the frontpage for module/task
|
|
10
|
+
"member": "content/member", // when user has been logged in
|
|
11
|
+
"public": "content" // when user not login yet
|
|
12
12
|
},
|
|
13
|
-
"errorReport": {
|
|
13
|
+
"errorReport": { // add telegram ids to listenReport Error
|
|
14
14
|
"telegramIds": [
|
|
15
15
|
"111111111"
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
|
-
"group_id":'1,
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
"group_id":'1,
|
|
19
|
+
2', // string separated comma
|
|
20
|
+
"isDebug": 1, // optional: display console on esp.log('any message'), don't use it for automatic detect the environment (production / development)
|
|
21
|
+
"salt": "CHANGE_INTO_YOUR_OWN_SALT", // SALT form config.php in your website
|
|
22
|
+
"notification": 1, // optional: to determine is this application have notification or not
|
|
23
|
+
"exludeModules": [],
|
|
24
|
+
"excludePackages": [], // optional: to delete module when listed
|
|
25
|
+
"firebase": { // https://console.firebase.google.com - download google-services.json
|
|
26
|
+
"apiKey": "FIREBASE_Web_API_Key", // Eg. AIzaSyAvVyNeXI3RTo7Tl5LCBSZ-mu92VpbPBK8Y
|
|
27
|
+
"authDomain": "FIREBASE_authDomain", // Eg. project-6495177974885932998.firebaseapp.com
|
|
26
28
|
"databaseURL": "FIREBASE_Database_URL", // Eg. https://project-6495177974885932998.firebaseio.com/
|
|
27
29
|
"storageBucket": "FIREBASE_Storage_URL" // Eg. test://project-6495177974885932998.appspot.com/
|
|
28
30
|
},
|
|
29
|
-
"experienceId":"@esp/appslug",
|
|
30
|
-
"iosClientId":"Ios Client id untuk keperluan google login",
|
|
31
|
-
"facebookAppId":"APP ID dari Aplikasi yang didaftarkan di Facebook Developer",
|
|
32
|
-
"theme":[],
|
|
33
|
-
"fonts":{
|
|
34
|
-
"fontName":"fontName.ttf or .otf",
|
|
35
|
-
"fontName2":"fontName2.ttf or .otf"
|
|
31
|
+
"experienceId": "@esp/appslug",
|
|
32
|
+
"iosClientId": "Ios Client id untuk keperluan google login",
|
|
33
|
+
"facebookAppId": "APP ID dari Aplikasi yang didaftarkan di Facebook Developer",
|
|
34
|
+
"theme": [], // untuk custom theme jika diperlukan,silahkan lihat module LibTheme untuk cara peggunaannya
|
|
35
|
+
"fonts": {
|
|
36
|
+
"fontName": "fontName.ttf or .otf", // taruh file font di assets/fonts/ jika ingin custom fonts. bisa lebih dari 1
|
|
37
|
+
"fontName2": "fontName2.ttf or .otf"
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
}
|
package/global.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface useGlobalOption {
|
|
|
32
32
|
|
|
33
33
|
export interface useGlobalConnect<T> {
|
|
34
34
|
selector?: (props: T) => any,
|
|
35
|
-
render: (props:
|
|
35
|
+
render: (props: Partial<T> | T) => any,
|
|
36
36
|
}
|
|
37
37
|
export let userDataReset: Function[] = []
|
|
38
38
|
let timeoutFinish: NodeJS.Timeout
|
|
@@ -175,7 +175,7 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
175
175
|
set(initValue)
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
function useSelector(se: (state: T) => any):
|
|
178
|
+
function useSelector(se: (state: T) => any): Partial<T> | T {
|
|
179
179
|
loadFromDisk()
|
|
180
180
|
|
|
181
181
|
let [l, s] = R.useState<any>(se(value));
|
package/modules/lib/object.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { update } from "immhelper";
|
|
4
4
|
|
|
5
5
|
export default class m {
|
|
6
|
-
|
|
6
|
+
#value = undefined
|
|
7
7
|
|
|
8
8
|
constructor(array: any) {
|
|
9
|
-
this
|
|
9
|
+
this.#value = array
|
|
10
10
|
this.value = this.value.bind(this)
|
|
11
11
|
this.push = this.push.bind(this)
|
|
12
12
|
this.unset = this.unset.bind(this)
|
|
@@ -27,40 +27,44 @@ export default class m {
|
|
|
27
27
|
spec = { [pathToUpdate]: [command, ...allValues] }
|
|
28
28
|
else
|
|
29
29
|
spec = [command, ...allValues]
|
|
30
|
-
this
|
|
30
|
+
this.#value = update(array, spec)
|
|
31
31
|
return this
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
push(value?: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
36
|
-
return this.cursorBuilder("push", this
|
|
36
|
+
return this.cursorBuilder("push", this.#value, value, ...values)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
unshift(value?: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
40
|
-
return this.cursorBuilder("unshift", this
|
|
40
|
+
return this.cursorBuilder("unshift", this.#value, value, ...values)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
splice(index: number, deleteCount: number, value?: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
44
|
-
return this.cursorBuilder("splice", this
|
|
44
|
+
return this.cursorBuilder("splice", this.#value, index, deleteCount, value, ...values)
|
|
45
45
|
}
|
|
46
46
|
unset(index: number | string, ...indexs: (string | number)[]): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
47
|
-
return this.cursorBuilder("unset", this
|
|
47
|
+
return this.cursorBuilder("unset", this.#value, index, ...indexs)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
set(value: any): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
51
|
-
return this.cursorBuilder("set", this
|
|
51
|
+
return this.cursorBuilder("set", this.#value, value)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
update(callback: (lastValue: any) => any): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
55
|
-
return this.cursorBuilder("batch", this
|
|
55
|
+
return this.cursorBuilder("batch", this.#value, callback)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
assign(obj1: any): (cursor?: string | number, ...cursors: (string | number)[]) => this {
|
|
59
|
-
return this.cursorBuilder("assign", this
|
|
59
|
+
return this.cursorBuilder("assign", this.#value, deepCopy(obj1))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
removeKeys(deletedItemKeys: string[]): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
63
|
+
return cursorBuilder("batch", this.#value, (arr) => _removeKeys(arr, deletedItemKeys))
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
value(): any {
|
|
63
|
-
return this
|
|
67
|
+
return this.#value
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
static push(array: any, value?: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
@@ -69,6 +73,9 @@ export default class m {
|
|
|
69
73
|
static unshift(array: any, value?: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
70
74
|
return cursorBuilder("unshift", array, value, ...values)
|
|
71
75
|
}
|
|
76
|
+
static removeKeys(arrayOrObj: any, deletedItemKeys: string[]): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
77
|
+
return cursorBuilder("batch", arrayOrObj, (arrOrObj) => _removeKeys(arrOrObj, deletedItemKeys))
|
|
78
|
+
}
|
|
72
79
|
static splice(array: any, index: number, deleteCount: number, value?: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
73
80
|
return cursorBuilder("splice", array, index, deleteCount, value, ...values)
|
|
74
81
|
}
|
|
@@ -84,32 +91,6 @@ export default class m {
|
|
|
84
91
|
static assign(obj: any, obj1: any): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
85
92
|
return cursorBuilder("assign", obj, deepCopy(obj1))
|
|
86
93
|
}
|
|
87
|
-
|
|
88
|
-
// static deepMerge(obj: any, obj1: any) {
|
|
89
|
-
// return (cursor?: string | number, ...cursors: (string | number)[]) => {
|
|
90
|
-
// function mergeDeep(target: any, source: any): any {
|
|
91
|
-
// const isObject = (obj) => obj && typeof obj === 'object';
|
|
92
|
-
// if (!isObject(target) || !isObject(source)) {
|
|
93
|
-
// return source;
|
|
94
|
-
// }
|
|
95
|
-
// Object.keys(source).forEach(key => {
|
|
96
|
-
// const targetValue = target[key];
|
|
97
|
-
// const sourceValue = source[key];
|
|
98
|
-
// if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
99
|
-
// target[key] = targetValue.concat(sourceValue);
|
|
100
|
-
// } else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
101
|
-
// target[key] = mergeDeep(Object.assign({}, targetValue), sourceValue);
|
|
102
|
-
// } else {
|
|
103
|
-
// target[key] = sourceValue;
|
|
104
|
-
// }
|
|
105
|
-
// });
|
|
106
|
-
// return target;
|
|
107
|
-
// }
|
|
108
|
-
// const allCursors = [cursor, ...cursors].filter((x) => x != undefined)
|
|
109
|
-
// let addressedObj = obj[cursor]
|
|
110
|
-
// return mergeDeep(addressedObj, obj1)
|
|
111
|
-
// }
|
|
112
|
-
// }
|
|
113
94
|
}
|
|
114
95
|
|
|
115
96
|
function cursorBuilder(command: string, array: any, value: any, ...values: any[]): (cursor?: string | number, ...cursors: (string | number)[]) => any {
|
|
@@ -126,6 +107,23 @@ function cursorBuilder(command: string, array: any, value: any, ...values: any[]
|
|
|
126
107
|
}
|
|
127
108
|
|
|
128
109
|
|
|
110
|
+
function _removeKeys(objOrArr, keysToRemove) {
|
|
111
|
+
if (Array.isArray(objOrArr)) {
|
|
112
|
+
return objOrArr.map(obj => {
|
|
113
|
+
let newObj = { ...obj };
|
|
114
|
+
keysToRemove.forEach(key => {
|
|
115
|
+
delete newObj[key];
|
|
116
|
+
});
|
|
117
|
+
return newObj;
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
let newObj = { ...objOrArr };
|
|
121
|
+
keysToRemove.forEach(key => {
|
|
122
|
+
delete newObj[key];
|
|
123
|
+
});
|
|
124
|
+
return newObj;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
129
127
|
|
|
130
128
|
function deepCopy(o) {
|
|
131
129
|
switch (typeof o) {
|