esoftplay 0.0.115 → 0.0.116

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 CHANGED
@@ -146,6 +146,12 @@ if (fs.existsSync(packjson)) {
146
146
  "simulator": true
147
147
  }
148
148
  },
149
+ "preview_build": {
150
+ "distribution": "internal",
151
+ "android": {
152
+ "buildType": "apk"
153
+ }
154
+ },
149
155
  "production": {}
150
156
  },
151
157
  "submit": {
package/bin/cli.js CHANGED
@@ -92,9 +92,9 @@ switch (args[0]) {
92
92
  createMaster(args[1])
93
93
  break;
94
94
  case "start":
95
- jsEng(appjson, false)
96
- jsEng(appdebug, false)
97
- jsEng(applive, false)
95
+ jsEng(appjson, true)
96
+ jsEng(appdebug, true)
97
+ jsEng(applive, true)
98
98
  excludeModules()
99
99
  execution();
100
100
  break;
@@ -665,7 +665,19 @@ function build() {
665
665
  }
666
666
  },
667
667
  {
668
- name: "3. IOS (Production) - ipa",
668
+ name: "3. IOS (Preview) - Non Simulator",
669
+ cmd: "eas build --platform ios --profile preview_build",
670
+ pre: () => {
671
+ configAvailable(true)
672
+ devClientPos(appjson)
673
+ jsEng(appjson, true)
674
+ jsEng(appdebug, true)
675
+ jsEng(applive, true)
676
+ consoleSucces("Hermes diaktifkan")
677
+ }
678
+ },
679
+ {
680
+ name: "4. IOS (Production) - ipa",
669
681
  cmd: "eas build --platform ios --profile production",
670
682
  pre: () => {
671
683
  configAvailable(true)
@@ -677,7 +689,7 @@ function build() {
677
689
  }
678
690
  },
679
691
  {
680
- name: "4. Android (Development) - apk",
692
+ name: "5. Android (Development) - apk",
681
693
  cmd: "eas build --platform android --profile development",
682
694
  pre: () => {
683
695
  configAvailable(true)
@@ -689,7 +701,7 @@ function build() {
689
701
  }
690
702
  },
691
703
  {
692
- name: "5. Android (Preview) - apk",
704
+ name: "6. Android (Preview) - apk",
693
705
  cmd: "eas build --platform android --profile preview",
694
706
  pre: () => {
695
707
  configAvailable(true)
@@ -701,7 +713,7 @@ function build() {
701
713
  }
702
714
  },
703
715
  {
704
- name: "6. Android (Production) - aab",
716
+ name: "7. Android (Production) - aab",
705
717
  cmd: "eas build --platform android --profile production",
706
718
  pre: () => {
707
719
  configAvailable(true)
package/bin/router.js CHANGED
@@ -570,7 +570,7 @@ function createRouter() {
570
570
  var nav = "";
571
571
  var staticImport = []
572
572
 
573
- staticImport.push("const isEqual = require('react-fast-compare');\n")
573
+ staticImport.push("var isEqual = require('react-fast-compare');\n")
574
574
  staticImport.push("export function applyStyle(style){ return style };\n")
575
575
  staticImport.push("export { default as useGlobalState } from '../../../node_modules/esoftplay/global';\n")
576
576
  staticImport.push("export { default as usePersistState } from '../../../node_modules/esoftplay/persist';\n")
@@ -599,13 +599,13 @@ function createRouter() {
599
599
  item += "export { _" + ucword(module) + ucword(task) + " as " + ucword(module) + ucword(task) + " };\n"
600
600
  }
601
601
  if (module == 'lib' && task == 'component') {
602
- staticImport.splice(0, 0, item)
602
+ staticImport.splice(2, 0, item)
603
603
  } else if (module == 'lib' && task == 'style') {
604
- staticImport.splice(0, 0, item)
604
+ staticImport.splice(4, 0, item)
605
605
  } else if (module == 'lib' && task == 'worker') {
606
- staticImport.splice(2, 0, item)
606
+ staticImport.splice(4, 0, item)
607
607
  } else if (module == 'lib' && task == 'navigation') {
608
- staticImport.splice(2, 0, item)
608
+ staticImport.splice(4, 0, item)
609
609
  } else if (task == 'style') {
610
610
  staticImport.splice(9, 0, item)
611
611
  } else if (task == 'scrollpicker') {
@@ -615,9 +615,9 @@ function createRouter() {
615
615
  }
616
616
  }
617
617
  }
618
- staticImport.splice(0, 0, "export { default as createCache } from '../../../node_modules/esoftplay/_cache';\n")
619
- staticImport.splice(0, 0, "export { default as _global } from '../../../node_modules/esoftplay/_global';\n")
620
- staticImport.splice(0, 0, "import React from 'react';\n")
618
+ staticImport.splice(2, 0, "export { default as createCache } from '../../../node_modules/esoftplay/_cache';\n")
619
+ staticImport.splice(2, 0, "export { default as _global } from '../../../node_modules/esoftplay/_global';\n")
620
+ staticImport.splice(2, 0, "import React from 'react';\n")
621
621
  const x = staticImport.join('')
622
622
  if (isChange(tmpDir + 'index.js', x))
623
623
  fs.writeFile(tmpDir + 'index.js', x, { flag: 'w' }, function (err) {
package/global.ts CHANGED
@@ -35,134 +35,130 @@ class Context {
35
35
 
36
36
  export const globalIdx = new Context()
37
37
 
38
- const n = () => {
39
- let subscriber = {}
40
- let debouceTime
41
- let persistKeys: any = {}
42
-
43
- function m<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
44
- const _idx = globalIdx.idx
45
- if (!subscriber[_idx])
46
- subscriber[_idx] = [];
47
- let value: T = initValue;
48
-
49
- // rehidryte instant
50
- if (o?.persistKey) {
51
- rehidryte(o.persistKey, (p) => {
52
- if (typeof p == 'string') set(JSON.parse(p))
53
38
 
54
- })
39
+ let subscriber = {}
40
+ let debouceTime
41
+ let persistKeys: any = {}
42
+
43
+ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
44
+ const _idx = globalIdx.idx
45
+ if (!subscriber[_idx])
46
+ subscriber[_idx] = [];
47
+ let value: T = initValue;
48
+
49
+ // rehidryte instant
50
+ if (o?.persistKey) {
51
+ rehidryte(o.persistKey, (p) => {
52
+ if (typeof p == 'string') set(JSON.parse(p))
53
+
54
+ })
55
+ }
56
+
57
+ /* register to userData to automatically reset state and persist */
58
+ if (o?.isUserData) {
59
+ function resetFunction() {
60
+ set(initValue)
61
+ }
62
+ if (o?.persistKey) {
63
+ const UserData = require('./modules/user/data').default
64
+ UserData.register(o?.persistKey)
55
65
  }
66
+ _global.useGlobalUserDelete[_idx] = resetFunction
67
+ }
56
68
 
57
- /* register to userData to automatically reset state and persist */
58
- if (o?.isUserData) {
59
- function resetFunction() {
60
- set(initValue)
61
- }
69
+ function set(ns: T) {
70
+ const isChange = !isEqual(value, ns)
71
+ if (isChange) {
72
+ value = ns
73
+ fastLoop(subscriber?.[_idx], (c) => { c?.(ns) })
62
74
  if (o?.persistKey) {
63
- const UserData = require('./modules/user/data').default
64
- UserData.register(o?.persistKey)
75
+ AsyncStorage.setItem(o.persistKey, JSON.stringify(ns))
65
76
  }
66
- _global.useGlobalUserDelete[_idx] = resetFunction
77
+ if (o?.listener)
78
+ o.listener(ns)
67
79
  }
80
+ };
68
81
 
69
- function set(ns: T) {
70
- const isChange = !isEqual(value, ns)
71
- if (isChange) {
72
- value = ns
73
- fastLoop(subscriber?.[_idx], (c) => { c?.(ns) })
74
- if (o?.persistKey) {
75
- AsyncStorage.setItem(o.persistKey, JSON.stringify(ns))
76
- }
77
- if (o?.listener)
78
- o.listener(ns)
79
- }
80
- };
81
-
82
- function del() {
83
- if (o?.persistKey) {
84
- AsyncStorage.removeItem(o.persistKey)
85
- }
86
- set(initValue)
82
+ function del() {
83
+ if (o?.persistKey) {
84
+ AsyncStorage.removeItem(o.persistKey)
87
85
  }
86
+ set(initValue)
87
+ }
88
88
 
89
- function useSelector(se: (state: T) => any): void {
90
- let [l, s] = R.useState<any>(se(value));
89
+ function useSelector(se: (state: T) => any): void {
90
+ let [l, s] = R.useState<any>(se(value));
91
91
 
92
- let sl = R.useCallback(
93
- (ns: T) => {
94
- let n = se(ns);
95
- !isEqual(l, n) && s(n);
96
- },
97
- [l]
98
- );
92
+ let sl = R.useCallback(
93
+ (ns: T) => {
94
+ let n = se(ns);
95
+ !isEqual(l, n) && s(n);
96
+ },
97
+ [l]
98
+ );
99
99
 
100
- subscribe(sl)
100
+ subscribe(sl)
101
101
 
102
- return l;
103
- }
102
+ return l;
103
+ }
104
104
 
105
- function subscribe(func: any) {
106
- R.useLayoutEffect(() => {
107
- subscriber[_idx].push(func);
108
- return () => {
109
- subscriber[_idx] = fastFilter(subscriber?.[_idx], (f) => f !== func)
110
- };
111
- }, [func]);
112
- }
105
+ function subscribe(func: any) {
106
+ R.useLayoutEffect(() => {
107
+ subscriber[_idx].push(func);
108
+ return () => {
109
+ subscriber[_idx] = fastFilter(subscriber?.[_idx], (f) => f !== func)
110
+ };
111
+ }, [func]);
112
+ }
113
113
 
114
- function get(param?: string, ...params: string[]): any {
115
- let out: any = value;
116
- if (param) {
117
- const _params = [param, ...params]
118
- if (_params.length > 0)
119
- for (let i = 0; i < _params.length; i++) {
120
- if (out && _params[i] != undefined)
121
- out = out?.[_params[i]];
122
- }
123
- }
124
- return out;
114
+ function get(param?: string, ...params: string[]): any {
115
+ let out: any = value;
116
+ if (param) {
117
+ const _params = [param, ...params]
118
+ if (_params.length > 0)
119
+ for (let i = 0; i < _params.length; i++) {
120
+ if (out && _params[i] != undefined)
121
+ out = out?.[_params[i]];
122
+ }
125
123
  }
124
+ return out;
125
+ }
126
126
 
127
127
 
128
- function useState(): [T, (newState: T) => void, () => void] {
129
- let [l, sl] = R.useState<T>(value);
128
+ function useState(): [T, (newState: T) => void, () => void] {
129
+ let [l, sl] = R.useState<T>(value);
130
130
 
131
- subscribe(sl)
131
+ subscribe(sl)
132
132
 
133
- return [l, set, del];
134
- };
133
+ return [l, set, del];
134
+ };
135
135
 
136
- function _connect(props: useGlobalConnect<T>): any {
137
- const [state] = useState()
138
- const children = props.render(state)
139
- return children ? R.cloneElement(children) : null
140
- }
141
-
142
- globalIdx.increment()
143
- return { useState, get, set, useSelector, reset: del, connect: _connect };
136
+ function _connect(props: useGlobalConnect<T>): any {
137
+ const [state] = useState()
138
+ const children = props.render(state)
139
+ return children ? R.cloneElement(children) : null
144
140
  }
145
141
 
146
- function debounce(func: () => any, delay: number): void {
147
- clearTimeout(debouceTime)
148
- debouceTime = setTimeout(() => func(), delay)
149
- }
142
+ globalIdx.increment()
143
+ return { useState, get, set, useSelector, reset: del, connect: _connect };
144
+ }
150
145
 
151
- function rehidryte(key: string, func: (e: string) => void) {
152
- persistKeys[key] = func
153
- debounce(() => {
154
- AsyncStorage.multiGet(Object.keys(persistKeys), (e, v) => {
155
- if (v && !e) {
156
- v.forEach((iv, i) => {
157
- persistKeys[iv[0]]?.(iv[1])
158
- })
159
- } else {
160
-
161
- }
162
- })
163
- }, 100)
164
- }
165
- return m
146
+ function debounce(func: () => any, delay: number): void {
147
+ clearTimeout(debouceTime)
148
+ debouceTime = setTimeout(() => func(), delay)
166
149
  }
167
150
 
168
- export default n()
151
+ function rehidryte(key: string, func: (e: string) => void) {
152
+ persistKeys[key] = func
153
+ debounce(() => {
154
+ AsyncStorage.multiGet(Object.keys(persistKeys), (e, v) => {
155
+ if (v && !e) {
156
+ v.forEach((iv, i) => {
157
+ persistKeys[iv[0]]?.(iv[1])
158
+ })
159
+ } else {
160
+
161
+ }
162
+ })
163
+ }, 100)
164
+ }
@@ -9,6 +9,7 @@ export default class ecurl {
9
9
  signal = this.controller.signal
10
10
  timeout = 30000;
11
11
  maxRetry = 3;
12
+ resStatus?: number = undefined
12
13
  timeoutContext: any = null;
13
14
  isDebug = esp.config("isDebug");
14
15
  post: any;
@@ -267,7 +268,6 @@ export default class ecurl {
267
268
  Pragma: "no-cache",
268
269
  ['Cache-Control']: "no-store",
269
270
  mode: "cors",
270
- _post: post
271
271
  }
272
272
  if (debug == 1)
273
273
  esp.log(this.url + this.uri, options)
@@ -276,6 +276,7 @@ export default class ecurl {
276
276
  fetch(this.url + this.uri, options).then(async (res) => {
277
277
  this.cancelTimeout()
278
278
  var resText = await res.text()
279
+ this.resStatus = res.status
279
280
  var resJson = (resText.startsWith("{") || resText.startsWith("[")) ? JSON.parse(resText) : null
280
281
  if (resJson) {
281
282
  if (onDone) onDone(resJson, false)
@@ -333,7 +334,6 @@ export default class ecurl {
333
334
  ["Cache-Control"]: 'no-cache, no-store, must-revalidate',
334
335
  ["Expires"]: 0,
335
336
  mode: "cors",
336
- _post: post
337
337
  }
338
338
 
339
339
  //api_logger
@@ -347,6 +347,7 @@ export default class ecurl {
347
347
 
348
348
  fetch(this.url + this.uri, options).then(async (res) => {
349
349
  this.cancelTimeout()
350
+ this.resStatus = res.status
350
351
  let resText = await res.text()
351
352
  this.onFetched(resText, onDone, onFailed, debug)
352
353
  }).catch((r) => {
@@ -407,7 +408,16 @@ export default class ecurl {
407
408
  private onError(msg: string): void {
408
409
  esp.log("\x1b[31m", msg)
409
410
  esp.log("\x1b[0m")
411
+ this.fetchConf.options["status_code"] = this.resStatus
410
412
  delete this.fetchConf.options.cancelToken
413
+ delete this.fetchConf.options.signal
414
+ delete this.fetchConf.options.cache
415
+ delete this.fetchConf.options.Pragma
416
+ delete this.fetchConf.options.Expires
417
+ delete this.fetchConf.options.mode
418
+ delete this.fetchConf.options["Cache-Control"]
419
+ delete this.fetchConf.options["Content-Type"]
420
+ delete this.fetchConf.options.token
411
421
  reportApiError(this.fetchConf, msg)
412
422
  LibProgress.hide()
413
423
  }
@@ -1,5 +1,6 @@
1
1
  // withHooks
2
2
 
3
+ // import { FlashList } from "@shopify/flash-list";
3
4
  import { LibIcon, LibLoading, LibNavigation, LibObject, LibStyle, LibTextstyle, useSafeState } from 'esoftplay';
4
5
  import * as MediaLibrary from 'expo-media-library';
5
6
  import React, { useEffect } from 'react';
@@ -70,6 +71,8 @@ export default function m(props: LibImage_multiProps): any {
70
71
  setPhotos(LibObject.set(photos, item.selected == 1 ? 0 : 1)(index, "selected"))
71
72
  }} />
72
73
  )
74
+ // const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
75
+ const List = /* !!AutoLayoutViewNativeComponent ? FlashList : */ FlatList
73
76
 
74
77
  return (
75
78
  <View style={{ flex: 1, backgroundColor: "white" }} >
@@ -87,7 +90,7 @@ export default function m(props: LibImage_multiProps): any {
87
90
  </TouchableOpacity>
88
91
  </View>
89
92
  <View style={{ flex: 1 }} >
90
- <FlatList
93
+ <List
91
94
  data={photos}
92
95
  keyExtractor={(_: any, i) => _.uri}
93
96
  getItemLayout={getItemLayout}
@@ -1,11 +1,11 @@
1
1
  // noPage
2
2
 
3
+ // import { FlashList } from "@shopify/flash-list";
3
4
  import { esp, LibComponent, LibCurl, LibListItemLayout, LibLoading, LibStyle, LibTextstyle } from 'esoftplay';
4
5
  import React from 'react';
5
6
  import isEqual from 'react-fast-compare';
6
7
  import { FlatList, View } from 'react-native';
7
8
 
8
-
9
9
  export interface LibInfiniteProps {
10
10
  url: string,
11
11
  post?: any,
@@ -172,13 +172,15 @@ export default class m extends LibComponent<LibInfiniteProps, LibInfiniteState>{
172
172
  render(): any {
173
173
  const { data, error } = this.state
174
174
  const { errorView, refreshEnabled } = this.props
175
+ // const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
176
+ const List = /* !!AutoLayoutViewNativeComponent ? FlashList : */ FlatList
175
177
  return (
176
178
  <View style={{ flex: 1 }} >
177
179
  {
178
180
  (!data || data.length) == 0 && !this.isStop ?
179
181
  this.props.LoadingView || <LibLoading />
180
182
  :
181
- <FlatList
183
+ <List
182
184
  ref={this.flatlist}
183
185
  data={data || []}
184
186
  onRefresh={((refreshEnabled == undefined) || refreshEnabled) && (() => this.loadData())}
@@ -1,6 +1,7 @@
1
1
  // noPage
2
2
 
3
3
 
4
+ // import { FlashList } from "@shopify/flash-list";
4
5
  import { LibComponent } from "esoftplay";
5
6
  import React from "react";
6
7
  import { FlatList, View } from 'react-native';
@@ -75,9 +76,11 @@ export default class EList extends LibComponent<LibListProps, LibListState> {
75
76
  if (this.props.staticHeight)
76
77
  return ({ getItemLayout: (data, index) => this.props.staticHeight ? ({ length: this.props.staticHeight, offset: this.props.staticHeight, index: index }) : undefined })
77
78
  }
79
+ // const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
80
+ const List = /* !!AutoLayoutViewNativeComponent ? FlashList : */ FlatList
78
81
  return (
79
82
  <View ref={(e) => this.view = e} style={[{ flex: 1 }]} >
80
- <FlatList
83
+ <List
81
84
  ref={this.flatlist}
82
85
  data={this.props.data}
83
86
  keyExtractor={this.keyExtractor}
@@ -1,10 +1,8 @@
1
1
 
2
- // noPage
3
-
4
- import { esp, LibComponent, LibCurl, LibDialog, LibIcon, LibNavigation, LibStyle, LibTextstyle, LibUtils } from 'esoftplay';
2
+ import { esp, LibComponent, LibCurl, LibDialog, LibIcon, LibNavigation, LibStyle, LibTextstyle } from 'esoftplay';
5
3
  import Constants from 'expo-constants';
6
4
  import React from 'react';
7
- import { BackHandler, Linking, Platform, TouchableOpacity, View } from 'react-native';
5
+ import { BackHandler, ImageBackground, Linking, Platform, TouchableOpacity } from 'react-native';
8
6
  export interface LibVersionProps {
9
7
 
10
8
  }
@@ -42,7 +40,6 @@ export default class m extends LibComponent<LibVersionProps, LibVersionState> {
42
40
 
43
41
  static onDone(res: any, msg: string): void {
44
42
  const { title, version, android, ios } = res
45
-
46
43
  function isAvailableNewVersion(newVersion: string): boolean {
47
44
  let oldVersion = m.appVersion()
48
45
  return newVersion > oldVersion
@@ -62,16 +59,16 @@ export default class m extends LibComponent<LibVersionProps, LibVersionState> {
62
59
  const { res: { title, version, android, ios }, msg } = LibNavigation.getArgsAll(this.props)
63
60
  const link = Platform.OS == 'ios' ? ios : android
64
61
  return (
65
- <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', borderStartColor: 'white', paddingHorizontal: 17 }} >
62
+ <ImageBackground source={esp.assets("splash.png")} blurRadius={100} style={{ flex: 1, justifyContent: 'center', alignItems: 'center', borderStartColor: 'white', paddingHorizontal: 17 }} >
66
63
  <LibIcon.SimpleLineIcons name="info" size={60} />
67
64
  <LibTextstyle textStyle="headline" text={title || 'A new version is available'} style={{ textAlign: 'center', marginTop: 10 }} />
68
- <LibTextstyle textStyle="callout" text={LibUtils.ucwords(msg)} style={{ textAlign: 'center', marginTop: 10, color: '#888' }} />
65
+ <LibTextstyle textStyle="callout" text={msg} style={{ textAlign: 'center', marginTop: 10, color: '#333' }} />
69
66
  <TouchableOpacity
70
67
  onPress={() => { Linking.canOpenURL(link) && Linking.openURL(link) }}
71
68
  style={{ marginTop: 20, borderRadius: 10, paddingHorizontal: 17, paddingVertical: 10, backgroundColor: LibStyle.colorPrimary }} >
72
69
  <LibTextstyle textStyle="body" text="Update Sekarang" />
73
70
  </TouchableOpacity>
74
- </View>
71
+ </ImageBackground>
75
72
  )
76
73
  }
77
74
  }
@@ -1,8 +1,10 @@
1
1
  // noPage
2
2
 
3
- import { _global } from 'esoftplay';
3
+ import { useGlobalReturn, _global } from 'esoftplay';
4
4
  import React, { Component } from "react";
5
5
  import { Platform } from 'react-native';
6
+ import useGlobalState from '../../global';
7
+
6
8
 
7
9
  export interface LibWorkerInit {
8
10
  task: string,
@@ -16,17 +18,21 @@ export interface LibWorkerProps {
16
18
  export interface LibWorkerState {
17
19
 
18
20
  }
19
-
20
21
  _global.LibWorkerBase = React.createRef()
21
22
  _global.LibWorkerTasks = new Map()
22
23
  _global.injectedJavaScripts = []
23
24
  _global.LibWorkerReady = 0
24
25
  _global.LibWorkerCount = 0
26
+ const state = useGlobalState?.(null)
25
27
  export default class m extends Component<LibWorkerProps, LibWorkerState> {
26
28
  constructor(props: LibWorkerProps) {
27
29
  super(props)
28
30
  }
29
-
31
+
32
+ static workerState(): useGlobalReturn<any> {
33
+ return state
34
+ }
35
+
30
36
  static delete(taskId: string): void {
31
37
  _global.LibWorkerTasks.delete(taskId)
32
38
  }
@@ -152,6 +158,7 @@ export default class m extends Component<LibWorkerProps, LibWorkerState> {
152
158
  return (e: any) => {
153
159
  if (e.nativeEvent.data == withRefName) {
154
160
  _global.LibWorkerReady += 1
161
+ m.workerState().set(1)
155
162
  return
156
163
  }
157
164
  const dt = e.nativeEvent.data
@@ -1,14 +1,14 @@
1
1
  // noPage
2
2
 
3
3
  import AsyncStorage from '@react-native-async-storage/async-storage';
4
- import { esp, LibCrypt, LibCurl, LibNotification, useGlobalReturn, useGlobalState, UserClass, UserData } from 'esoftplay';
4
+ import { esp, LibCrypt, LibCurl, LibNotification, useGlobalReturn, UserClass, UserData } from 'esoftplay';
5
5
  import Constants from 'expo-constants';
6
6
  import * as Notifications from 'expo-notifications';
7
7
  import { Platform } from 'react-native';
8
+ import useGlobalState from '../../global';
8
9
  import moment from "../../moment";
9
10
 
10
-
11
- const state = useGlobalState(undefined)
11
+ const state = useGlobalState?.(null, { persistKey: "user" })
12
12
 
13
13
  export default class eclass {
14
14
  static state(): useGlobalReturn<any> {
@@ -16,33 +16,15 @@ export default class eclass {
16
16
  }
17
17
  static create(user: any): Promise<void> {
18
18
  return new Promise((r, j) => {
19
- state.set(user)
20
- AsyncStorage.setItem("user", new LibCrypt().encode(JSON.stringify(user)))
21
- if (esp.config('notification') == 1) {
22
- UserClass.pushToken()
23
- }
24
- r();
19
+ state?.set?.(user)
20
+ r(user)
25
21
  })
26
22
  }
27
23
 
28
24
  static load(callback?: (user?: any | null) => void): Promise<any> {
29
25
  return new Promise((r, j) => {
30
- AsyncStorage.getItem("user").then((user: string) => {
31
- if (user) {
32
- const usr = (user[0] == '{' && user[user.length - 1] == '}') ? JSON.parse(user) : JSON.parse(new LibCrypt().decode(user))
33
- if (usr) {
34
- r(usr);
35
- state.set(usr)
36
- if (callback) callback(usr)
37
- } else {
38
- j()
39
- if (callback) callback(null)
40
- }
41
- } else {
42
- j()
43
- if (callback) callback(null)
44
- }
45
- })
26
+ if (callback) callback(state?.get?.())
27
+ r((state?.get?.()))
46
28
  })
47
29
  }
48
30
 
@@ -59,11 +41,10 @@ export default class eclass {
59
41
  }
60
42
 
61
43
  static delete(): Promise<void> {
62
- return new Promise((r) => {
44
+ return new Promise(async (r) => {
63
45
  Notifications.setBadgeCountAsync(0)
64
- state.set(undefined)
65
- AsyncStorage.removeItem("user_notification");
66
- AsyncStorage.removeItem("user");
46
+ state.reset()
47
+ await AsyncStorage.removeItem("user_notification");
67
48
  new UserData().deleteAll()
68
49
  if (esp.config('notification') == 1) {
69
50
  UserClass.pushToken()
@@ -74,7 +55,7 @@ export default class eclass {
74
55
 
75
56
  static pushToken(): Promise<any> {
76
57
  return new Promise((resolve, reject) => {
77
- if (Constants.appOwnership == 'expo' && !esp.isDebug()) {
58
+ if (Constants.appOwnership == 'expo' && !esp.isDebug('')) {
78
59
  resolve(undefined)
79
60
  return
80
61
  }
File without changes
@@ -1,12 +1,11 @@
1
1
  // withHooks
2
2
  // noPage
3
3
 
4
- import { ChattingFirebase, esp, LibDialog, LibImage, LibNet_status, LibProgress, LibStyle, LibToast, LibUpdaterProperty, LibVersion, LibWorker, LibWorkloop, LibWorkview, UseDeeplink, UserClass, UserLoading, UserMain, UserRoutes, useSafeState, _global } from 'esoftplay';
4
+ import { ChattingFirebase, esp, LibDialog, LibImage, LibNet_status, LibProgress, LibStyle, LibToast, LibUpdaterProperty, LibVersion, LibWorker, LibWorkloop, LibWorkview, UseDeeplink, UserClass, UserHook, UserLoading, UserRoutes, useSafeState, _global } from 'esoftplay';
5
5
  import * as Font from "expo-font";
6
- import React, { useEffect, useLayoutEffect } from "react";
7
- import { View } from "react-native";
6
+ import React, { useEffect } from "react";
7
+ import { Platform, View } from "react-native";
8
8
  import { GestureHandlerRootView } from 'react-native-gesture-handler';
9
- import Navs from "../../cache/navs";
10
9
 
11
10
  export interface UserIndexProps {
12
11
 
@@ -31,8 +30,9 @@ function setFonts(): Promise<void> {
31
30
 
32
31
 
33
32
 
34
- export default function m(props: UserIndexProps): any {
33
+ export default function UserIndex(props: UserIndexProps): any {
35
34
  const [loading, setLoading] = useSafeState(true)
35
+ const [worker] = LibWorker.workerState().useState()
36
36
  const user = UserClass.state().useSelector(s => s)
37
37
  const ready = React.useRef(0)
38
38
  UseDeeplink()
@@ -47,21 +47,33 @@ export default function m(props: UserIndexProps): any {
47
47
  UserRoutes.set(currentState)
48
48
  }
49
49
 
50
- useLayoutEffect(() => {
50
+ useEffect(() => {
51
51
  // const timeout = setTimeout(() => {
52
52
  // setLoading(false)
53
53
  // }, 15 * 1000);
54
+ let limitReady = 3
55
+ if (Platform.OS == 'android')
56
+ if (Platform.Version <= 22) {
57
+ limitReady = 2
58
+ }
59
+
60
+ if (worker == 1) {
61
+ ready.current += 1
62
+ if (ready.current >= limitReady) {
63
+ setLoading(false)
64
+ }
65
+ }
54
66
  (async () => {
55
67
  await setFonts()
56
68
  ready.current += 1
57
- if (ready.current >= 2) {
69
+ if (ready.current >= limitReady) {
58
70
  setLoading(false)
59
71
  }
60
72
  })()
61
73
 
62
74
  UserClass.isLogin(async () => {
63
75
  ready.current += 1
64
- if (ready.current >= 2) {
76
+ if (ready.current >= limitReady) {
65
77
  setLoading(false)
66
78
  }
67
79
  })
@@ -74,7 +86,7 @@ export default function m(props: UserIndexProps): any {
74
86
  }
75
87
  }
76
88
  LibUpdaterProperty.check((isNew) => { })
77
- }, [])
89
+ }, [worker])
78
90
 
79
91
  useEffect(() => {
80
92
  if (!loading) {
@@ -84,19 +96,24 @@ export default function m(props: UserIndexProps): any {
84
96
  }
85
97
  }, [loading])
86
98
 
87
- if (loading) return <UserLoading />
88
99
  return (
89
100
  <GestureHandlerRootView style={{ flex: 1 }}>
90
101
  <View style={{ flex: 1 }}>
91
102
  <LibWorker />
92
103
  <LibWorkview />
93
104
  <LibWorkloop />
94
- <Navs user={user} initialState={initialState} handler={handler} />
105
+ {
106
+ loading ?
107
+ <UserLoading />
108
+ :
109
+ <View style={{ backgroundColor: 'red', flex: 1 }} />
110
+ // <Navs user={user} initialState={initialState} handler={handler} />
111
+ }
95
112
  <LibNet_status />
96
113
  <LibDialog style={'default'} />
97
114
  <LibImage />
98
115
  <LibProgress />
99
- <UserMain />
116
+ <UserHook />
100
117
  <LibToast />
101
118
  </View>
102
119
  <View style={{ backgroundColor: LibStyle.colorNavigationBar || 'white', height: LibStyle.isIphoneX ? 35 : 0 }} />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.115",
3
+ "version": "0.0.116",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",