esoftplay 0.0.115-r → 0.0.115-u

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/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;
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,7 +599,7 @@ 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
604
  staticImport.splice(4, 0, item)
605
605
  } else if (module == 'lib' && task == 'worker') {
@@ -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 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
+
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
+ }
@@ -71,7 +71,7 @@ export default function m(props: LibImage_multiProps): any {
71
71
  setPhotos(LibObject.set(photos, item.selected == 1 ? 0 : 1)(index, "selected"))
72
72
  }} />
73
73
  )
74
- const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
74
+ // const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
75
75
  const List = /* !!AutoLayoutViewNativeComponent ? FlashList : */ FlatList
76
76
 
77
77
  return (
@@ -172,7 +172,7 @@ 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")
175
+ // const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
176
176
  const List = /* !!AutoLayoutViewNativeComponent ? FlashList : */ FlatList
177
177
  return (
178
178
  <View style={{ flex: 1 }} >
@@ -76,7 +76,7 @@ export default class EList extends LibComponent<LibListProps, LibListState> {
76
76
  if (this.props.staticHeight)
77
77
  return ({ getItemLayout: (data, index) => this.props.staticHeight ? ({ length: this.props.staticHeight, offset: this.props.staticHeight, index: index }) : undefined })
78
78
  }
79
- const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
79
+ // const AutoLayoutViewNativeComponent = require("@shopify/flash-list/src/native/auto-layout/AutoLayoutViewNativeComponent")
80
80
  const List = /* !!AutoLayoutViewNativeComponent ? FlashList : */ FlatList
81
81
  return (
82
82
  <View ref={(e) => this.view = e} style={[{ flex: 1 }]} >
@@ -1,8 +1,10 @@
1
1
  // noPage
2
2
 
3
- import { useGlobalReturn, useGlobalState, _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,
@@ -21,7 +23,7 @@ _global.LibWorkerTasks = new Map()
21
23
  _global.injectedJavaScripts = []
22
24
  _global.LibWorkerReady = 0
23
25
  _global.LibWorkerCount = 0
24
- const state = useGlobalState(null)
26
+ const state = useGlobalState?.(null)
25
27
  export default class m extends Component<LibWorkerProps, LibWorkerState> {
26
28
  constructor(props: LibWorkerProps) {
27
29
  super(props)
@@ -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)
12
12
 
13
13
  export default class eclass {
14
14
  static state(): useGlobalReturn<any> {
@@ -16,7 +16,7 @@ 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)
19
+ state?.set?.(user)
20
20
  AsyncStorage.setItem("user", new LibCrypt().encode(JSON.stringify(user)))
21
21
  if (esp.config('notification') == 1) {
22
22
  UserClass.pushToken()
@@ -32,7 +32,7 @@ export default class eclass {
32
32
  const usr = (user[0] == '{' && user[user.length - 1] == '}') ? JSON.parse(user) : JSON.parse(new LibCrypt().decode(user))
33
33
  if (usr) {
34
34
  r(usr);
35
- state.set(usr)
35
+ state?.set?.(usr)
36
36
  if (callback) callback(usr)
37
37
  } else {
38
38
  j()
@@ -52,7 +52,7 @@ export default function m(props: UserIndexProps): any {
52
52
  // const timeout = setTimeout(() => {
53
53
  // setLoading(false)
54
54
  // }, 15 * 1000);
55
- let limitReady = 3
55
+ let limitReady = 2
56
56
  if (Platform.OS == 'android')
57
57
  if (Platform.Version <= 22) {
58
58
  limitReady = 2
@@ -72,12 +72,12 @@ export default function m(props: UserIndexProps): any {
72
72
  }
73
73
  })()
74
74
 
75
- UserClass.isLogin(async () => {
76
- ready.current += 1
77
- if (ready.current >= limitReady) {
78
- setLoading(false)
79
- }
80
- })
75
+ // UserClass.isLogin(async () => {
76
+ // ready.current += 1
77
+ // if (ready.current >= limitReady) {
78
+ // setLoading(false)
79
+ // }
80
+ // })
81
81
  if (esp.config('firebase').hasOwnProperty('apiKey')) {
82
82
  try {
83
83
  if (ChattingFirebase)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.115-r",
3
+ "version": "0.0.115-u",
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",