esoftplay 0.0.136-i → 0.0.136-j

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.
Files changed (3) hide show
  1. package/global.ts +22 -21
  2. package/mmkv.ts +2 -2
  3. package/package.json +1 -1
package/global.ts CHANGED
@@ -98,32 +98,33 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
98
98
  })[0]
99
99
  }
100
100
 
101
- async function loadFromDisk() {
101
+ function loadFromDisk() {
102
102
  if (loaded == 0) {
103
103
  loaded = 1
104
104
  let persistKey = o?.persistKey
105
- const p = await STORAGE.getItem(String(persistKey))
106
- if (p) {
107
- if (persistKey != '__globalReady')
108
- if (p != undefined && typeof p == 'string' && (p.startsWith("{") || p.startsWith("[")))
109
- try { set(JSON.parse(p)) } catch (error) { }
110
- else {
111
- if (p == "true" || p == "false") {
112
- try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
113
- } else if (isNaN(p)) {
114
- try { /* @ts-ignore */ set(p) } catch (error) { }
115
- } else {
116
- try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
105
+ STORAGE.getItem(String(persistKey)).then((p: any) => {
106
+ if (p) {
107
+ if (persistKey != '__globalReady')
108
+ if (p != undefined && typeof p == 'string' && (p.startsWith("{") || p.startsWith("[")))
109
+ try { set(JSON.parse(p)) } catch (error) { }
110
+ else {
111
+ if (p == "true" || p == "false") {
112
+ try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
113
+ } else if (isNaN(p)) {
114
+ try { /* @ts-ignore */ set(p) } catch (error) { }
115
+ } else {
116
+ try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
117
+ }
117
118
  }
118
- }
119
- }
120
- if (o?.onFinish) {
121
- clearTimeout(timeoutFinish)
122
- timeoutFinish = setTimeout(() => {
123
- o.onFinish?.()
119
+ }
120
+ if (o?.onFinish) {
124
121
  clearTimeout(timeoutFinish)
125
- }, 50);
126
- }
122
+ timeoutFinish = setTimeout(() => {
123
+ o.onFinish?.()
124
+ clearTimeout(timeoutFinish)
125
+ }, 50);
126
+ }
127
+ })
127
128
  }
128
129
  }
129
130
 
package/mmkv.ts CHANGED
@@ -3,8 +3,8 @@ import { MMKV } from 'react-native-mmkv';
3
3
  const storage = new MMKV()
4
4
 
5
5
  const FastStorage = {
6
- getItem(key: string): string | undefined {
7
- return storage.getString(key)
6
+ getItem(key: string): Promise<string | undefined | null> {
7
+ return new Promise((r) => r(storage.getString(key)))
8
8
  },
9
9
  setItem(key: string, value: string) {
10
10
  storage.set(key, value)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.136-i",
3
+ "version": "0.0.136-j",
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",