esoftplay 0.0.266 → 0.0.268-04cfb21
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/assets/plugins/withAndroidPermissionsFix.js +37 -0
- package/bin/build.js +2 -1
- package/bin/cli.js +1 -0
- package/bin/mover.js +1 -1
- package/modules/lib/crypt.js +22340 -2
- package/modules/sys/mmkv.ts +5 -3
- package/modules/sys/storage.ts +82 -53
- package/package.json +1 -1
- package/publisher.js +4 -8
- package/publisher_beta.js +12 -0
package/modules/sys/mmkv.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// noPage
|
|
2
|
+
|
|
3
|
+
import { createMMKV } from "react-native-mmkv";
|
|
4
|
+
|
|
2
5
|
// withObject
|
|
3
6
|
let storage: any;
|
|
4
7
|
let isWeb = typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
|
|
@@ -19,8 +22,7 @@ if (isWeb) {
|
|
|
19
22
|
}
|
|
20
23
|
} else {
|
|
21
24
|
// @ts-ignore
|
|
22
|
-
|
|
23
|
-
storage = new MMKV();
|
|
25
|
+
storage = createMMKV()
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md) untuk melihat dokumentasi*/
|
|
@@ -39,7 +41,7 @@ const FastStorage = {
|
|
|
39
41
|
},
|
|
40
42
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md#removeItem) untuk melihat dokumentasi*/
|
|
41
43
|
removeItem(key: string) {
|
|
42
|
-
storage.
|
|
44
|
+
storage.remove(key)
|
|
43
45
|
},
|
|
44
46
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md#clear) untuk melihat dokumentasi*/
|
|
45
47
|
clear(): void {
|
package/modules/sys/storage.ts
CHANGED
|
@@ -1,90 +1,119 @@
|
|
|
1
1
|
//noPage
|
|
2
|
-
import
|
|
2
|
+
import { Directory, File, Paths } from "expo-file-system";
|
|
3
3
|
|
|
4
|
-
const CACHE_DIR =
|
|
4
|
+
const CACHE_DIR = new Directory(Paths.cache, "lib-storage-cache");
|
|
5
5
|
|
|
6
6
|
(async () => {
|
|
7
7
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
if (!CACHE_DIR.exists) {
|
|
9
|
+
CACHE_DIR.create();
|
|
10
|
+
}
|
|
11
|
+
} catch { }
|
|
12
12
|
})();
|
|
13
13
|
|
|
14
14
|
const Storage = {
|
|
15
|
-
getDBPath(key: string):
|
|
16
|
-
const
|
|
17
|
-
return
|
|
15
|
+
getDBPath(key: string): File {
|
|
16
|
+
const name = key.replace(/\//g, "-") + ".txt";
|
|
17
|
+
return new File(CACHE_DIR, name);
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
async getItem(key: string): Promise<any | null> {
|
|
21
21
|
try {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
if (exists)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} catch
|
|
22
|
+
const file = this.getDBPath(key);
|
|
23
|
+
|
|
24
|
+
if (!file.exists) return null;
|
|
25
|
+
|
|
26
|
+
const value = await file.text();
|
|
27
|
+
return JSON.parse(value);
|
|
28
|
+
} catch {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
return null;
|
|
32
31
|
},
|
|
32
|
+
|
|
33
33
|
async setItem(key: string, value: string): Promise<string> {
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const file = this.getDBPath(key);
|
|
35
|
+
|
|
36
|
+
await file.write(value);
|
|
37
|
+
|
|
36
38
|
return value;
|
|
37
39
|
},
|
|
40
|
+
|
|
38
41
|
async removeItem(key: string): Promise<string> {
|
|
39
|
-
const path = this.getDBPath(key);
|
|
40
42
|
try {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
const file = this.getDBPath(key);
|
|
44
|
+
|
|
45
|
+
if (file.exists) {
|
|
46
|
+
file.delete();
|
|
47
|
+
}
|
|
48
|
+
} catch { }
|
|
49
|
+
|
|
43
50
|
return key;
|
|
44
51
|
},
|
|
52
|
+
|
|
45
53
|
clear(): void {
|
|
46
|
-
|
|
54
|
+
try {
|
|
55
|
+
if (CACHE_DIR.exists) {
|
|
56
|
+
CACHE_DIR.delete();
|
|
57
|
+
}
|
|
58
|
+
} catch { }
|
|
47
59
|
},
|
|
48
|
-
async sendTelegram(key: string, message: string, onDone?: () => void, onFailed?: (reason: string) => void, chat_id?: string, customFileName?: (originalName: string) => string,) {
|
|
49
60
|
|
|
61
|
+
async sendTelegram(
|
|
62
|
+
key: string,
|
|
63
|
+
message: string,
|
|
64
|
+
onDone?: () => void,
|
|
65
|
+
onFailed?: (reason: string) => void,
|
|
66
|
+
chat_id?: string,
|
|
67
|
+
customFileName?: (originalName: string) => string
|
|
68
|
+
) {
|
|
50
69
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!
|
|
54
|
-
onFailed?.("File not found")
|
|
55
|
-
return
|
|
70
|
+
const file = this.getDBPath(key);
|
|
71
|
+
|
|
72
|
+
if (!file.exists) {
|
|
73
|
+
onFailed?.("File not found");
|
|
74
|
+
return;
|
|
56
75
|
}
|
|
57
76
|
|
|
58
|
-
const fileName =
|
|
77
|
+
const fileName = file.name;
|
|
59
78
|
|
|
60
79
|
if (fileName) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
const parts = fileName.split(".");
|
|
81
|
+
const fileWithoutExtension = parts.slice(0, -1).join(".");
|
|
82
|
+
const extension = parts[parts.length - 1];
|
|
83
|
+
|
|
64
84
|
const formData = new FormData();
|
|
65
|
-
formData.append(
|
|
66
|
-
formData.append(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
85
|
+
formData.append("caption", message);
|
|
86
|
+
formData.append("chat_id", chat_id ?? "-1001737180019");
|
|
87
|
+
|
|
88
|
+
formData.append("document", {
|
|
89
|
+
uri: file.uri,
|
|
90
|
+
name:
|
|
91
|
+
(customFileName?.(fileWithoutExtension) || fileWithoutExtension) +
|
|
92
|
+
"." +
|
|
93
|
+
extension,
|
|
94
|
+
type: "text/csv",
|
|
95
|
+
} as any);
|
|
96
|
+
|
|
97
|
+
const response = await fetch(
|
|
98
|
+
`https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendDocument`,
|
|
99
|
+
{
|
|
100
|
+
method: "POST",
|
|
101
|
+
body: formData,
|
|
102
|
+
}
|
|
103
|
+
);
|
|
76
104
|
|
|
77
105
|
const result = await response.json();
|
|
78
|
-
|
|
79
|
-
|
|
106
|
+
|
|
107
|
+
if (result.ok === true) {
|
|
108
|
+
onDone?.();
|
|
80
109
|
} else {
|
|
81
|
-
onFailed?.(result)
|
|
110
|
+
onFailed?.(JSON.stringify(result));
|
|
82
111
|
}
|
|
83
112
|
}
|
|
84
113
|
} catch (ex) {
|
|
85
|
-
onFailed?.(String(ex))
|
|
114
|
+
onFailed?.(String(ex));
|
|
86
115
|
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
89
118
|
|
|
90
|
-
export default Storage;
|
|
119
|
+
export default Storage;
|
package/package.json
CHANGED
package/publisher.js
CHANGED
|
@@ -2,14 +2,10 @@ const shell = require('child_process').execSync;
|
|
|
2
2
|
const packJson = require("./package.json")
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const version = packJson.version
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
let nextVersion = number.split(".")[0] + "." + number.split(".")[1] + "."
|
|
10
|
-
|
|
11
|
-
nextNumber = Number(nextNumber) + 1
|
|
12
|
-
nextVersion += nextNumber
|
|
5
|
+
const baseVersion = version.split('-')[0]
|
|
6
|
+
const parts = baseVersion.split('.')
|
|
7
|
+
let nextNumber = parseInt(parts[2]) + 1
|
|
8
|
+
let nextVersion = parts[0] + '.' + parts[1] + '.' + nextNumber
|
|
13
9
|
const newPackJson = { ...packJson, version: nextVersion }
|
|
14
10
|
fs.writeFileSync("./package.json", JSON.stringify(newPackJson, undefined, 2))
|
|
15
11
|
shell("npm publish", { stdio: ['inherit', 'inherit', 'inherit'] })
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const shell = require('child_process').execSync;
|
|
2
|
+
const packJson = require("./package.json")
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const crypto = require('crypto')
|
|
5
|
+
const version = packJson.version
|
|
6
|
+
const baseVersion = version.split('-')[0]
|
|
7
|
+
const randomHash = crypto.randomBytes(4).toString('hex').substring(0,7)
|
|
8
|
+
const nextVersion = baseVersion + '-' + randomHash
|
|
9
|
+
const newPackJson = { ...packJson, version: nextVersion }
|
|
10
|
+
fs.writeFileSync("./package.json", JSON.stringify(newPackJson, undefined, 2))
|
|
11
|
+
shell("npm publish", { stdio: ['inherit', 'inherit', 'inherit'] })
|
|
12
|
+
console.log("\nbun add esoftplay@" + nextVersion + " && bun install\n")
|