esoftplay 0.0.109 → 0.0.110
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 +92 -140
- package/bin/router.js +25 -9
- package/esp.ts +7 -10
- package/global.ts +9 -4
- package/modules/content/category.tsx +2 -2
- package/modules/content/category_list.tsx +2 -2
- package/modules/content/comment.tsx +3 -3
- package/modules/content/detail.tsx +1 -1
- package/modules/content/gallery.tsx +4 -4
- package/modules/content/list.tsx +2 -2
- package/modules/lib/curl.ts +82 -30
- package/modules/lib/image_crop.tsx +2 -2
- package/modules/lib/image_multi.tsx +2 -2
- package/modules/lib/input_base.tsx +2 -0
- package/modules/lib/list.tsx +1 -1
- package/modules/lib/locale.ts +3 -6
- package/modules/lib/navigation.ts +15 -2
- package/modules/lib/progress.tsx +1 -0
- package/modules/lib/sociallogin.tsx +2 -2
- package/modules/lib/utils.ts +2 -0
- package/modules/lib/version.tsx +1 -1
- package/moment.ts +1 -1
- package/package.json +1 -1
- package/state.ts +2 -2
package/bin/build.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @ts-check
|
|
3
|
-
const {
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const DIR = "../../"
|
|
6
6
|
const packjson = DIR + "package.json"
|
|
7
7
|
const appjson = DIR + "app.json"
|
|
8
8
|
const confjson = DIR + "config.json"
|
|
9
9
|
const gitignore = DIR + ".gitignore"
|
|
10
|
+
const babelconfig = DIR + "babel.config.js"
|
|
10
11
|
const tsconfig = DIR + "tsconfig.json"
|
|
11
12
|
const appjs = DIR + "App.js"
|
|
12
13
|
const appts = DIR + "App.tsx"
|
|
13
|
-
const pathScript = DIR + "node_modules/react-native-scripts/build/bin/react-native-scripts.js"
|
|
14
14
|
const pathJSTimer = DIR + "node_modules/react-native/Libraries/Core/Timers/JSTimers.js"
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -22,104 +22,16 @@ const pathJSTimer = DIR + "node_modules/react-native/Libraries/Core/Timers/JSTim
|
|
|
22
22
|
if (fs.existsSync(packjson)) {
|
|
23
23
|
let txt = fs.readFileSync(packjson, 'utf8');
|
|
24
24
|
let $package = JSON.parse(txt);
|
|
25
|
-
let rewrite = false;
|
|
26
25
|
let args = process.argv.slice(2);
|
|
27
26
|
|
|
28
|
-
|
|
29
27
|
/* ADD SCRIPTS.PRESTART AND SCRIPTS.POSTSTOP */
|
|
30
|
-
if (fs.existsSync(pathScript)) {
|
|
31
|
-
let $script = fs.readFileSync(pathScript, 'utf8');
|
|
32
28
|
|
|
33
|
-
/* Update react-native-scripts */
|
|
34
|
-
let code1 = "// the command is valid"
|
|
35
|
-
let code2 = "";
|
|
36
|
-
let match = $script.match(new RegExp(code1 + "(\s{0,}\n\s{0,}[^\n]+)\n")); // mengambil 1 baris setelah code1
|
|
37
|
-
let $script2 = $script;
|
|
38
|
-
let espCode = false;
|
|
39
|
-
if (match) {
|
|
40
|
-
if (args[0] == "install") {
|
|
41
|
-
let reg = new RegExp(/(\[.*?\),)/g) // mengambil argument ke 2 dari .sync()
|
|
42
|
-
let tag = match[1].match(reg)
|
|
43
|
-
if (tag) {
|
|
44
|
-
if (!tag[0].match(/esoftplay/)) {
|
|
45
|
-
espCode = match[1].replace(reg, "['./node_modules/.bin/esoftplay', script],") // ganti argument ke 2 menjadi milik esoftplay
|
|
46
|
-
code2 = code1 + espCode;
|
|
47
|
-
$script2 = $script.replace(code1, code2) // masukkan code ke dalam script setelah argument ke 2 di ganti ke esoftplay
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} else
|
|
51
|
-
if (args[0] == "uninstall") {
|
|
52
|
-
if (match[1].match(/esoftplay/)) {
|
|
53
|
-
$script2 = $script.replace(match[1], code2) // hapus script dari esoftplay
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if ($script2 != $script) {
|
|
58
|
-
fs.writeFile(pathScript, $script2, (err) => {
|
|
59
|
-
if (err) throw err;
|
|
60
|
-
console.log('react-native-scripts has been updated!!');
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
/* Update package.json for latest expo */
|
|
65
|
-
let stringExist = ''
|
|
66
|
-
let stringToBe = ''
|
|
67
|
-
rewrite = false
|
|
68
|
-
if (!$package.hasOwnProperty("scripts")) {
|
|
69
|
-
rewrite = true
|
|
70
|
-
$package.scripts = {
|
|
71
|
-
"start": "esp start && expo start",
|
|
72
|
-
"android": "expo start --android",
|
|
73
|
-
"ios": "expo start --ios",
|
|
74
|
-
"eject": "expo eject"
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (args[0] == "install") {
|
|
78
|
-
if (!$package.scripts.hasOwnProperty("start")) {
|
|
79
|
-
rewrite = true;
|
|
80
|
-
stringExist = `"start": "expo start"`
|
|
81
|
-
stringToBe = `"start": "esp start && expo start"`
|
|
82
|
-
// $package.scripts.start = "esp start && expo start"
|
|
83
|
-
} else {
|
|
84
|
-
if (!$package.scripts.start.match(/esp start/)) {
|
|
85
|
-
rewrite = true
|
|
86
|
-
stringExist = `"start": "expo start"`
|
|
87
|
-
stringToBe = `"start": "esp start && expo start"`
|
|
88
|
-
// $package.scripts.start = "esp start && " + $package.scripts.start
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
} else
|
|
92
|
-
if (args[0] == "uninstall") {
|
|
93
|
-
if ($package.scripts.start.match(/esp start/)) {
|
|
94
|
-
rewrite = true
|
|
95
|
-
stringExist = `"start": "esp start && expo start"`
|
|
96
|
-
stringToBe = `"start": "expo start"`
|
|
97
|
-
// $package.scripts.start = $package.scripts.start.replace(/esp start(\s+&&\s+)/ig, "");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (rewrite) {
|
|
101
|
-
// fs.readFile(packjson, 'utf8', function (err, data) {
|
|
102
|
-
// if (err) {
|
|
103
|
-
// return console.log(err);
|
|
104
|
-
// }
|
|
105
|
-
// let result = data.replace(stringExist, stringToBe);
|
|
106
|
-
|
|
107
|
-
// fs.writeFile(packjson, result, 'utf8', function (err) {
|
|
108
|
-
// if (err) return console.log(err);
|
|
109
|
-
// });
|
|
110
|
-
// });
|
|
111
|
-
// console.log("Please change scripts.start in package.json into '" + $package.scripts.start + "'")
|
|
112
|
-
// spawn('node', ['./packager.js', args[0], packjson], { stdio: 'inherit' })
|
|
113
|
-
fs.writeFile(packjson, JSON.stringify($package, null, 2), (err) => {
|
|
114
|
-
if (err) throw err;
|
|
115
|
-
console.log('package.json has been updated');
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/* Create esp command line */
|
|
121
29
|
if (args[0] == "install") {
|
|
122
|
-
|
|
30
|
+
$package.scripts.start = "esp start && expo start"
|
|
31
|
+
fs.writeFile(packjson, JSON.stringify($package, null, 2), (err) => {
|
|
32
|
+
if (err) throw err;
|
|
33
|
+
console.log('package.json has been updated');
|
|
34
|
+
});
|
|
123
35
|
}
|
|
124
36
|
|
|
125
37
|
/* Update app.json */
|
|
@@ -127,9 +39,7 @@ if (fs.existsSync(packjson)) {
|
|
|
127
39
|
let $config = {}
|
|
128
40
|
if (fs.existsSync(confjson))
|
|
129
41
|
$config = JSON.parse(fs.readFileSync(confjson, 'utf8')) || {};
|
|
130
|
-
rewrite = false;
|
|
131
42
|
if (!$config.hasOwnProperty('config')) {
|
|
132
|
-
rewrite = true;
|
|
133
43
|
$config.config = {
|
|
134
44
|
"domain": "domain.com",
|
|
135
45
|
"errorReport": {
|
|
@@ -146,18 +56,15 @@ if (fs.existsSync(packjson)) {
|
|
|
146
56
|
}
|
|
147
57
|
}
|
|
148
58
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
59
|
+
fs.writeFile(confjson, JSON.stringify($config, null, 2), (err) => {
|
|
60
|
+
if (err) throw err;
|
|
61
|
+
console.log('config.json has been created');
|
|
62
|
+
});
|
|
63
|
+
|
|
155
64
|
let $appjson = {}
|
|
156
65
|
if (fs.existsSync(appjson))
|
|
157
66
|
$appjson = JSON.parse(fs.readFileSync(appjson, 'utf8')) || {};
|
|
158
|
-
rewrite = false;
|
|
159
67
|
if (!$appjson.expo.hasOwnProperty('android')) {
|
|
160
|
-
rewrite = true;
|
|
161
68
|
$appjson.expo.android = {
|
|
162
69
|
"useNextNotificationsApi": true,
|
|
163
70
|
"package": "com.domain",
|
|
@@ -196,12 +103,11 @@ if (fs.existsSync(packjson)) {
|
|
|
196
103
|
"applinks:domain.com"
|
|
197
104
|
]
|
|
198
105
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
106
|
+
|
|
107
|
+
fs.writeFile(appjson, JSON.stringify($appjson, null, 2), (err) => {
|
|
108
|
+
if (err) throw err;
|
|
109
|
+
console.log('app.json has been updated');
|
|
110
|
+
});
|
|
205
111
|
}
|
|
206
112
|
/* Fix Code android timers */
|
|
207
113
|
if (fs.existsSync(pathJSTimer)) {
|
|
@@ -210,6 +116,27 @@ if (fs.existsSync(packjson)) {
|
|
|
210
116
|
fs.writeFileSync(pathJSTimer, JSTimers)
|
|
211
117
|
}
|
|
212
118
|
|
|
119
|
+
|
|
120
|
+
const babelconf = `module.exports = function (api) {
|
|
121
|
+
api.cache(true);
|
|
122
|
+
|
|
123
|
+
let plugins = []
|
|
124
|
+
|
|
125
|
+
if (process.env["ENV"] === "prod") {
|
|
126
|
+
plugins.push("transform-remove-console");
|
|
127
|
+
plugins.push("transform-react-native-style-optimizer");
|
|
128
|
+
}
|
|
129
|
+
plugins.push("react-native-reanimated/plugin")
|
|
130
|
+
return {
|
|
131
|
+
presets: ["babel-preset-expo"],
|
|
132
|
+
plugins
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
`
|
|
136
|
+
fs.writeFile(babelconfig, babelconf, (err) => {
|
|
137
|
+
if (err) throw err;
|
|
138
|
+
console.log('babel.config.js has been updated');
|
|
139
|
+
})
|
|
213
140
|
/* Update App.js */
|
|
214
141
|
const TSconfig = `{\n\
|
|
215
142
|
"compilerOptions": {\n\
|
|
@@ -249,33 +176,56 @@ node_modules/\n\
|
|
|
249
176
|
npm-debug.*\n\
|
|
250
177
|
package-lock.json\n\
|
|
251
178
|
yarn.lock\n\
|
|
179
|
+
yarn-error.log\n\
|
|
252
180
|
`
|
|
253
181
|
fs.writeFile(gitignore, GitIgnore, (err) => {
|
|
254
182
|
if (err) throw err;
|
|
255
183
|
console.log('.gitignore has been created');
|
|
256
184
|
});
|
|
257
185
|
|
|
186
|
+
// const AppJS = `import { esp, LibNotification } from 'esoftplay';
|
|
187
|
+
// import * as ErrorReport from 'esoftplay/error';
|
|
188
|
+
// import * as Notifications from 'expo-notifications';
|
|
189
|
+
// import React, { useEffect, useRef } from 'react';
|
|
190
|
+
// import { enableFreeze, enableScreens } from 'react-native-screens';
|
|
191
|
+
// const { globalIdx } = require('esoftplay/global')
|
|
192
|
+
// enableScreens();
|
|
193
|
+
// enableFreeze(true);
|
|
194
|
+
|
|
195
|
+
// Notifications.addNotificationResponseReceivedListener(x => LibNotification.onAction(x))
|
|
196
|
+
|
|
197
|
+
// export default function App() {
|
|
198
|
+
// const Home = useRef(esp.home()).current
|
|
199
|
+
|
|
200
|
+
// useEffect(() => {
|
|
201
|
+
// globalIdx.reset()
|
|
202
|
+
// ErrorReport.getError()
|
|
203
|
+
// }, [])
|
|
204
|
+
|
|
205
|
+
// return <Home />
|
|
206
|
+
// }`;
|
|
207
|
+
|
|
208
|
+
|
|
258
209
|
const AppJS = `import { esp, LibNotification } from 'esoftplay';
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}`;
|
|
210
|
+
import * as ErrorReport from 'esoftplay/error';
|
|
211
|
+
import * as Notifications from 'expo-notifications';
|
|
212
|
+
import React, { useEffect, useRef } from 'react';
|
|
213
|
+
import { enableScreens } from 'react-native-screens';
|
|
214
|
+
const { globalIdx } = require('esoftplay/global');
|
|
215
|
+
enableScreens();
|
|
216
|
+
|
|
217
|
+
Notifications.addNotificationResponseReceivedListener(x => LibNotification.onAction(x));
|
|
218
|
+
|
|
219
|
+
export default function App() {
|
|
220
|
+
const Home = useRef(esp.home()).current
|
|
221
|
+
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
globalIdx.reset()
|
|
224
|
+
ErrorReport.getError()
|
|
225
|
+
}, [])
|
|
226
|
+
|
|
227
|
+
return <Home />
|
|
228
|
+
}`;
|
|
279
229
|
let expoLib = [
|
|
280
230
|
'@expo/vector-icons',
|
|
281
231
|
'@react-native-async-storage/async-storage',
|
|
@@ -325,6 +275,8 @@ yarn.lock\n\
|
|
|
325
275
|
}
|
|
326
276
|
let devLibs = [
|
|
327
277
|
"@babel/core",
|
|
278
|
+
"babel-plugin-transform-react-native-style-optimizer",
|
|
279
|
+
"babel-plugin-transform-remove-console",
|
|
328
280
|
"@types/react",
|
|
329
281
|
"@types/react-native",
|
|
330
282
|
"typescript",
|
|
@@ -358,16 +310,16 @@ yarn.lock\n\
|
|
|
358
310
|
cmd += "&& yarn add " + installDevLibs.join(" ") + " --dev "
|
|
359
311
|
if (installExpoLibs.length > 0)
|
|
360
312
|
cmd += "&& expo install " + installExpoLibs.join(" ")
|
|
361
|
-
cmd += "&&
|
|
362
|
-
execSync(cmd
|
|
313
|
+
// cmd += " && npm i -s esoftplay"
|
|
314
|
+
execSync(cmd)
|
|
363
315
|
console.log('App.js has been replace to App.tsx');
|
|
364
|
-
/* bugfix AsyncStorage @firebase, remove this section if firebase has update the AsyncStorage */
|
|
365
|
-
if (fs.existsSync('../@firebase/app/dist/index.rn.cjs.js')) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
/* end AsyncStorage @firebase section */
|
|
316
|
+
// /* bugfix AsyncStorage @firebase, remove this section if firebase has update the AsyncStorage */
|
|
317
|
+
// if (fs.existsSync('../@firebase/app/dist/index.rn.cjs.js')) {
|
|
318
|
+
// let firebaseText = fs.readFileSync('../@firebase/app/dist/index.rn.cjs.js', 'utf8')
|
|
319
|
+
// firebaseText = firebaseText.replace("var AsyncStorage = require('react-native').AsyncStorage;", "var AsyncStorage = require('@react-native-async-storage/async-storage').default;")
|
|
320
|
+
// fs.writeFileSync('../@firebase/app/dist/index.rn.cjs.js', firebaseText)
|
|
321
|
+
// }
|
|
322
|
+
// /* end AsyncStorage @firebase section */
|
|
371
323
|
if (fs.existsSync('../@expo/vector-icons')) {
|
|
372
324
|
let esoftplayIcon = ''
|
|
373
325
|
fs.readdir('../@expo/vector-icons/build', (err, files) => {
|
package/bin/router.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
2
3
|
/* EXECUTED ON `ESP START` TO BUILD FILE CACHES */
|
|
3
4
|
const fs = require('fs');
|
|
4
5
|
var checks = ['./node_modules/esoftplay/modules/', './modules/', './templates/'];
|
|
@@ -9,14 +10,29 @@ var replacer = new RegExp(/(?:\-|\.(?:ios|android))?\.(?:jsx|js|ts|tsx)$/);
|
|
|
9
10
|
var Text = "";
|
|
10
11
|
const rngh = "./node_modules/react-native-gesture-handler/react-native-gesture-handler.d.ts"
|
|
11
12
|
|
|
12
|
-
const curPackjson = require('../package.json')
|
|
13
|
-
const mainPackjson = require('../../../package.json')
|
|
13
|
+
// const curPackjson = require('../package.json')
|
|
14
|
+
// const mainPackjson = require('../../../package.json')
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
// function getNestedObjectValue(obj, keys) {
|
|
17
|
+
// if (keys.length > 0) {
|
|
18
|
+
// var key = keys.shift();
|
|
19
|
+
// if (key in obj) {
|
|
20
|
+
// return getNestedObjectValue(obj[key], keys);
|
|
21
|
+
// } else {
|
|
22
|
+
// return null;
|
|
23
|
+
// }
|
|
24
|
+
// } else {
|
|
25
|
+
// return obj;
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// const prjVersion = getNestedObjectValue(mainPackjson, ['dependencies', 'esoftplay'])
|
|
31
|
+
// if (prjVersion && prjVersion.includes(curPackjson.version)) {
|
|
32
|
+
// try {
|
|
33
|
+
// console.log("\x1b[31m", "VERSI esoftplay tidak SESUAI " + mainPackjson.dependencies.esoftplay + " != " + curPackjson.version + " ✘", "\x1b[0m")
|
|
34
|
+
// } catch (error) { }
|
|
35
|
+
// }
|
|
20
36
|
|
|
21
37
|
if (fs.existsSync(rngh)) {
|
|
22
38
|
fs.unlink(rngh, (err) => { })
|
|
@@ -247,7 +263,7 @@ checks.forEach(modules => {
|
|
|
247
263
|
}
|
|
248
264
|
/* REGEX All Functions */
|
|
249
265
|
if (!isHooks && !isUseLibs) {
|
|
250
|
-
var r = /\n(\s+)((?:(?:static|public|private|async)\s+)?[a-zA-Z0-9_]{3,}\s{0,}(?:<S>|)(?:=\s{0,})?\([^{\n]+)/g; // 1=spaces 2=FunctionObject
|
|
266
|
+
var r = /\n(\s+)((?:(?:static|public|private|protected|public async|private async|protected async|async)\s+)?[a-zA-Z0-9_]{3,}\s{0,}(?:<S>|)(?:=\s{0,})?\([^{\n]+)/g; // 1=spaces 2=FunctionObject
|
|
251
267
|
if (s = r.exec(data)) {
|
|
252
268
|
if (m = data.match(r)) {
|
|
253
269
|
/* check jika class tersebut nge replace bukan nge extends maka hapus semua fungsi bawaan dari supernya */
|
|
@@ -257,7 +273,7 @@ checks.forEach(modules => {
|
|
|
257
273
|
}
|
|
258
274
|
}
|
|
259
275
|
for (var i = 0; i < m.length; i++) {
|
|
260
|
-
if (S = m[i].match(/\n([^\na-zA-Z0-9_]+)((?:(?:static|public|private|async)\s+)?[a-zA-Z0-9_]{3,})/)) {
|
|
276
|
+
if (S = m[i].match(/\n([^\na-zA-Z0-9_]+)((?:(?:static|public|private|protected|public async|private async|protected async|async)\s+)?[a-zA-Z0-9_]{3,})/)) {
|
|
261
277
|
if (S[1] === s[1].replace(new RegExp('\n', 'g'), '')) {
|
|
262
278
|
var a = m[i].trim().replace('async ', '') + ";"
|
|
263
279
|
tmpTask[clsName]["function"][S[2]] = a;
|
package/esp.ts
CHANGED
|
@@ -76,11 +76,9 @@ export default (() => {
|
|
|
76
76
|
var _params = [param, ...params]
|
|
77
77
|
if (_params.length > 0)
|
|
78
78
|
for (let i = 0; i < _params.length; i++) {
|
|
79
|
-
|
|
80
|
-
if (out
|
|
81
|
-
|
|
82
|
-
} else {
|
|
83
|
-
out = undefined;
|
|
79
|
+
out = out?.[_params[i]];
|
|
80
|
+
if (out == undefined) {
|
|
81
|
+
break;
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
}
|
|
@@ -89,9 +87,9 @@ export default (() => {
|
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
function lang(moduleTask: string, langName: string, ...stringToBe: string[]): string {
|
|
92
|
-
let string =
|
|
90
|
+
let string = esp.assets("locale/" + langId() + ".json")?.[moduleTask]?.[langName]
|
|
93
91
|
if (!string) {
|
|
94
|
-
string =
|
|
92
|
+
string = esp.assets("locale/id.json")?.[moduleTask]?.[langName]
|
|
95
93
|
}
|
|
96
94
|
function sprintf(string: string, index: number) {
|
|
97
95
|
if (stringToBe[index] != undefined) {
|
|
@@ -109,10 +107,9 @@ export default (() => {
|
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
function langId(): string {
|
|
112
|
-
|
|
113
|
-
return _store.lang_id
|
|
110
|
+
return LibLocale.state().get()
|
|
114
111
|
}
|
|
115
|
-
|
|
112
|
+
|
|
116
113
|
function mod(path: string): any {
|
|
117
114
|
var modtast = path.split("/");
|
|
118
115
|
if (modtast[1] == "") {
|
package/global.ts
CHANGED
|
@@ -48,7 +48,10 @@ const n = () => {
|
|
|
48
48
|
|
|
49
49
|
// rehidryte instant
|
|
50
50
|
if (o?.persistKey) {
|
|
51
|
-
rehidryte(o.persistKey, (p) => {
|
|
51
|
+
rehidryte(o.persistKey, (p) => {
|
|
52
|
+
if (typeof p == 'string') set(JSON.parse(p))
|
|
53
|
+
|
|
54
|
+
})
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
/* register to userData to automatically reset state and persist */
|
|
@@ -150,12 +153,14 @@ const n = () => {
|
|
|
150
153
|
debounce(() => {
|
|
151
154
|
AsyncStorage.multiGet(Object.keys(persistKeys), (e, v) => {
|
|
152
155
|
if (v && !e) {
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
v.forEach((iv, i) => {
|
|
157
|
+
persistKeys[iv[0]]?.(iv[1])
|
|
155
158
|
})
|
|
159
|
+
} else {
|
|
160
|
+
|
|
156
161
|
}
|
|
157
162
|
})
|
|
158
|
-
},
|
|
163
|
+
}, 100)
|
|
159
164
|
}
|
|
160
165
|
return m
|
|
161
166
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
|
|
3
|
-
import { ContentHeader, esp, LibCurl, LibList, LibNavigation, LibPicture,
|
|
3
|
+
import { ContentHeader, esp, LibCurl, LibList, LibNavigation, LibPicture, useGlobalReturn, useGlobalState } from 'esoftplay';
|
|
4
4
|
import React, { useEffect, useRef } from 'react';
|
|
5
5
|
import { Pressable, Text, View } from 'react-native';
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ export function state(): useGlobalReturn<any> {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
export default function m(props: ContentCategoryProps): any {
|
|
23
|
-
let { url } = useRef<any>(
|
|
23
|
+
let { url } = useRef<any>(LibNavigation.getArgsAll(props)).current
|
|
24
24
|
const conf = esp.config()
|
|
25
25
|
url = url || conf.content
|
|
26
26
|
const data = _state.useSelector(s => s)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
// noPage
|
|
3
|
-
import { ContentCategoryProperty, esp, LibCurl, LibNavigation, LibPicture
|
|
3
|
+
import { ContentCategoryProperty, esp, LibCurl, LibNavigation, LibPicture } from 'esoftplay';
|
|
4
4
|
import React, { useEffect, useRef } from 'react';
|
|
5
5
|
import { Pressable, ScrollView, Text, View } from 'react-native';
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ export interface ContentCategory_listProps {
|
|
|
13
13
|
}
|
|
14
14
|
export default function m(props: ContentCategory_listProps): any {
|
|
15
15
|
const { id } = props
|
|
16
|
-
let { url } = useRef<any>(
|
|
16
|
+
let { url } = useRef<any>(LibNavigation.getArgsAll(props)).current
|
|
17
17
|
const conf = esp.config()
|
|
18
18
|
url = url || conf.content
|
|
19
19
|
const menu = ContentCategoryProperty.state().useSelector(s => s)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
|
|
3
|
-
import { ContentComment_item, ContentHeader, LibCurl, LibIcon, LibInfinite, LibInput, LibKeyboard_avoid, LibObject, LibSociallogin, LibStyle, LibToastProperty, LibUtils, useGlobalReturn, useGlobalState, useSafeState } from 'esoftplay';
|
|
3
|
+
import { ContentComment_item, ContentHeader, LibCurl, LibIcon, LibInfinite, LibInput, LibKeyboard_avoid, LibNavigation, LibObject, LibSociallogin, LibStyle, LibToastProperty, LibUtils, useGlobalReturn, useGlobalState, useSafeState } from 'esoftplay';
|
|
4
4
|
import esp from 'esoftplay/esp';
|
|
5
5
|
import React, { useEffect, useRef } from 'react';
|
|
6
6
|
import { Alert, Image, Pressable, Text, View } from 'react-native';
|
|
@@ -26,7 +26,7 @@ export function state(): useGlobalReturn<any> {
|
|
|
26
26
|
export default function m(props: ContentCommentProps): any {
|
|
27
27
|
const listComment = useRef<LibInfinite>(null)
|
|
28
28
|
const commentInput = useRef<LibInput>(null)
|
|
29
|
-
let { url, url_post, id, par_id, header } =
|
|
29
|
+
let { url, url_post, id, par_id, header } = LibNavigation.getArgsAll(props)
|
|
30
30
|
|
|
31
31
|
url = useRef(url || esp.config('content') + 'user/commentlist/' + id).current
|
|
32
32
|
url_post = useRef(url_post || esp.config('content') + 'user/commentpost/' + id).current
|
|
@@ -113,7 +113,7 @@ export default function m(props: ContentCommentProps): any {
|
|
|
113
113
|
</View>
|
|
114
114
|
)
|
|
115
115
|
}
|
|
116
|
-
let x =(item) => <ContentComment_item url={url} url_post={url_post} {...item} />
|
|
116
|
+
let x = (item) => <ContentComment_item url={url} url_post={url_post} {...item} />
|
|
117
117
|
|
|
118
118
|
return (
|
|
119
119
|
<View style={{ flex: 1 }} >
|
|
@@ -12,7 +12,7 @@ export interface ContentDetailProps {
|
|
|
12
12
|
|
|
13
13
|
}
|
|
14
14
|
export default function m(props: ContentDetailProps): any {
|
|
15
|
-
const { id, url, title, image, created } =
|
|
15
|
+
const { id, url, title, image, created } = LibNavigation.getArgsAll(props)
|
|
16
16
|
const [result, setResult] = useSafeState<any>({ id, url, title, image, created })
|
|
17
17
|
const [isAudioPlaying, setIsAudioPlaying] = useSafeState(false)
|
|
18
18
|
const audioRef = useRef<ContentAudio>(null)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
|
|
3
|
-
import { LibIcon, LibNavigation, LibStyle
|
|
3
|
+
import { LibIcon, LibNavigation, LibStyle } from 'esoftplay';
|
|
4
4
|
import React, { useRef } from 'react';
|
|
5
5
|
import { Pressable, View } from 'react-native';
|
|
6
6
|
import Gallery from 'react-native-awesome-gallery';
|
|
@@ -12,9 +12,9 @@ export interface ContentGalleryProps {
|
|
|
12
12
|
|
|
13
13
|
}
|
|
14
14
|
export default function m(props: ContentGalleryProps): any {
|
|
15
|
-
let images =
|
|
16
|
-
const image =
|
|
17
|
-
const index =
|
|
15
|
+
let images = LibNavigation.getArgs(props, "images", [])
|
|
16
|
+
const image = LibNavigation.getArgs(props, "image", "")
|
|
17
|
+
const index = LibNavigation.getArgs(props, "index", 0)
|
|
18
18
|
let scale = useRef(1).current
|
|
19
19
|
|
|
20
20
|
if (images.length == 0) {
|
package/modules/content/list.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
|
|
3
|
-
import { ContentCategory_list, ContentConfig, ContentHeader, ContentItem, ContentItem_header, esp, LibCarrousel, LibInfinite, LibObject, LibStyle,
|
|
3
|
+
import { ContentCategory_list, ContentConfig, ContentHeader, ContentItem, ContentItem_header, esp, LibCarrousel, LibInfinite, LibNavigation, LibObject, LibStyle, UserRoutes, useSafeState } from 'esoftplay';
|
|
4
4
|
import React, { useRef } from 'react';
|
|
5
5
|
import { View } from 'react-native';
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ export default function m(props: ContentListProps): any {
|
|
|
15
15
|
|
|
16
16
|
const routes = UserRoutes.state().get()
|
|
17
17
|
|
|
18
|
-
let { url, title, id } = useRef<any>(
|
|
18
|
+
let { url, title, id } = useRef<any>(LibNavigation.getArgsAll(props)).current
|
|
19
19
|
const conf = esp.config()
|
|
20
20
|
url = url || conf.content
|
|
21
21
|
id = id || 0
|
package/modules/lib/curl.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { reportApiError } from "esoftplay/error";
|
|
|
4
4
|
import moment from "esoftplay/moment";
|
|
5
5
|
const axios = require('axios');
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
export default class ecurl {
|
|
9
8
|
timeout = 55000;
|
|
10
9
|
timeoutContext: any = null;
|
|
@@ -14,6 +13,7 @@ export default class ecurl {
|
|
|
14
13
|
url: any = esp.config('url')
|
|
15
14
|
apiKey: any = 0
|
|
16
15
|
uri: any = '';
|
|
16
|
+
isSecure: boolean = false
|
|
17
17
|
fetchConf: any = ''
|
|
18
18
|
alertTimeout = {
|
|
19
19
|
title: "Oops..! Gagal menyambung ke server",
|
|
@@ -39,17 +39,19 @@ export default class ecurl {
|
|
|
39
39
|
this.onError = this.onError.bind(this)
|
|
40
40
|
this.setApiKey = this.setApiKey.bind(this)
|
|
41
41
|
this.secure = this.secure.bind(this)
|
|
42
|
+
this.withHeader = this.withHeader.bind(this)
|
|
42
43
|
this.initTimeout = this.initTimeout.bind(this)
|
|
43
44
|
this.cancelTimeout = this.cancelTimeout.bind(this)
|
|
45
|
+
// this.createApiTesterUris = this.createApiTesterUris.bind(this)
|
|
44
46
|
const str: any = LibNet_status.state().get()
|
|
45
47
|
if (uri && str.isOnline) {
|
|
46
48
|
this.init(uri, post, onDone, onFailed, debug);
|
|
47
49
|
} else if (!str.isOnline && onFailed) {
|
|
48
|
-
onFailed("Failed to access", false);
|
|
50
|
+
onFailed(this.refineErrorMessage("Failed to access"), false);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
initTimeout(customTimeout?: number): void {
|
|
54
|
+
protected initTimeout(customTimeout?: number): void {
|
|
53
55
|
this.cancelTimeout()
|
|
54
56
|
this.timeoutContext = setTimeout(() => {
|
|
55
57
|
if (this.abort?.cancel) {
|
|
@@ -60,28 +62,57 @@ export default class ecurl {
|
|
|
60
62
|
}, customTimeout ?? this.timeout);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
cancelTimeout(): void {
|
|
65
|
+
private cancelTimeout(): void {
|
|
64
66
|
clearTimeout(this.timeoutContext)
|
|
65
67
|
this.timeoutContext = null;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
onFetchFailed(message: string): void {
|
|
70
|
+
private onFetchFailed(message: string): void {
|
|
69
71
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
setUrl(url: string): void {
|
|
74
|
+
protected setUrl(url: string): void {
|
|
73
75
|
this.url = url
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
setUri(uri: string): void {
|
|
78
|
+
protected setUri(uri: string): void {
|
|
77
79
|
this.uri = uri
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
// createApiTesterUris(): void {
|
|
83
|
+
|
|
84
|
+
// if (esp.isDebug('onlyAvailableOnDebug')) {
|
|
85
|
+
// setTimeout(() => {
|
|
86
|
+
// const options = this.fetchConf.options
|
|
87
|
+
// const msg = this.uri.replace('/', '.').split('?')[0] + `
|
|
88
|
+
// /* RARE USAGE : to simulate LibCurl().secure() : default false */
|
|
89
|
+
// const IS_SECURE_POST = `+ this.isSecure + `
|
|
90
|
+
|
|
91
|
+
// const EXTRACT = []
|
|
92
|
+
// const EXTRACT_CHECK = []
|
|
93
|
+
|
|
94
|
+
// const GET = {`+ JSON.stringify(LibUtils.getUrlParams(options?.url) || '') + `
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
// const POST = {`+ options._post + `
|
|
98
|
+
// }
|
|
99
|
+
// module.exports = { POST, GET, IS_SECURE_POST, EXTRACT, EXTRACT_CHECK }
|
|
100
|
+
// `
|
|
101
|
+
// let post = {
|
|
102
|
+
// text: msg,
|
|
103
|
+
// chat_id: '-626800023',
|
|
104
|
+
// disable_web_page_preview: true
|
|
105
|
+
// }
|
|
106
|
+
// this.custom('https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendMessage', post)
|
|
107
|
+
// }, 1000);
|
|
108
|
+
// }
|
|
109
|
+
// }
|
|
110
|
+
|
|
111
|
+
protected setApiKey(apiKey: string): void {
|
|
81
112
|
this.apiKey = apiKey
|
|
82
113
|
}
|
|
83
114
|
|
|
84
|
-
async setHeader(): Promise<void> {
|
|
115
|
+
protected async setHeader(): Promise<void> {
|
|
85
116
|
return new Promise((r) => {
|
|
86
117
|
if ((/:\/\/data.*?\/(.*)/g).test(this.url)) {
|
|
87
118
|
this.header["masterkey"] = new LibCrypt().encode(this.url)
|
|
@@ -90,25 +121,26 @@ export default class ecurl {
|
|
|
90
121
|
});
|
|
91
122
|
}
|
|
92
123
|
|
|
93
|
-
closeConnection(): void {
|
|
124
|
+
protected closeConnection(): void {
|
|
94
125
|
this?.abort?.cancel('Oops, Sepertinya ada gangguan jaringan... Silahkan coba beberapa saat lagi');
|
|
95
126
|
}
|
|
96
127
|
|
|
97
|
-
onDone(result: any, msg?: string): void {
|
|
128
|
+
protected onDone(result: any, msg?: string): void {
|
|
98
129
|
|
|
99
130
|
}
|
|
100
131
|
|
|
101
|
-
onFailed(msg: string, timeout: boolean): void {
|
|
132
|
+
protected onFailed(msg: string, timeout: boolean): void {
|
|
102
133
|
|
|
103
134
|
}
|
|
104
135
|
|
|
105
|
-
onStatusCode(ok: number, status_code: number, message: string, result: any): boolean {
|
|
136
|
+
protected onStatusCode(ok: number, status_code: number, message: string, result: any): boolean {
|
|
106
137
|
return true
|
|
107
138
|
}
|
|
108
139
|
|
|
109
|
-
secure(token_uri?: string): (apiKey?: string) => (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
|
|
140
|
+
public secure(token_uri?: string): (apiKey?: string) => (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
|
|
110
141
|
return (apiKey?: string): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void => {
|
|
111
142
|
return async (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => {
|
|
143
|
+
this.isSecure = true
|
|
112
144
|
await this.setHeader();
|
|
113
145
|
const _apiKey = apiKey || this.apiKey
|
|
114
146
|
Object.keys(post).forEach((key) => {
|
|
@@ -146,7 +178,7 @@ export default class ecurl {
|
|
|
146
178
|
this.init(uri, { ...post, access_token: res }, onDone, onFailed, debug);
|
|
147
179
|
}, (msg) => {
|
|
148
180
|
if (onFailed)
|
|
149
|
-
onFailed(msg, false)
|
|
181
|
+
onFailed(this.refineErrorMessage(msg), false)
|
|
150
182
|
}, debug)
|
|
151
183
|
}).catch((r: string) => {
|
|
152
184
|
this.cancelTimeout();
|
|
@@ -157,7 +189,12 @@ export default class ecurl {
|
|
|
157
189
|
}
|
|
158
190
|
}
|
|
159
191
|
|
|
160
|
-
|
|
192
|
+
public withHeader(header: any): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
|
|
193
|
+
this.header = { ...this.header, ...header }
|
|
194
|
+
return (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => this.init(uri, post, onDone, onFailed, debug)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public upload(uri: string, postKey: string, fileUri: string, mimeType: string, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
|
|
161
198
|
postKey = postKey || "image";
|
|
162
199
|
var uName = fileUri.substring(fileUri.lastIndexOf("/") + 1, fileUri.length);
|
|
163
200
|
if (!uName.includes('.')) {
|
|
@@ -168,7 +205,7 @@ export default class ecurl {
|
|
|
168
205
|
this.init(uri, post, onDone, onFailed, debug, true)
|
|
169
206
|
}
|
|
170
207
|
|
|
171
|
-
urlEncode(str: string): string {
|
|
208
|
+
private urlEncode(str: string): string {
|
|
172
209
|
return str
|
|
173
210
|
.replace(/\!/g, '%21')
|
|
174
211
|
.replace(/\'/g, '%27')
|
|
@@ -178,7 +215,7 @@ export default class ecurl {
|
|
|
178
215
|
.replace(/%20/g, '+')
|
|
179
216
|
}
|
|
180
217
|
|
|
181
|
-
encodeGetValue(_get: string): string {
|
|
218
|
+
private encodeGetValue(_get: string): string {
|
|
182
219
|
if (_get != '') {
|
|
183
220
|
let hashes = _get.split('&')
|
|
184
221
|
let params: any = {}
|
|
@@ -200,7 +237,7 @@ export default class ecurl {
|
|
|
200
237
|
return _get
|
|
201
238
|
}
|
|
202
239
|
|
|
203
|
-
signatureBuild(): string {
|
|
240
|
+
private signatureBuild(): string {
|
|
204
241
|
let signature = '';
|
|
205
242
|
if (this.url.includes(esp.config('url'))) {
|
|
206
243
|
let payload = '';
|
|
@@ -224,7 +261,7 @@ export default class ecurl {
|
|
|
224
261
|
return signature
|
|
225
262
|
}
|
|
226
263
|
|
|
227
|
-
async custom(uri: string, post?: any, onDone?: (res: any, timeout: boolean) => void, debug?: number): Promise<void> {
|
|
264
|
+
public async custom(uri: string, post?: any, onDone?: (res: any, timeout: boolean) => void, debug?: number): Promise<void> {
|
|
228
265
|
const str: any = LibNet_status.state().get()
|
|
229
266
|
if (str.isOnline) {
|
|
230
267
|
if (post) {
|
|
@@ -256,8 +293,9 @@ export default class ecurl {
|
|
|
256
293
|
mode: "cors",
|
|
257
294
|
_post: post
|
|
258
295
|
}
|
|
259
|
-
if (debug == 1)
|
|
260
|
-
esp.log(this.url + this.uri, options)
|
|
296
|
+
if (debug == 1) {
|
|
297
|
+
esp.log(this.url + this.uri, { ...options, cancelToken: undefined })
|
|
298
|
+
}
|
|
261
299
|
this.fetchConf = { url: this.url + this.uri, options: options }
|
|
262
300
|
// this.initTimeout()
|
|
263
301
|
axios(options).then(async (res: any) => {
|
|
@@ -276,7 +314,7 @@ export default class ecurl {
|
|
|
276
314
|
}
|
|
277
315
|
}
|
|
278
316
|
|
|
279
|
-
async init(uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number, upload?: boolean): Promise<void> {
|
|
317
|
+
private async init(uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number, upload?: boolean): Promise<void> {
|
|
280
318
|
if (post) {
|
|
281
319
|
if (upload) {
|
|
282
320
|
let fd = new FormData();
|
|
@@ -316,7 +354,9 @@ export default class ecurl {
|
|
|
316
354
|
mode: "cors",
|
|
317
355
|
_post: post
|
|
318
356
|
}
|
|
319
|
-
if (debug == 1)
|
|
357
|
+
if (debug == 1) {
|
|
358
|
+
esp.log(this.url + this.uri, { ...options, cancelToken: undefined })
|
|
359
|
+
}
|
|
320
360
|
this.fetchConf = { url: this.url + this.uri, options: options }
|
|
321
361
|
this.initTimeout(upload ? 120000 : undefined)
|
|
322
362
|
axios(options).then(async (res: any) => {
|
|
@@ -328,7 +368,7 @@ export default class ecurl {
|
|
|
328
368
|
})
|
|
329
369
|
}
|
|
330
370
|
|
|
331
|
-
onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
|
|
371
|
+
protected onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
|
|
332
372
|
var resJson = typeof resText == 'string' && ((resText.startsWith("{") && resText.endsWith("}")) || (resText.startsWith("[") && resText.endsWith("]"))) ? JSON.parse(resText) : resText
|
|
333
373
|
if (typeof resJson == "object") {
|
|
334
374
|
if (!resJson.status_code || this.onStatusCode(resJson.ok, resJson.status_code, resJson.message, resJson.result)) {
|
|
@@ -336,8 +376,8 @@ export default class ecurl {
|
|
|
336
376
|
if (onDone) onDone(resJson.result, resJson.message)
|
|
337
377
|
this.onDone(resJson.result, resJson.message)
|
|
338
378
|
} else {
|
|
339
|
-
if (onFailed) onFailed(resJson.message, false)
|
|
340
|
-
this.onFailed(resJson.message, false)
|
|
379
|
+
if (onFailed) onFailed(this.refineErrorMessage(resJson.message), false)
|
|
380
|
+
this.onFailed(this.refineErrorMessage(resJson.message), false)
|
|
341
381
|
}
|
|
342
382
|
}
|
|
343
383
|
} else {
|
|
@@ -348,17 +388,29 @@ export default class ecurl {
|
|
|
348
388
|
}
|
|
349
389
|
}
|
|
350
390
|
|
|
351
|
-
|
|
391
|
+
private refineErrorMessage(resText: string): string {
|
|
392
|
+
let out = resText
|
|
393
|
+
if (!esp.isDebug('')) {
|
|
394
|
+
if (resText.toLowerCase().includes('failed') || resText.toLowerCase().includes('code')) {
|
|
395
|
+
reportApiError(this.fetchConf.options, resText)
|
|
396
|
+
out = 'Terjadi kesalahan, biar ' + esp.appjson()?.expo?.name + ' bereskan, silahkan coba beberapa saat lagi.'
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return out
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
private onError(msg: string): void {
|
|
352
403
|
esp.log("\x1b[31m", msg)
|
|
353
404
|
esp.log("\x1b[0m")
|
|
354
405
|
if (esp.isDebug('') && msg == '') {
|
|
355
406
|
return
|
|
356
407
|
}
|
|
357
|
-
|
|
408
|
+
delete this.fetchConf.options.cancelToken
|
|
409
|
+
reportApiError(this.fetchConf.options, msg)
|
|
358
410
|
LibProgress.hide()
|
|
359
411
|
}
|
|
360
412
|
|
|
361
|
-
getTimeByTimeZone(timeZone: string): number {
|
|
413
|
+
protected getTimeByTimeZone(timeZone: string): number {
|
|
362
414
|
return moment(new Date()).tz(timeZone).toMiliseconds();
|
|
363
415
|
}
|
|
364
416
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
|
|
3
|
-
import { LibIcon, LibNavigation, LibProgress, LibStatusbar, LibStyle, LibTextstyle, LibToastProperty,
|
|
3
|
+
import { LibIcon, LibNavigation, LibProgress, LibStatusbar, LibStyle, LibTextstyle, LibToastProperty, useSafeState } from 'esoftplay';
|
|
4
4
|
import * as ImageManipulator from "expo-image-manipulator";
|
|
5
5
|
import React, { useEffect, useRef } from 'react';
|
|
6
6
|
import { Dimensions, Image, Text, TouchableOpacity, View } from 'react-native';
|
|
@@ -13,7 +13,7 @@ export interface LibImage_cropProps {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
export default function m(props: LibImage_cropProps): any {
|
|
16
|
-
const { image, ratio, forceCrop, message } =
|
|
16
|
+
const { image, ratio, forceCrop, message } = LibNavigation.getArgsAll(props)
|
|
17
17
|
const [_image, setImage] = useSafeState(image)
|
|
18
18
|
const [counter, setCounter] = useSafeState(0)
|
|
19
19
|
const [size, setSize] = useSafeState(LibStyle.width)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
|
|
3
|
-
import { LibIcon, LibLoading, LibNavigation, LibObject, LibStyle, LibTextstyle,
|
|
3
|
+
import { LibIcon, LibLoading, LibNavigation, LibObject, LibStyle, LibTextstyle, useSafeState } from 'esoftplay';
|
|
4
4
|
import * as MediaLibrary from 'expo-media-library';
|
|
5
5
|
import React, { useEffect } from 'react';
|
|
6
6
|
import { FlatList, Image, TouchableOpacity, View } from 'react-native';
|
|
@@ -30,7 +30,7 @@ export default function m(props: LibImage_multiProps): any {
|
|
|
30
30
|
const [photos, setPhotos] = useSafeState([])
|
|
31
31
|
const [after, setAfter] = useSafeState(null)
|
|
32
32
|
const [hasNextPage, setHasNextPage] = useSafeState(true)
|
|
33
|
-
const { max } =
|
|
33
|
+
const { max } = LibNavigation.getArgsAll(props)
|
|
34
34
|
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
MediaLibrary.getPermissionsAsync()
|
|
@@ -102,6 +102,7 @@ function unmask(name: string, text: string): string {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export default function m(props: LibInput_baseProps): any {
|
|
105
|
+
|
|
105
106
|
LibInput_base_dataProperty.inputBaseRef[props.name] = useRef<TextInput>(null);
|
|
106
107
|
LibInput_base_dataProperty.inputBaseData[props.name] = {
|
|
107
108
|
mask: props.mask,
|
|
@@ -109,6 +110,7 @@ export default function m(props: LibInput_baseProps): any {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
useEffect(() => {
|
|
113
|
+
console.warn('LibInput_base is deprecated, use LibInput with props `base={true}` instead')
|
|
112
114
|
LibInput_base_dataProperty.inputBaseRef[props.name].current!.blur()
|
|
113
115
|
if (props.defaultValue) {
|
|
114
116
|
setTimeout(() => {
|
package/modules/lib/list.tsx
CHANGED
|
@@ -73,7 +73,7 @@ export default class EList extends LibComponent<LibListProps, LibListState> {
|
|
|
73
73
|
render(): any {
|
|
74
74
|
const isStatic = () => {
|
|
75
75
|
if (this.props.staticHeight)
|
|
76
|
-
return { getItemLayout: (data, index) => this.props.staticHeight ? ({ length: this.props.staticHeight, offset: this.props.staticHeight, index: index }) : undefined }
|
|
76
|
+
return ({ getItemLayout: (data, index) => this.props.staticHeight ? ({ length: this.props.staticHeight, offset: this.props.staticHeight, index: index }) : undefined })
|
|
77
77
|
}
|
|
78
78
|
return (
|
|
79
79
|
<View ref={(e) => this.view = e} style={[{ flex: 1 }]} >
|
package/modules/lib/locale.ts
CHANGED
|
@@ -3,19 +3,16 @@
|
|
|
3
3
|
import { LibNavigation, useGlobalReturn, useGlobalState } from 'esoftplay';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
lang_id: "id"
|
|
8
|
-
}
|
|
9
|
-
const state = useGlobalState(initState, { persistKey: 'lib_locale' })
|
|
6
|
+
const state = useGlobalState("id", { persistKey: 'lib_locale_lang' })
|
|
10
7
|
|
|
11
|
-
export default class
|
|
8
|
+
export default class m {
|
|
12
9
|
|
|
13
10
|
static state(): useGlobalReturn<any> {
|
|
14
11
|
return state
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
static setLanguage(langId: string): void {
|
|
18
|
-
state.set({ lang_id: langId })
|
|
19
15
|
LibNavigation.reset()
|
|
16
|
+
state.set(langId)
|
|
20
17
|
}
|
|
21
18
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// noPage
|
|
3
3
|
|
|
4
4
|
import { CommonActions, StackActions } from '@react-navigation/native';
|
|
5
|
-
import { esp, LibNavigationRoutes,
|
|
5
|
+
import { esp, LibNavigationRoutes, UserClass, UserRoutes, _global } from 'esoftplay';
|
|
6
6
|
import React from "react";
|
|
7
7
|
|
|
8
8
|
export interface LibNavigationInjector {
|
|
@@ -22,6 +22,19 @@ export default (() => {
|
|
|
22
22
|
libNavigationData._navigation = nav
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
static getArgs(props: any, key: string, defOutput?: any): any {
|
|
26
|
+
if (defOutput == undefined) {
|
|
27
|
+
defOutput = "";
|
|
28
|
+
}
|
|
29
|
+
return props?.route?.params?.[key] || defOutput;
|
|
30
|
+
}
|
|
31
|
+
static getArgsAll<S>(props: any, defOutput?: any): S {
|
|
32
|
+
if (defOutput == undefined) {
|
|
33
|
+
defOutput = "";
|
|
34
|
+
}
|
|
35
|
+
return props?.route?.params || defOutput;
|
|
36
|
+
}
|
|
37
|
+
|
|
25
38
|
static navigation(): any {
|
|
26
39
|
return libNavigationData?._navigation
|
|
27
40
|
}
|
|
@@ -54,7 +67,7 @@ export default (() => {
|
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
static getResultKey(props: any): number {
|
|
57
|
-
return
|
|
70
|
+
return m.getArgs(props, "_senderKey", 0)
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
static cancelBackResult(key?: number): void {
|
package/modules/lib/progress.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// noPage
|
|
2
2
|
|
|
3
3
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
-
import { esp, LibComponent,
|
|
4
|
+
import { esp, LibComponent, LibNavigation, LibStyle } from "esoftplay";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { ActivityIndicator, View } from "react-native";
|
|
7
7
|
import { WebView } from 'react-native-webview';
|
|
@@ -47,7 +47,7 @@ export default class esocialLogin extends LibComponent<LibSocialloginProps, LibS
|
|
|
47
47
|
render(): any {
|
|
48
48
|
var { url, onResult } = this.props
|
|
49
49
|
if (!url) {
|
|
50
|
-
url =
|
|
50
|
+
url = LibNavigation.getArgs(this.props, "url");
|
|
51
51
|
}
|
|
52
52
|
return (
|
|
53
53
|
<View style={{ flex: 1 }} >
|
package/modules/lib/utils.ts
CHANGED
|
@@ -60,12 +60,14 @@ export default class eutils {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
static getArgs(props: any, key: string, defOutput?: any): any {
|
|
63
|
+
console.warn('LibUtils.getArgs is deprecated, use LibNavigation.getArgs instead')
|
|
63
64
|
if (defOutput == undefined) {
|
|
64
65
|
defOutput = "";
|
|
65
66
|
}
|
|
66
67
|
return props?.route?.params?.[key] || defOutput;
|
|
67
68
|
}
|
|
68
69
|
static getArgsAll<S>(props: any, defOutput?: any): S {
|
|
70
|
+
console.warn('LibUtils.getArgsAll is deprecated, use LibNavigation.getArgsAll instead')
|
|
69
71
|
if (defOutput == undefined) {
|
|
70
72
|
defOutput = "";
|
|
71
73
|
}
|
package/modules/lib/version.tsx
CHANGED
|
@@ -59,7 +59,7 @@ export default class m extends LibComponent<LibVersionProps, LibVersionState> {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
render(): any {
|
|
62
|
-
const { res: { title, version, android, ios }, msg } =
|
|
62
|
+
const { res: { title, version, android, ios }, msg } = LibNavigation.getArgsAll(this.props)
|
|
63
63
|
const link = Platform.OS == 'ios' ? ios : android
|
|
64
64
|
return (
|
|
65
65
|
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', borderStartColor: 'white', paddingHorizontal: 17 }} >
|
package/moment.ts
CHANGED
|
@@ -35,7 +35,7 @@ export default function moment(date?: string | Date | any) {
|
|
|
35
35
|
locale: (locale_id: "af" | "am" | "ar-dz" | "ar-kw" | "ar-ly" | "ar-ma" | "ar-sa" | "ar-tn" | "ar" | "az" | "be" | "bg" | "bi" | "bm" | "bn" | "bo" | "br" | "bs" | "ca" | "cs" | "cv" | "cy" | "da" | "de-at" | "de-ch" | "de" | "dv" | "el" | "en-au" | "en-ca" | "en-gb" | "en-ie" | "en-il" | "en-in" | "en-nz" | "en-sg" | "en-tt" | "en" | "eo" | "es-do" | "es-pr" | "es-us" | "es" | "fi" | "fo" | "fr-ca" | "fr-ch" | "fr" | "fy" | "ga" | "gd" | "gl" | "gom-latn" | "gu" | "he" | "hi" | "hr" | "ht" | "hu" | "hy-am" | "id" | "is" | "it-ch" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "lb" | "lo" | "lt" | "lv" | "me" | "mi" | "mk" | "ml" | "mn" | "mr" | "ms-my" | "ms" | "mt" | "my" | "nb" | "ne" | "nl-be" | "nl" | "nn" | "oc-lnc" | "pa-in" | "pl" | "pt-br" | "pt" | "ro" | "ru" | "rw" | "sd" | "se" | "si" | "sk" | "sl" | "sq" | "sr-cyrl" | "sr" | "ss" | "sv-fi" | "sv" | "sw" | "ta" | "te" | "tet" | "tg" | "th" | "tk" | "tl-ph" | "tlh" | "tr" | "tzl" | "tzm-latn" | "tzm" | "ug-cn" | "uk" | "ur" | "uz-latn" | "uz" | "vi" | "x-pseudo" | "yo" | "zh-cn" | "zh-hk" | "zh-tw" | "zh" | "et" | "eu" | "fa") => {
|
|
36
36
|
require('dayjs/locale/en')
|
|
37
37
|
require('dayjs/locale/id')
|
|
38
|
-
const out = dayjs.locale(
|
|
38
|
+
const out = dayjs.locale('id')
|
|
39
39
|
return moment(out)
|
|
40
40
|
},
|
|
41
41
|
/* last chain */
|
package/package.json
CHANGED
package/state.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
export default function m(def?: any) {
|
|
4
4
|
const r = useRef<boolean>(true)
|
|
@@ -9,7 +9,7 @@ export default function m(def?: any) {
|
|
|
9
9
|
b(value)
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
r.current = true
|
|
15
15
|
return () => { r.current = false }
|