esoftplay 0.0.184 → 0.0.185
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/bin/build.js +2 -6
- package/mmkv.ts +23 -3
- package/mmkv.web.ts +32 -0
- package/modules/lib/curl.ts +9 -9
- package/package.json +1 -1
package/bin/build.js
CHANGED
|
@@ -168,11 +168,11 @@ if (fs.existsSync(packjson)) {
|
|
|
168
168
|
|
|
169
169
|
const easconfg = `{
|
|
170
170
|
"cli": {
|
|
171
|
-
"version": ">= 0.52.0"
|
|
171
|
+
"version": ">= 0.52.0",
|
|
172
|
+
"appVersionSource": "local"
|
|
172
173
|
},
|
|
173
174
|
"build": {
|
|
174
175
|
"development": {
|
|
175
|
-
"bun": "1.1.0",
|
|
176
176
|
"developmentClient": true,
|
|
177
177
|
"distribution": "internal",
|
|
178
178
|
"ios": {
|
|
@@ -181,13 +181,11 @@ if (fs.existsSync(packjson)) {
|
|
|
181
181
|
"channel": "default"
|
|
182
182
|
},
|
|
183
183
|
"development_build": {
|
|
184
|
-
"bun": "1.1.0",
|
|
185
184
|
"developmentClient": true,
|
|
186
185
|
"distribution": "internal",
|
|
187
186
|
"channel": "default"
|
|
188
187
|
},
|
|
189
188
|
"preview": {
|
|
190
|
-
"bun": "1.1.0",
|
|
191
189
|
"distribution": "internal",
|
|
192
190
|
"ios": {
|
|
193
191
|
"simulator": true
|
|
@@ -195,7 +193,6 @@ if (fs.existsSync(packjson)) {
|
|
|
195
193
|
"channel": "default"
|
|
196
194
|
},
|
|
197
195
|
"preview_build": {
|
|
198
|
-
"bun": "1.1.0",
|
|
199
196
|
"distribution": "internal",
|
|
200
197
|
"android": {
|
|
201
198
|
"buildType": "apk"
|
|
@@ -203,7 +200,6 @@ if (fs.existsSync(packjson)) {
|
|
|
203
200
|
"channel": "default"
|
|
204
201
|
},
|
|
205
202
|
"production": {
|
|
206
|
-
"bun": "1.1.0",
|
|
207
203
|
"channel": "default"
|
|
208
204
|
}
|
|
209
205
|
},
|
package/mmkv.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import { MMKV } from 'react-native-mmkv';
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
let storage: any;
|
|
3
|
+
let isWeb = typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
|
|
4
|
+
if (isWeb) {
|
|
5
|
+
storage = {
|
|
6
|
+
getString(key: string) {
|
|
7
|
+
return window.localStorage.getItem(key) || '';
|
|
8
|
+
},
|
|
9
|
+
set(key: string, value: string) {
|
|
10
|
+
window.localStorage.setItem(key, value);
|
|
11
|
+
},
|
|
12
|
+
delete(key: string) {
|
|
13
|
+
window.localStorage.removeItem(key);
|
|
14
|
+
},
|
|
15
|
+
clearAll() {
|
|
16
|
+
window.localStorage.clear();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const MMKV = require('react-native-mmkv').MMKV;
|
|
22
|
+
storage = new MMKV();
|
|
23
|
+
}
|
|
4
24
|
|
|
5
25
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md) untuk melihat dokumentasi*/
|
|
6
26
|
const FastStorage = {
|
|
@@ -22,7 +42,7 @@ const FastStorage = {
|
|
|
22
42
|
},
|
|
23
43
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md#clear) untuk melihat dokumentasi*/
|
|
24
44
|
clear(): void {
|
|
25
|
-
storage.clearAll()
|
|
45
|
+
storage.clearAll();
|
|
26
46
|
},
|
|
27
47
|
};
|
|
28
48
|
|
package/mmkv.web.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// MMKV web shim using localStorage
|
|
2
|
+
const isWeb = typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
|
|
3
|
+
|
|
4
|
+
const storage = {
|
|
5
|
+
getString(key) {
|
|
6
|
+
if (isWeb) return window.localStorage.getItem(key) || '';
|
|
7
|
+
return '';
|
|
8
|
+
},
|
|
9
|
+
set(key, value) {
|
|
10
|
+
if (isWeb) window.localStorage.setItem(key, value);
|
|
11
|
+
},
|
|
12
|
+
delete(key) {
|
|
13
|
+
if (isWeb) window.localStorage.removeItem(key);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const FastStorage = {
|
|
18
|
+
getItemSync(key) {
|
|
19
|
+
return storage.getString(key);
|
|
20
|
+
},
|
|
21
|
+
getItem(key) {
|
|
22
|
+
return Promise.resolve(storage.getString(key));
|
|
23
|
+
},
|
|
24
|
+
setItem(key, value) {
|
|
25
|
+
storage.set(key, value);
|
|
26
|
+
},
|
|
27
|
+
removeItem(key) {
|
|
28
|
+
storage.delete(key);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default FastStorage;
|
package/modules/lib/curl.ts
CHANGED
|
@@ -153,7 +153,7 @@ export default class m {
|
|
|
153
153
|
post.api_key = _apiKey
|
|
154
154
|
}
|
|
155
155
|
let ps = Object.keys(_post).map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(_post[key])).join('&');
|
|
156
|
-
|
|
156
|
+
let options: any = {
|
|
157
157
|
method: "POST",
|
|
158
158
|
signal: this.signal,
|
|
159
159
|
headers: {
|
|
@@ -198,12 +198,12 @@ export default class m {
|
|
|
198
198
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/curl.md#uploaduri-string-postkey-string-fileuri-string-mimetype-string-ondone-res-any-msg-string--void-onfailed-error-any-timeout-boolean--void-debug-number-void) untuk melihat dokumentasi*/
|
|
199
199
|
public upload(uri: string, postKey: string, fileUri: string, mimeType: string, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number): void {
|
|
200
200
|
postKey = postKey || "image";
|
|
201
|
-
|
|
201
|
+
let uName = fileUri.substring(fileUri.lastIndexOf("/") + 1, fileUri.length);
|
|
202
202
|
if (!uName.includes('.')) {
|
|
203
203
|
uName += '.jpg'
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
let uType = mimeType || "image/jpeg"
|
|
206
|
+
let post = { [postKey]: { uri: fileUri, type: uType, name: uName } }
|
|
207
207
|
this.init(uri, post, onDone, onFailed, debug, true)
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -284,7 +284,7 @@ export default class m {
|
|
|
284
284
|
this.setUrl(esp.config("url"))
|
|
285
285
|
}
|
|
286
286
|
await this.setHeader()
|
|
287
|
-
|
|
287
|
+
let options: any = {
|
|
288
288
|
method: !this.post ? "GET" : "POST",
|
|
289
289
|
signal: this.signal,
|
|
290
290
|
headers: {
|
|
@@ -304,9 +304,9 @@ export default class m {
|
|
|
304
304
|
//api_init_time
|
|
305
305
|
fetch(this.url + this.uri, options).then(async (res) => {
|
|
306
306
|
this.cancelTimeout()
|
|
307
|
-
|
|
307
|
+
let resText = await res.text()
|
|
308
308
|
this.resStatus = res.status
|
|
309
|
-
|
|
309
|
+
let resJson = (resText.startsWith("{") || resText.startsWith("[")) ? JSON.parse(resText) : null
|
|
310
310
|
if (resJson) {
|
|
311
311
|
if (onDone) onDone(resJson, false)
|
|
312
312
|
this.onDone(resJson)
|
|
@@ -361,7 +361,7 @@ export default class m {
|
|
|
361
361
|
this.header["Content-Type"] = "multipart/form-data"
|
|
362
362
|
else
|
|
363
363
|
this.header["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8"
|
|
364
|
-
|
|
364
|
+
let options: any = {
|
|
365
365
|
method: !this.post ? "GET" : "POST",
|
|
366
366
|
headers: this.header,
|
|
367
367
|
body: this.post,
|
|
@@ -409,7 +409,7 @@ export default class m {
|
|
|
409
409
|
|
|
410
410
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/curl.md#onfetchedrestext-string--object-ondone-res-any-msg-string--void-onfailed-error-any-timeout-boolean--void-debug-number-void) untuk melihat dokumentasi*/
|
|
411
411
|
protected onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number): void {
|
|
412
|
-
|
|
412
|
+
let resJson = typeof resText == 'string' && ((resText.startsWith("{") && resText.endsWith("}")) || (resText.startsWith("[") && resText.endsWith("]"))) ? JSON.parse(resText) : resText
|
|
413
413
|
if (typeof resJson == "object") {
|
|
414
414
|
if (!resJson.status_code || this.onStatusCode(resJson.ok, resJson.status_code, resJson.message, resJson.result)) {
|
|
415
415
|
if (resJson.ok === 1) {
|