esoftplay 0.0.121 → 0.0.122
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/_global.ts +2 -1
- package/bin/build.js +5 -3
- package/bin/cli.js +36 -61
- package/bin/router.js +20 -14
- package/esp.ts +46 -54
- package/global.ts +6 -6
- package/import_migrator.mjs +4 -3
- package/libs/worker.tsx +6 -2
- package/modules/lib/autoreload.ts +4 -4
- package/modules/lib/curl.ts +4 -6
- package/modules/lib/image_shadow.tsx +2 -1
- package/modules/lib/input.tsx +1 -0
- package/modules/lib/navigation.ts +49 -20
- package/modules/lib/notification.ts +2 -3
- package/modules/lib/notify.ts +1 -0
- package/modules/lib/picture.tsx +4 -3
- package/modules/lib/style.ts +19 -19
- package/modules/lib/tabs.tsx +1 -1
- package/modules/lib/utils.ts +12 -15
- package/modules/use/form.ts +1 -2
- package/modules/user/class.ts +13 -5
- package/modules/user/data.ts +1 -1
- package/modules/user/index.tsx +2 -11
- package/package.json +1 -1
- package/storage.ts +9 -20
package/_global.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const x: any = {}
|
|
2
|
+
export default x
|
package/bin/build.js
CHANGED
|
@@ -249,12 +249,14 @@ yarn-error.log\n\
|
|
|
249
249
|
import { LibNotification } from 'esoftplay/cache/lib/notification/import';
|
|
250
250
|
import { UserIndex } from 'esoftplay/cache/user/index/import';
|
|
251
251
|
import * as ErrorReport from 'esoftplay/error';
|
|
252
|
+
import { globalIdx } from 'esoftplay/global';
|
|
252
253
|
import * as Notifications from 'expo-notifications';
|
|
253
254
|
import React, { useEffect } from 'react';
|
|
254
255
|
import { enableFreeze, enableScreens } from 'react-native-screens';
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
|
|
257
|
+
enableFreeze()
|
|
258
|
+
enableScreens()
|
|
259
|
+
|
|
258
260
|
|
|
259
261
|
Notifications.addNotificationResponseReceivedListener(x => LibNotification.onAction(x));
|
|
260
262
|
|
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const exec = require('child_process').execSync;
|
|
4
|
+
const execAsync = require('child_process').exec;
|
|
4
5
|
const path = require('path');
|
|
5
6
|
const os = require('os')
|
|
6
7
|
const readline = require('readline');
|
|
@@ -63,6 +64,14 @@ switch (args[0]) {
|
|
|
63
64
|
case "build":
|
|
64
65
|
build()
|
|
65
66
|
break;
|
|
67
|
+
case "bc":
|
|
68
|
+
case "build-cancel":
|
|
69
|
+
buildPrepare(false)
|
|
70
|
+
break;
|
|
71
|
+
case "bp":
|
|
72
|
+
case "build-prepare":
|
|
73
|
+
buildPrepare(true)
|
|
74
|
+
break;
|
|
66
75
|
case "vn":
|
|
67
76
|
case "version-new":
|
|
68
77
|
incrementVersion()
|
|
@@ -643,57 +652,31 @@ function devClientPos(file) {
|
|
|
643
652
|
}
|
|
644
653
|
}
|
|
645
654
|
|
|
646
|
-
function
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
// let file = fs.readFileSync(`./modules/${module}/${task}`, { encoding: 'utf8' }).replace(/esoftplay\/cache/g, "../../esoftplay/cache")
|
|
672
|
-
// fs.writeFileSync(`./modules/${module}/${task}`, file, { encoding: 'utf8' })
|
|
673
|
-
// })
|
|
674
|
-
// })
|
|
675
|
-
// }
|
|
676
|
-
// if (fs.existsSync('./esoftplay/cache')) {
|
|
677
|
-
// fs.readdirSync('./esoftplay/cache').forEach((module) => {
|
|
678
|
-
// if (!module.startsWith('.'))
|
|
679
|
-
// if (fs.lstatSync('./esoftplay/cache/' + module).isDirectory()) {
|
|
680
|
-
// fs.readdirSync('./esoftplay/cache/' + module).forEach((task) => {
|
|
681
|
-
// fs.readdirSync(`./esoftplay/cache/${module}/${task}`).forEach((imprt) => {
|
|
682
|
-
// console.log(`./esoftplay/cache/${module}/${task}/import.js`)
|
|
683
|
-
// let file = fs.readFileSync(`./esoftplay/cache/${module}/${task}/import.js`, { encoding: 'utf8' }).replace(/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\//g, "../../../../")
|
|
684
|
-
// file = file.replace(/\.\.\/\.\.\/\.\.\/\.\.\/node_modules\/esoftplay\//g, "../../../")
|
|
685
|
-
// fs.writeFileSync(`./esoftplay/cache/${module}/${task}/import.js`, file, { encoding: 'utf8' })
|
|
686
|
-
// })
|
|
687
|
-
// })
|
|
688
|
-
// }
|
|
689
|
-
// })
|
|
690
|
-
// }
|
|
691
|
-
|
|
692
|
-
// } else {
|
|
693
|
-
// command('rm -rf ./esoftplay')
|
|
694
|
-
// command('rm -rf ./modules')
|
|
695
|
-
// command('mv ./modules_ori ./modules')
|
|
696
|
-
// }
|
|
655
|
+
function buildPrepare(include = true) {
|
|
656
|
+
if (include) {
|
|
657
|
+
if (!fs.existsSync('./assets/esoftplaymodules')) {
|
|
658
|
+
fs.mkdirSync('./assets/esoftplaymodules')
|
|
659
|
+
command('cp -r ./modules/* ./assets/esoftplaymodules')
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (fs.existsSync('./node_modules/esoftplay/modules')) {
|
|
663
|
+
let comm = []
|
|
664
|
+
fs.readdirSync('./node_modules/esoftplay/modules').forEach((module) => {
|
|
665
|
+
if (!module.startsWith('.')) {
|
|
666
|
+
if (!fs.existsSync(`./modules/${module}`)) {
|
|
667
|
+
fs.mkdirSync(`./modules/${module}`)
|
|
668
|
+
}
|
|
669
|
+
comm.push(`cp -n ./node_modules/esoftplay/modules/${module}/* ./modules/${module}`)
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
consoleSucces("\n\nPLEASE COPY AND EXECUTE THE FOLLOWING COMMAND\n\n" + comm.join('\n') + "\n")
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
if (fs.existsSync('./assets/esoftplaymodules'))
|
|
676
|
+
command('rm -rf modules && mv ./assets/esoftplaymodules modules')
|
|
677
|
+
else
|
|
678
|
+
consoleError('')
|
|
679
|
+
}
|
|
697
680
|
}
|
|
698
681
|
|
|
699
682
|
function configAvailable(enabled) {
|
|
@@ -742,7 +725,6 @@ function build() {
|
|
|
742
725
|
name: "1. IOS (Development) - Simulator",
|
|
743
726
|
cmd: "eas build --platform ios --profile development",
|
|
744
727
|
pre: () => {
|
|
745
|
-
cacheBuild()
|
|
746
728
|
configAvailable(true)
|
|
747
729
|
devClientPre(appjson)
|
|
748
730
|
jsEng(appjson, false)
|
|
@@ -755,7 +737,6 @@ function build() {
|
|
|
755
737
|
name: "2. IOS (Preview) - Simulator",
|
|
756
738
|
cmd: "eas build --platform ios --profile preview",
|
|
757
739
|
pre: () => {
|
|
758
|
-
cacheBuild()
|
|
759
740
|
configAvailable(true)
|
|
760
741
|
devClientPos(appjson)
|
|
761
742
|
jsEng(appjson, true)
|
|
@@ -768,7 +749,6 @@ function build() {
|
|
|
768
749
|
name: "3. IOS (Preview) - Non Simulator",
|
|
769
750
|
cmd: "eas build --platform ios --profile preview_build",
|
|
770
751
|
pre: () => {
|
|
771
|
-
cacheBuild()
|
|
772
752
|
configAvailable(true)
|
|
773
753
|
devClientPos(appjson)
|
|
774
754
|
jsEng(appjson, true)
|
|
@@ -781,7 +761,6 @@ function build() {
|
|
|
781
761
|
name: "4. IOS (Production) - ipa",
|
|
782
762
|
cmd: "eas build --platform ios --profile production",
|
|
783
763
|
pre: () => {
|
|
784
|
-
cacheBuild()
|
|
785
764
|
configAvailable(true)
|
|
786
765
|
devClientPos(appjson)
|
|
787
766
|
jsEng(appjson, true)
|
|
@@ -794,7 +773,6 @@ function build() {
|
|
|
794
773
|
name: "5. Android (Development) - apk",
|
|
795
774
|
cmd: "eas build --platform android --profile development",
|
|
796
775
|
pre: () => {
|
|
797
|
-
cacheBuild()
|
|
798
776
|
configAvailable(true)
|
|
799
777
|
devClientPre(appjson)
|
|
800
778
|
jsEng(appjson, false)
|
|
@@ -807,7 +785,6 @@ function build() {
|
|
|
807
785
|
name: "6. Android (Preview) - apk",
|
|
808
786
|
cmd: "eas build --platform android --profile preview",
|
|
809
787
|
pre: () => {
|
|
810
|
-
cacheBuild()
|
|
811
788
|
configAvailable(true)
|
|
812
789
|
devClientPos(appjson)
|
|
813
790
|
jsEng(appjson, true)
|
|
@@ -820,7 +797,6 @@ function build() {
|
|
|
820
797
|
name: "7. Android (Production) - aab",
|
|
821
798
|
cmd: "eas build --platform android --profile production",
|
|
822
799
|
pre: () => {
|
|
823
|
-
cacheBuild()
|
|
824
800
|
configAvailable(true)
|
|
825
801
|
devClientPos(appjson)
|
|
826
802
|
jsEng(appjson, true)
|
|
@@ -850,15 +826,12 @@ function build() {
|
|
|
850
826
|
if (pre) pre()
|
|
851
827
|
consoleSucces("⚙⚙⚙ ... \n" + cmd)
|
|
852
828
|
command(cmd)
|
|
853
|
-
cacheBuild(false)
|
|
854
829
|
configAvailable(false)
|
|
855
830
|
devClientPos(appjson)
|
|
856
831
|
} else if (d === false) {
|
|
857
832
|
consoleError("Build Canceled")
|
|
858
|
-
cacheBuild(false)
|
|
859
833
|
} else {
|
|
860
834
|
consoleError("Build type tidak ditemukan")
|
|
861
|
-
cacheBuild(false)
|
|
862
835
|
}
|
|
863
836
|
});
|
|
864
837
|
|
|
@@ -961,6 +934,8 @@ function help() {
|
|
|
961
934
|
"\n - u|update all : untuk update semua esp module ke versi terakhir",
|
|
962
935
|
"\n - start : start esoftplay framework",
|
|
963
936
|
"\n - b|build : untuk build app .ipa .apk .aab",
|
|
937
|
+
"\n - bp|build-prepare : untuk prepare for esp b",
|
|
938
|
+
"\n - bc|build-cancel : untuk cancel build prepare",
|
|
964
939
|
"\n - f|file : untuk check status file",
|
|
965
940
|
"\n - c|check : untuk check status",
|
|
966
941
|
"\n - create-master [moduleName] : untuk create master module terpisah",
|
package/bin/router.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
/* EXECUTED ON `ESP START` TO BUILD FILE CACHES */
|
|
4
|
-
const { execSync } = require('child_process');
|
|
5
4
|
const fs = require('fs');
|
|
6
5
|
var checks = ['./node_modules/esoftplay/modules/', './modules/', './templates/'];
|
|
7
6
|
var pathAsset = "./assets";
|
|
@@ -66,21 +65,25 @@ var tmpExp = ["LibCrypt"]; // nama2 class yang tidak perlu dibuat
|
|
|
66
65
|
var Nav5 = (importer, navs) => {
|
|
67
66
|
return (`
|
|
68
67
|
// @ts-nocheck
|
|
69
|
-
import React from 'react';
|
|
68
|
+
import React, { useEffect } from 'react';
|
|
70
69
|
import { NavigationContainer } from '@react-navigation/native';
|
|
71
70
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
72
|
-
\nimport {
|
|
71
|
+
\nimport { _global } from "esoftplay";\n
|
|
72
|
+
\nimport useGlobalState from "esoftplay/global";\n
|
|
73
73
|
${importer}
|
|
74
|
-
\nimport { LibNavigation } from 'esoftplay/cache/lib/navigation/import';\n
|
|
75
74
|
const Stack = createNativeStackNavigator();
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
const config = require('../../../config.json')
|
|
77
|
+
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
|
|
78
|
+
|
|
79
|
+
export default function m(props): any {
|
|
80
|
+
const { user, initialState, handler } = props
|
|
81
|
+
const econf = config.config
|
|
82
|
+
const [s] = LibNavigation.state().useState()
|
|
83
|
+
const appOrientation = econf?.orientation ? String(econf.orientation) : 'portrait'
|
|
84
|
+
return (
|
|
85
|
+
<NavigationContainer
|
|
86
|
+
ref={(r) => LibNavigation.setRef(r)}
|
|
84
87
|
initialState={initialState}
|
|
85
88
|
onReady={() => { _global.NavsIsReady = true }}
|
|
86
89
|
onStateChange={handler} >
|
|
@@ -387,7 +390,7 @@ import { AntDesignTypes, EntypoTypes, EvilIconsTypes, FeatherTypes, FontAwesomeT
|
|
|
387
390
|
|
|
388
391
|
declare module "esoftplay" {
|
|
389
392
|
var _global: any;
|
|
390
|
-
|
|
393
|
+
function useGlobalState<S>(initialState?: S, option?: useGlobalOption): useGlobalReturn<S>;
|
|
391
394
|
function usePersistState<S>(key: string, initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined, (a?: (x: S) => void) => void, () => void];
|
|
392
395
|
function useSafeState<S>(initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined];
|
|
393
396
|
function applyStyle<T>(style: T): T;
|
|
@@ -716,15 +719,18 @@ function createRouter() {
|
|
|
716
719
|
});
|
|
717
720
|
let importer = []
|
|
718
721
|
let screens = []
|
|
722
|
+
|
|
719
723
|
Navigations.forEach((nav) => {
|
|
724
|
+
const prefix = "{s['" + nav + "'] && "
|
|
725
|
+
const suffix = "}"
|
|
720
726
|
const orientation = NavsOrientation[nav]
|
|
721
727
|
const [module, task] = nav.split('/')
|
|
722
728
|
const comp = ucword(module) + ucword(task)
|
|
723
729
|
importer.push(`import { ${comp} } from ${'"esoftplay/cache/' + module + '/' + task + '/import"'}`)
|
|
724
730
|
if (orientation)
|
|
725
|
-
screens.push("\t\t\t\t<Stack.Screen name={\"" + nav + "\"} options={{ orientation: '" + orientation + "' }} component={" + comp + "} />")
|
|
731
|
+
screens.push("\t\t\t\t" + prefix + "<Stack.Screen name={\"" + nav + "\"} options={{ orientation: '" + orientation + "' }} component={" + comp + "} />" + suffix)
|
|
726
732
|
else
|
|
727
|
-
screens.push("\t\t\t\t<Stack.Screen name={\"" + nav + "\"} component={" + comp + "} />")
|
|
733
|
+
screens.push("\t\t\t\t" + prefix + "<Stack.Screen name={\"" + nav + "\"} component={" + comp + "} />" + suffix)
|
|
728
734
|
})
|
|
729
735
|
|
|
730
736
|
let N = Nav5(importer.join("\n"), screens.join("\n"))
|
package/esp.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UserRoutes } from 'esoftplay/cache/user/routes/import';
|
|
3
|
-
import Constants from 'expo-constants';
|
|
4
|
-
import { LogBox, Platform } from 'react-native';
|
|
1
|
+
import { LogBox } from 'react-native';
|
|
5
2
|
import 'react-native-reanimated';
|
|
6
|
-
import _assets from './cache/assets';
|
|
7
|
-
import navs from './cache/navigations';
|
|
8
|
-
import properties from './cache/properties';
|
|
9
|
-
import routers from './cache/routers';
|
|
10
|
-
|
|
11
3
|
import './oneplusfixfont';
|
|
4
|
+
|
|
12
5
|
const ignoreWarns = [
|
|
13
6
|
"Setting a timer for a long period of time",
|
|
14
7
|
"VirtualizedLists should never be nested inside plain ScrollViews with the same orientation",
|
|
@@ -48,8 +41,8 @@ try {
|
|
|
48
41
|
|
|
49
42
|
}
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
const esp = {
|
|
45
|
+
mergeDeep(target: any, ...sources: any[]) {
|
|
53
46
|
target = Object(target);
|
|
54
47
|
for (let source of sources) {
|
|
55
48
|
source = Object(source);
|
|
@@ -64,21 +57,20 @@ export default class esp {
|
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
59
|
return target;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static appjson(): any {
|
|
60
|
+
},
|
|
61
|
+
appjson(): any {
|
|
70
62
|
return esp.mergeDeep(app, conf)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
},
|
|
64
|
+
assets(path: string): any {
|
|
65
|
+
const _assets = require('./cache/assets')
|
|
74
66
|
return _assets(path)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
},
|
|
68
|
+
versionName(): string {
|
|
69
|
+
const Platform = require('react-native').Platform
|
|
70
|
+
const Constants = require('expo-constants').default
|
|
78
71
|
return (Platform.OS == 'android' ? Constants?.manifest?.android?.versionCode : Constants?.manifest?.ios?.buildNumber) + '-' + esp.config('publish_id')
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static config(param?: string, ...params: string[]): any {
|
|
72
|
+
},
|
|
73
|
+
config(param?: string, ...params: string[]): any {
|
|
82
74
|
let out: any = esp._config();
|
|
83
75
|
if (param) {
|
|
84
76
|
var _params = [param, ...params]
|
|
@@ -93,16 +85,14 @@ export default class esp {
|
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
87
|
return out;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static isDebug(message: string): boolean {
|
|
88
|
+
},
|
|
89
|
+
isDebug(message: string): boolean {
|
|
99
90
|
if (!lconf) {
|
|
100
91
|
return false
|
|
101
92
|
}
|
|
102
93
|
return conf.config.domain != lconf.config.domain
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
static readDeepObj(obj: any) {
|
|
94
|
+
},
|
|
95
|
+
readDeepObj(obj: any) {
|
|
106
96
|
return function (param?: string, ...params: string[]): any {
|
|
107
97
|
let out: any = obj
|
|
108
98
|
if (param) {
|
|
@@ -117,9 +107,8 @@ export default class esp {
|
|
|
117
107
|
}
|
|
118
108
|
return out;
|
|
119
109
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
static lang(moduleTask: string, langName: string, ...stringToBe: string[]): string {
|
|
110
|
+
},
|
|
111
|
+
lang(moduleTask: string, langName: string, ...stringToBe: string[]): string {
|
|
123
112
|
let string = esp.assets("locale/" + esp.langId() + ".json")?.[moduleTask]?.[langName]
|
|
124
113
|
if (!string) {
|
|
125
114
|
string = esp.assets("locale/id.json")[moduleTask][langName]
|
|
@@ -137,28 +126,28 @@ export default class esp {
|
|
|
137
126
|
string = sprintf(string, 0)
|
|
138
127
|
}
|
|
139
128
|
return string
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
129
|
+
},
|
|
130
|
+
langId(): string {
|
|
131
|
+
const LibLocale = esp.mod('lib/locale');
|
|
143
132
|
return LibLocale.state().get()
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
static mod(path: string): any {
|
|
133
|
+
},
|
|
134
|
+
mod(path: string): any {
|
|
147
135
|
var modtast = path.split("/");
|
|
148
136
|
if (modtast[1] == "") {
|
|
149
137
|
modtast[1] = "index";
|
|
150
138
|
}
|
|
139
|
+
const routers = require('./cache/routers')
|
|
151
140
|
return routers(modtast.join("/"));
|
|
152
|
-
}
|
|
153
|
-
|
|
141
|
+
},
|
|
142
|
+
modProp(path: string): any {
|
|
154
143
|
var modtast = path.split("/");
|
|
155
144
|
if (modtast[1] == "") {
|
|
156
145
|
modtast[1] = "index";
|
|
157
146
|
}
|
|
147
|
+
const properties = require('./cache/properties')
|
|
158
148
|
return properties(modtast.join("/"));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
static _config(): string {
|
|
149
|
+
},
|
|
150
|
+
_config(): string {
|
|
162
151
|
app = esp.mergeDeep(app, conf)
|
|
163
152
|
var msg = ''
|
|
164
153
|
if (!app.hasOwnProperty('config')) {
|
|
@@ -201,23 +190,24 @@ export default class esp {
|
|
|
201
190
|
config.webviewOpen = '<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="' + config.content + 'user/editor_css" rel="stylesheet" /> <script type="text/javascript">var _ROOT="' + config.uri + '";var _URL="' + config.content + '";function _Bbc(a,b){var c="BS3load_func";if(!window[c+"i"]){window[c+"i"]=0};window[c+"i"]++;if(!b){b=c+"i"+window[c+"i"]};if(!window[c]){window[c]=b}else{window[c]+=","+b}window[b]=a;if(typeof BS3!="undefined"){window[b](BS3)}};</script> <style type="text/css">body {padding: 0 20px;}</style></head> <body>';
|
|
202
191
|
config.webviewClose = '<script src="' + config.content + 'templates/admin/bootstrap/js/bootstrap.min.js"></script> </body> </html>';
|
|
203
192
|
return config;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
193
|
+
},
|
|
194
|
+
navigations(): string[] {
|
|
195
|
+
const navs = require('./cache/navs').default
|
|
207
196
|
return navs;
|
|
208
|
-
}
|
|
209
|
-
|
|
197
|
+
},
|
|
198
|
+
home(): any {
|
|
210
199
|
return esp.mod('user/index');
|
|
211
|
-
}
|
|
212
|
-
|
|
200
|
+
},
|
|
201
|
+
routes(): any {
|
|
202
|
+
const UserRoutes = esp.mod('user/routes');
|
|
213
203
|
return UserRoutes.state().get();
|
|
214
|
-
}
|
|
215
|
-
|
|
204
|
+
},
|
|
205
|
+
log(message?: any, ...optionalParams: any[]) {
|
|
216
206
|
if (esp.config("isDebug") == 1) {
|
|
217
207
|
console.log(message, ...optionalParams, "\x1b[0m");
|
|
218
208
|
}
|
|
219
|
-
}
|
|
220
|
-
|
|
209
|
+
},
|
|
210
|
+
logColor: {
|
|
221
211
|
reset: "\x1b[0m",
|
|
222
212
|
black: "\x1b[30m",
|
|
223
213
|
red: "\x1b[31m",
|
|
@@ -238,6 +228,8 @@ export default class esp {
|
|
|
238
228
|
}
|
|
239
229
|
}
|
|
240
230
|
|
|
231
|
+
export default esp
|
|
232
|
+
|
|
241
233
|
// var a = esp.assets("bacground") // mengambil file dari folder images
|
|
242
234
|
// var b = esp.config("data", "name") // mengambil value dari config (bisa ditentukan di app.json)
|
|
243
235
|
// var c = esp.mod("module/task") // mengeksekusi module/task
|
package/global.ts
CHANGED
|
@@ -29,17 +29,17 @@ export interface useGlobalConnect<T> {
|
|
|
29
29
|
_global.useGlobalUserDelete = {}
|
|
30
30
|
_global.useGlobalSubscriber = {}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
idx
|
|
34
|
-
increment
|
|
35
|
-
reset
|
|
32
|
+
const Context = {
|
|
33
|
+
idx: 0,
|
|
34
|
+
increment: function () { this.idx++ },
|
|
35
|
+
reset: function () {
|
|
36
36
|
this.idx = 0
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export const globalIdx =
|
|
40
|
+
export const globalIdx = Context
|
|
41
41
|
export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
|
|
42
|
-
const STORAGE = o?.inFile ?
|
|
42
|
+
const STORAGE = o?.inFile ? Storage : AsyncStorage
|
|
43
43
|
const _idx = o?.persistKey || globalIdx.idx
|
|
44
44
|
if (!_global.useGlobalSubscriber[_idx])
|
|
45
45
|
_global.useGlobalSubscriber[_idx] = [];
|
package/import_migrator.mjs
CHANGED
|
@@ -34,9 +34,10 @@ if (fs.existsSync('./modules')) {
|
|
|
34
34
|
})
|
|
35
35
|
}
|
|
36
36
|
dFile = dFile.replace(cmatch, "\nimport { " + espMod.join(", ") + " } from 'esoftplay';\n" + adder)
|
|
37
|
-
if (matchGlobal)
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
// if (matchGlobal) {
|
|
38
|
+
// dFile = dFile.replace(matchGlobal, "")
|
|
39
|
+
// dFile = dFile.replace("\n", "\nimport useGlobalState from 'esoftplay/global';\n")
|
|
40
|
+
// }
|
|
40
41
|
fs.writeFileSync('./modules/' + module + '/' + task, dFile, { encoding: 'utf8' })
|
|
41
42
|
}
|
|
42
43
|
})
|
package/libs/worker.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { esp } from "esoftplay";
|
|
2
|
-
import
|
|
2
|
+
import _global from "esoftplay/_global";
|
|
3
|
+
import React, { useRef } from "react";
|
|
3
4
|
import { Platform, View } from 'react-native';
|
|
4
5
|
import WebView from "react-native-webview";
|
|
5
|
-
const _global = require('../_global').default
|
|
6
6
|
|
|
7
7
|
_global.WorkerBase = React.createRef()
|
|
8
8
|
_global.WorkerTasks = new Map()
|
|
@@ -14,6 +14,10 @@ const Worker = {
|
|
|
14
14
|
delete(taskId: string) {
|
|
15
15
|
_global.WorkerTasks.delete(taskId)
|
|
16
16
|
},
|
|
17
|
+
useWorker(name: string, func: (...fparams: any[]) => Promise<any>): (params: any[], res: (data: any) => void) => void {
|
|
18
|
+
const ref = useRef(Worker.registerJobAsync(name, func)).current
|
|
19
|
+
return ref
|
|
20
|
+
},
|
|
17
21
|
registerJob(name: string, func: Function): (params: any[], res: (data: any) => void) => void {
|
|
18
22
|
'show source';
|
|
19
23
|
const x = func.toString().replace('function', 'function ' + name)
|
|
@@ -4,8 +4,8 @@ import { InteractionManager } from 'react-native'
|
|
|
4
4
|
|
|
5
5
|
export default (() => {
|
|
6
6
|
let updater = undefined
|
|
7
|
-
return
|
|
8
|
-
|
|
7
|
+
return {
|
|
8
|
+
set(callback: () => void, duration?: number): void {
|
|
9
9
|
if (updater != undefined) {
|
|
10
10
|
clearInterval(updater)
|
|
11
11
|
updater = undefined
|
|
@@ -15,8 +15,8 @@ export default (() => {
|
|
|
15
15
|
callback()
|
|
16
16
|
});
|
|
17
17
|
}, duration || 6000)
|
|
18
|
-
}
|
|
19
|
-
|
|
18
|
+
},
|
|
19
|
+
clear(): void {
|
|
20
20
|
if (updater != undefined) {
|
|
21
21
|
clearInterval(updater)
|
|
22
22
|
updater = undefined
|
package/modules/lib/curl.ts
CHANGED
|
@@ -9,7 +9,7 @@ import esp from 'esoftplay/esp';
|
|
|
9
9
|
import { reportApiError } from "esoftplay/error";
|
|
10
10
|
import Constants from 'expo-constants';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
//api_logger_import
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
const { manifest } = Constants;
|
|
@@ -350,14 +350,11 @@ export default class m {
|
|
|
350
350
|
mode: "cors",
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
|
|
354
|
-
LogStateProperty.doLogCurl(this.uri, this.url, post, this.isSecure)
|
|
355
|
-
}
|
|
356
|
-
|
|
353
|
+
|
|
357
354
|
this.initTimeout(upload ? 120000 : this.timeout)
|
|
358
355
|
if (debug == 1) esp.log(this.url + this.uri, options)
|
|
359
356
|
this.fetchConf = { url: this.url + this.uri, options: options }
|
|
360
|
-
|
|
357
|
+
//api_logger_init_time
|
|
361
358
|
fetch(this.url + this.uri, options).then(async (res) => {
|
|
362
359
|
this.cancelTimeout()
|
|
363
360
|
this.resStatus = res.status
|
|
@@ -366,6 +363,7 @@ export default class m {
|
|
|
366
363
|
if (onFailed) onFailed({ message: "Koneksi internet kamu tidak stabil, silahkan coba lagi" }, false)
|
|
367
364
|
return
|
|
368
365
|
}
|
|
366
|
+
//api_logger
|
|
369
367
|
this.onFetched(resText, onDone, onFailed, debug)
|
|
370
368
|
}).catch((r) => {
|
|
371
369
|
// if (this.maxRetry > 0) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
import { LibPicture } from 'esoftplay/cache/lib/picture/import';
|
|
3
|
+
import esp from 'esoftplay/esp';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { Image, ImageStyle, View } from 'react-native';
|
|
5
6
|
|
|
@@ -22,7 +23,7 @@ export default function m(props: LibImage_shadowProps): any {
|
|
|
22
23
|
<View style={{ ...props.style, height: Number(height) + extra_height, width, backgroundColor: 'orange' }} >
|
|
23
24
|
<Image source={props.source} blurRadius={props.blurRadius || 8} style={{ height, width, ...props.style, marginTop: extra_height }} />
|
|
24
25
|
<View style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: 0.55 * width, width }} >
|
|
25
|
-
<LibPicture source={
|
|
26
|
+
<LibPicture source={esp.mod('blur.png')} style={{ width: '100%', height: '100%' }} />
|
|
26
27
|
</View>
|
|
27
28
|
<LibPicture source={props.source} style={{ height, width, ...props.style, position: 'absolute' }} />
|
|
28
29
|
</View>
|
package/modules/lib/input.tsx
CHANGED
|
@@ -222,6 +222,7 @@ export default class m extends LibComponent<LibInputProps, LibInputState>{
|
|
|
222
222
|
allowFontScaling={false}
|
|
223
223
|
{...this.props}
|
|
224
224
|
style={[{
|
|
225
|
+
outlineWidth: 0,
|
|
225
226
|
paddingVertical: 8,
|
|
226
227
|
marginBottom: 2,
|
|
227
228
|
paddingRight: suffix ? (suffix.length * 14) : 0,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// noPage
|
|
2
2
|
import { CommonActions, StackActions } from '@react-navigation/native';
|
|
3
|
-
import { LibNavigationRoutes } from 'esoftplay';
|
|
3
|
+
import { LibNavigationRoutes, useGlobalReturn } from 'esoftplay';
|
|
4
4
|
import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
5
5
|
import { UserRoutes } from 'esoftplay/cache/user/routes/import';
|
|
6
6
|
import esp from 'esoftplay/esp';
|
|
7
|
+
import useGlobalState from 'esoftplay/global';
|
|
7
8
|
import _global from 'esoftplay/_global';
|
|
8
9
|
import React from "react";
|
|
9
10
|
|
|
@@ -12,6 +13,22 @@ export interface LibNavigationInjector {
|
|
|
12
13
|
children?: any
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
|
|
17
|
+
export const state = useGlobalState({ 'bigbang/index': true })
|
|
18
|
+
function openNav(route: string, fun: Function) {
|
|
19
|
+
state.set(Object.assign({}, state.get(), { [route]: true }))
|
|
20
|
+
const open = () => {
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
if (state.get()[route]) {
|
|
23
|
+
fun()
|
|
24
|
+
} else {
|
|
25
|
+
open()
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
open()
|
|
30
|
+
}
|
|
31
|
+
|
|
15
32
|
export default (() => {
|
|
16
33
|
let libNavigationData: any = {}
|
|
17
34
|
let libNavigationRedirect: any = {}
|
|
@@ -20,6 +37,10 @@ export default (() => {
|
|
|
20
37
|
_global.libNavigationRef = ref
|
|
21
38
|
}
|
|
22
39
|
|
|
40
|
+
static state(): useGlobalReturn<any> {
|
|
41
|
+
return state
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
static setNavigation(nav: any): void {
|
|
24
45
|
libNavigationData._navigation = nav
|
|
25
46
|
}
|
|
@@ -65,7 +86,9 @@ export default (() => {
|
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
static navigate<S>(route: LibNavigationRoutes, params?: S): void {
|
|
68
|
-
|
|
89
|
+
openNav(route, () => {
|
|
90
|
+
_global.libNavigationRef?.navigate?.(route, params)
|
|
91
|
+
})
|
|
69
92
|
}
|
|
70
93
|
|
|
71
94
|
static getResultKey(props: any): number {
|
|
@@ -106,34 +129,40 @@ export default (() => {
|
|
|
106
129
|
r(value)
|
|
107
130
|
};
|
|
108
131
|
}
|
|
109
|
-
|
|
132
|
+
openNav(route, () => {
|
|
133
|
+
m.push(route, params)
|
|
134
|
+
})
|
|
110
135
|
})
|
|
111
136
|
}
|
|
112
137
|
|
|
113
|
-
static replace<S>(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
static replace<S>(route: LibNavigationRoutes, params?: S): void {
|
|
139
|
+
openNav(route, () => {
|
|
140
|
+
_global.libNavigationRef.dispatch(
|
|
141
|
+
StackActions.replace(route, params)
|
|
142
|
+
)
|
|
143
|
+
})
|
|
117
144
|
}
|
|
118
145
|
|
|
119
|
-
static push<S>(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
static push<S>(route: LibNavigationRoutes, params?: S): void {
|
|
147
|
+
openNav(route, () => {
|
|
148
|
+
_global.libNavigationRef?.dispatch?.(
|
|
149
|
+
StackActions.push(
|
|
150
|
+
route,
|
|
151
|
+
params
|
|
152
|
+
)
|
|
124
153
|
)
|
|
125
|
-
)
|
|
154
|
+
})
|
|
126
155
|
}
|
|
127
156
|
|
|
128
|
-
static reset(
|
|
157
|
+
static reset(route?: LibNavigationRoutes, ...routes: LibNavigationRoutes[]): void {
|
|
129
158
|
const user = UserClass.state().get()
|
|
130
|
-
let
|
|
131
|
-
if (
|
|
132
|
-
|
|
159
|
+
let _route = [route || esp.config('home', (user && (user.id || user.user_id)) ? 'member' : 'public')]
|
|
160
|
+
if (routes && routes.length > 0) {
|
|
161
|
+
_route = [..._route, ...routes]
|
|
133
162
|
}
|
|
134
163
|
const resetAction = CommonActions.reset({
|
|
135
|
-
index:
|
|
136
|
-
routes:
|
|
164
|
+
index: _route.length - 1,
|
|
165
|
+
routes: _route.map((rn) => ({ name: rn }))
|
|
137
166
|
});
|
|
138
167
|
_global.libNavigationRef?.dispatch?.(resetAction);
|
|
139
168
|
}
|
|
@@ -144,7 +173,7 @@ export default (() => {
|
|
|
144
173
|
_global.libNavigationRef?.dispatch?.(popAction)
|
|
145
174
|
}
|
|
146
175
|
|
|
147
|
-
/* return `root` on initialRoute otherwise return the
|
|
176
|
+
/* return `root` on initialRoute otherwise return the route was active */
|
|
148
177
|
static getCurrentRouteName(): string {
|
|
149
178
|
return UserRoutes.getCurrentRouteName()
|
|
150
179
|
}
|
|
@@ -8,14 +8,13 @@ import { LibObject } from 'esoftplay/cache/lib/object/import';
|
|
|
8
8
|
import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
9
9
|
import { UserNotification } from 'esoftplay/cache/user/notification/import';
|
|
10
10
|
import esp from 'esoftplay/esp';
|
|
11
|
+
import { fastFilter } from "esoftplay/fast";
|
|
11
12
|
import useGlobalState from 'esoftplay/global';
|
|
13
|
+
import moment from 'esoftplay/moment';
|
|
12
14
|
import _global from 'esoftplay/_global';
|
|
13
|
-
|
|
14
|
-
import { fastFilter } from "esoftplay/fast";
|
|
15
15
|
import Constants from 'expo-constants';
|
|
16
16
|
import * as Notifications from 'expo-notifications';
|
|
17
17
|
import { Alert, Linking, Platform } from "react-native";
|
|
18
|
-
import moment from '../../moment';
|
|
19
18
|
/*
|
|
20
19
|
{
|
|
21
20
|
to: // exp token
|
package/modules/lib/notify.ts
CHANGED
package/modules/lib/picture.tsx
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { esp, useSafeState } from 'esoftplay';
|
|
4
4
|
import { LibStyle } from 'esoftplay/cache/lib/style/import';
|
|
5
5
|
import { LibWorkloop } from 'esoftplay/cache/lib/workloop/import';
|
|
6
|
+
import Worker from 'esoftplay/libs/worker';
|
|
6
7
|
import * as FileSystem from 'expo-file-system';
|
|
7
8
|
import React, { useLayoutEffect } from 'react';
|
|
8
9
|
import { PixelRatio, Platform, View } from 'react-native';
|
|
9
10
|
import FastImage from 'react-native-fast-image';
|
|
10
|
-
import Worker from '../../libs/worker';
|
|
11
11
|
const sh = require("shorthash")
|
|
12
12
|
|
|
13
13
|
export interface LibPictureSource {
|
|
@@ -38,9 +38,10 @@ const getCacheEntry = async (uri: string, toSize: number): Promise<{ exists: boo
|
|
|
38
38
|
return { exists, path };
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const fetchPicture = Worker.registerJobAsync
|
|
41
|
+
const fetchPicture = Worker.registerJobAsync('lib_picture_fetch', (url: string, toSize: number) => {
|
|
42
42
|
'show source';
|
|
43
43
|
return new Promise((resolve, reject) => {
|
|
44
|
+
'show source';
|
|
44
45
|
fetch(url, { mode: 'cors' })
|
|
45
46
|
.then(response => response.blob())
|
|
46
47
|
.then(blob => {
|
|
@@ -121,7 +122,7 @@ export default function m(props: LibPictureProps): any {
|
|
|
121
122
|
if (exists) {
|
|
122
123
|
setUri(path)
|
|
123
124
|
} else {
|
|
124
|
-
fetchPicture
|
|
125
|
+
fetchPicture([b_uri, PixelRatio.getPixelSizeForLayoutSize(toSize)], (uri) => {
|
|
125
126
|
setUri("data:image/png;base64," + uri)
|
|
126
127
|
if (!props.noCache)
|
|
127
128
|
LibWorkloop.execNextTix(FileSystem.writeAsStringAsync, [path, uri, { encoding: "base64" }])
|
package/modules/lib/style.ts
CHANGED
|
@@ -83,22 +83,22 @@ const defaultStyle = {
|
|
|
83
83
|
},
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export default
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
86
|
+
export default {
|
|
87
|
+
isIphoneX: isIphoneX(),
|
|
88
|
+
STATUSBAR_HEIGHT: STATUSBAR_HEIGHT,
|
|
89
|
+
STATUSBAR_HEIGHT_MASTER: STATUSBAR_HEIGHT_MASTER,
|
|
90
|
+
colorPrimary: colorPrimary,
|
|
91
|
+
colorPrimaryDark: colorPrimaryDark,
|
|
92
|
+
colorNavigationBar: colorNavigationBar,
|
|
93
|
+
colorAccent: colorAccent,
|
|
94
|
+
colorGrey: colorGrey,
|
|
95
|
+
colorRed: colorRed,
|
|
96
|
+
colorTextPrimary: colorTextPrimary,
|
|
97
|
+
colorTextBody: colorTextBody,
|
|
98
|
+
colorTextCaption: colorTextCaption,
|
|
99
|
+
colorLightGrey: colorLightGrey,
|
|
100
|
+
elevation(val: number): any { return elevation(val) },
|
|
101
|
+
width: width,
|
|
102
|
+
height: height,
|
|
103
|
+
defaultStyle: defaultStyle,
|
|
104
|
+
}
|
package/modules/lib/tabs.tsx
CHANGED
|
@@ -3,9 +3,9 @@ import { LibComponent } from 'esoftplay/cache/lib/component/import';
|
|
|
3
3
|
import { LibStyle } from 'esoftplay/cache/lib/style/import';
|
|
4
4
|
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
|
|
5
5
|
|
|
6
|
+
import { fastFilter } from 'esoftplay/fast';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
import { ScrollView, View } from 'react-native';
|
|
8
|
-
import { fastFilter } from '../../fast';
|
|
9
9
|
|
|
10
10
|
export interface LibTabsProps {
|
|
11
11
|
tabIndex: number,
|
package/modules/lib/utils.ts
CHANGED
|
@@ -329,13 +329,13 @@ export default class eutils {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
static getInstallationID(): string {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
332
|
+
static getInstallationID(): Promise<string> {
|
|
333
|
+
return new Promise(async (resolve, reject) => {
|
|
334
|
+
let out = installationId.get()
|
|
335
|
+
if (!out) {
|
|
336
|
+
if (Platform.OS == "android")
|
|
337
|
+
resolve(String(Application.androidId))
|
|
338
|
+
if (Platform.OS == "ios") {
|
|
339
339
|
let code = await SecureStore.getItemAsync('installationId');
|
|
340
340
|
if (!code) {
|
|
341
341
|
code = ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
@@ -345,12 +345,11 @@ export default class eutils {
|
|
|
345
345
|
}
|
|
346
346
|
installationId.set(code);
|
|
347
347
|
SecureStore.setItemAsync('installationId', String(code));
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
return out
|
|
348
|
+
resolve(code);
|
|
349
|
+
}
|
|
351
350
|
}
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
resolve(out)
|
|
352
|
+
})
|
|
354
353
|
}
|
|
355
354
|
|
|
356
355
|
static sprintf(string: string, ...stringToBe: any[]): string {
|
|
@@ -368,6 +367,4 @@ export default class eutils {
|
|
|
368
367
|
}
|
|
369
368
|
return string
|
|
370
369
|
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// eutils.getInstallationID()
|
|
370
|
+
}
|
package/modules/use/form.ts
CHANGED
package/modules/user/class.ts
CHANGED
|
@@ -6,12 +6,11 @@ import { LibCurl } from 'esoftplay/cache/lib/curl/import';
|
|
|
6
6
|
import { LibNotification } from 'esoftplay/cache/lib/notification/import';
|
|
7
7
|
import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
8
8
|
import { UserData } from 'esoftplay/cache/user/data/import';
|
|
9
|
-
|
|
10
9
|
import useGlobalState from 'esoftplay/global';
|
|
10
|
+
import moment from "esoftplay/moment";
|
|
11
11
|
import Constants from 'expo-constants';
|
|
12
12
|
import * as Notifications from 'expo-notifications';
|
|
13
13
|
import { Platform } from 'react-native';
|
|
14
|
-
import moment from "../../moment";
|
|
15
14
|
|
|
16
15
|
const state = useGlobalState(null, { persistKey: "user" })
|
|
17
16
|
|
|
@@ -30,9 +29,18 @@ export default class m {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
static load(callback?: (user?: any | null) => void): Promise<any> {
|
|
33
|
-
return new Promise((r, j) => {
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
return new Promise(async (r, j) => {
|
|
33
|
+
AsyncStorage.getItem('user').then((user) => {
|
|
34
|
+
if (user) {
|
|
35
|
+
let juser = JSON.parse(user)
|
|
36
|
+
if (callback) callback(state?.get?.() || juser)
|
|
37
|
+
r((state?.get?.() || juser))
|
|
38
|
+
} else {
|
|
39
|
+
if (callback) callback(null)
|
|
40
|
+
r(null)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
36
44
|
})
|
|
37
45
|
}
|
|
38
46
|
|
package/modules/user/data.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// noPage
|
|
2
2
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
|
+
import { fastFilter } from 'esoftplay/fast';
|
|
3
4
|
import _global from 'esoftplay/_global';
|
|
4
|
-
import { fastFilter } from './../../fast';
|
|
5
5
|
|
|
6
6
|
export default class m {
|
|
7
7
|
static register(name: string): void {
|
package/modules/user/index.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { LibToast } from 'esoftplay/cache/lib/toast/import';
|
|
|
10
10
|
import { LibUpdaterProperty } from 'esoftplay/cache/lib/updater/import';
|
|
11
11
|
import { LibVersion } from 'esoftplay/cache/lib/version/import';
|
|
12
12
|
import { LibWorkloop } from 'esoftplay/cache/lib/workloop/import';
|
|
13
|
+
import Navs from 'esoftplay/cache/navs';
|
|
13
14
|
import { UseDeeplink } from 'esoftplay/cache/use/deeplink/import';
|
|
14
15
|
import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
15
16
|
import { UserHook } from 'esoftplay/cache/user/hook/import';
|
|
@@ -21,7 +22,6 @@ import * as Font from "expo-font";
|
|
|
21
22
|
import React, { useEffect, useLayoutEffect } from 'react';
|
|
22
23
|
import { Platform, View } from "react-native";
|
|
23
24
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
24
|
-
import Navs from '../../cache/navs';
|
|
25
25
|
|
|
26
26
|
export interface UserIndexProps {
|
|
27
27
|
|
|
@@ -112,17 +112,8 @@ export default function m(props: UserIndexProps): any {
|
|
|
112
112
|
setLoading(false)
|
|
113
113
|
}
|
|
114
114
|
})
|
|
115
|
+
//esoftplay-chatting
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
if (esp.config('firebase').hasOwnProperty('apiKey')) {
|
|
118
|
-
try {
|
|
119
|
-
const ChattingFirebase = esp.mod('chatting/firebase')
|
|
120
|
-
if (ChattingFirebase)
|
|
121
|
-
ChattingFirebase?.signInAnonymously?.();
|
|
122
|
-
} catch (error) {
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
117
|
LibUpdaterProperty.check()
|
|
127
118
|
}, [])
|
|
128
119
|
|
package/package.json
CHANGED
package/storage.ts
CHANGED
|
@@ -17,20 +17,11 @@ const CACHE_DIR = `${FileSystem.cacheDirectory}lib-storage-cache/`;
|
|
|
17
17
|
}
|
|
18
18
|
})()
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.setItem = this.setItem.bind(this);
|
|
24
|
-
this.getItem = this.getItem.bind(this)
|
|
25
|
-
this.removeItem = this.removeItem.bind(this);
|
|
26
|
-
this.clear = this.clear.bind(this);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private getDBPath(key: string): string {
|
|
30
|
-
const path = `${CACHE_DIR}${key.replace(/\\/g, "_")}.txt`;
|
|
20
|
+
const Storage = {
|
|
21
|
+
getDBPath(key: string): string {
|
|
22
|
+
const path = `${CACHE_DIR}${key.replace(/\//g, "-")}.txt`;
|
|
31
23
|
return path
|
|
32
|
-
}
|
|
33
|
-
|
|
24
|
+
},
|
|
34
25
|
getItem(key: string): Promise<string | null> {
|
|
35
26
|
return new Promise(async (r, j) => {
|
|
36
27
|
const path = this.getDBPath(key)
|
|
@@ -46,23 +37,21 @@ export default class Storage {
|
|
|
46
37
|
}
|
|
47
38
|
})
|
|
48
39
|
})
|
|
49
|
-
}
|
|
50
|
-
|
|
40
|
+
},
|
|
51
41
|
setItem(key: string, value: string): Promise<string> {
|
|
52
42
|
return new Promise(async (r, j) => {
|
|
53
43
|
const path = this.getDBPath(key)
|
|
54
44
|
FileSystem.writeAsStringAsync(path, value, { encoding: 'utf8' })
|
|
55
45
|
})
|
|
56
|
-
}
|
|
57
|
-
|
|
46
|
+
},
|
|
58
47
|
removeItem(key: string): Promise<string> {
|
|
59
48
|
return new Promise(async (r, j) => {
|
|
60
49
|
const path = this.getDBPath(key)
|
|
61
50
|
try { FileSystem.deleteAsync(path) } catch (error) { }
|
|
62
51
|
})
|
|
63
|
-
}
|
|
64
|
-
|
|
52
|
+
},
|
|
65
53
|
clear(): void {
|
|
66
54
|
FileSystem.deleteAsync(CACHE_DIR)
|
|
67
55
|
}
|
|
68
|
-
}
|
|
56
|
+
}
|
|
57
|
+
export default Storage;
|