esoftplay 0.0.124-u → 0.0.124-w
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 +2 -7
- package/libs/worker.tsx +15 -135
- package/modules/user/index.tsx +3 -26
- package/package.json +1 -1
package/bin/build.js
CHANGED
|
@@ -151,15 +151,13 @@ if (fs.existsSync(packjson)) {
|
|
|
151
151
|
"developmentClient": true,
|
|
152
152
|
"distribution": "internal",
|
|
153
153
|
"ios": {
|
|
154
|
-
"simulator": true
|
|
155
|
-
"resourceClass": "m1-medium"
|
|
154
|
+
"simulator": true
|
|
156
155
|
}
|
|
157
156
|
},
|
|
158
157
|
"preview": {
|
|
159
158
|
"distribution": "internal",
|
|
160
159
|
"ios": {
|
|
161
|
-
"simulator": true
|
|
162
|
-
"resourceClass": "m1-medium"
|
|
160
|
+
"simulator": true
|
|
163
161
|
}
|
|
164
162
|
},
|
|
165
163
|
"preview_build": {
|
|
@@ -169,9 +167,6 @@ if (fs.existsSync(packjson)) {
|
|
|
169
167
|
}
|
|
170
168
|
},
|
|
171
169
|
"production": {
|
|
172
|
-
"ios": {
|
|
173
|
-
"resourceClass": "m1-medium"
|
|
174
|
-
}
|
|
175
170
|
}
|
|
176
171
|
},
|
|
177
172
|
"submit": {
|
package/libs/worker.tsx
CHANGED
|
@@ -1,166 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import _global from "esoftplay/_global";
|
|
3
|
-
import React, { useRef } from "react";
|
|
4
|
-
import { Platform, View } from 'react-native';
|
|
5
|
-
import WebView from "react-native-webview";
|
|
1
|
+
import { useRef } from "react";
|
|
6
2
|
|
|
7
|
-
_global.WorkerBase = React.createRef()
|
|
8
|
-
_global.WorkerTasks = new Map()
|
|
9
|
-
_global.injectedJavaScripts = []
|
|
10
|
-
_global.WorkerReady = 0
|
|
11
|
-
_global.WorkerCount = 0
|
|
12
3
|
|
|
13
4
|
const Worker = {
|
|
14
5
|
delete(taskId: string) {
|
|
15
|
-
_global.WorkerTasks.delete(taskId)
|
|
16
6
|
},
|
|
17
7
|
useWorker(name: string, func: (...fparams: any[]) => Promise<any>): (params: any[], res: (data: any) => void) => void {
|
|
8
|
+
console.warn("Esoftplay Worker DEPRECATED, please remove from your code")
|
|
18
9
|
const ref = useRef(Worker.registerJobAsync(name, func)).current
|
|
19
10
|
return ref
|
|
20
11
|
},
|
|
21
12
|
registerJob(name: string, func: Function): (params: any[], res: (data: any) => void) => void {
|
|
22
|
-
|
|
23
|
-
const x = func.toString().replace('function', 'function ' + name)
|
|
24
|
-
_global.injectedJavaScripts.push(x)
|
|
25
|
-
Worker.dispatch(() => x, '', () => { })
|
|
13
|
+
console.warn("Esoftplay Worker DEPRECATED, please remove from your code");
|
|
26
14
|
return (params: (string | number | boolean)[], res: (data: string) => void) => {
|
|
27
|
-
|
|
28
|
-
if (Platform.Version <= 22) {
|
|
29
|
-
return res(func(...params))
|
|
30
|
-
}
|
|
31
|
-
Worker.dispatch(
|
|
32
|
-
(id: number) => {
|
|
33
|
-
let _params = params.map((param) => {
|
|
34
|
-
if (typeof param == 'string')
|
|
35
|
-
return `"` + param + `"`
|
|
36
|
-
return param
|
|
37
|
-
})
|
|
38
|
-
return (`window.ReactNativeWebView.postMessage(JSON.stringify({ data: ` + name + `(` + _params.join(", ") + `), id: ` + id + ` }));true;`)
|
|
39
|
-
}
|
|
40
|
-
, '', res)
|
|
15
|
+
return res(func(...params))
|
|
41
16
|
}
|
|
42
17
|
},
|
|
43
18
|
registerJobAsync(name: string, func: (...fparams: any[]) => Promise<any>): (params: any[], res: (data: any) => void) => void {
|
|
44
|
-
|
|
45
|
-
const x = func.toString().replace('function', 'function ' + name)
|
|
46
|
-
_global.injectedJavaScripts.push(x)
|
|
47
|
-
Worker.dispatch(() => x, '', () => { })
|
|
19
|
+
console.warn("Esoftplay Worker DEPRECATED, please remove from your code");
|
|
48
20
|
return (params: (string | number | boolean)[], res: (data: string) => void) => {
|
|
49
|
-
|
|
50
|
-
if (Platform.Version <= 22) {
|
|
51
|
-
(async () => res(await func(...params)))()
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
Worker.dispatch(
|
|
56
|
-
(id: number) => {
|
|
57
|
-
let _params = params.map((param) => {
|
|
58
|
-
if (typeof param == 'string')
|
|
59
|
-
return `"` + param + `"`
|
|
60
|
-
return param
|
|
61
|
-
})
|
|
62
|
-
return (`(async () => window.ReactNativeWebView.postMessage(JSON.stringify({ data: await ` + name + `(` + _params.join(", ") + `), id: ` + id + ` })))();true;`)
|
|
63
|
-
}
|
|
64
|
-
, '', res)
|
|
21
|
+
(async () => res(await func(...params)))()
|
|
65
22
|
}
|
|
66
23
|
},
|
|
67
24
|
objToString(data: any): string {
|
|
68
|
-
|
|
69
|
-
if (Platform.Version <= 22) {
|
|
70
|
-
return JSON.stringify(data)
|
|
71
|
-
}
|
|
72
|
-
return JSON.stringify(JSON.stringify(data)).slice(1, -1);
|
|
25
|
+
return JSON.stringify(data)
|
|
73
26
|
},
|
|
74
27
|
jobAsync(func: (...fparams: any[]) => Promise<any>, params: (string | number | boolean)[], res: (data: any) => void): void {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (Platform.Version <= 22) {
|
|
78
|
-
(async () => res(await func(...params)))()
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
Worker.dispatch(
|
|
82
|
-
(id: number) => {
|
|
83
|
-
const nameFunction = func.toString().replace('function', 'function tempFunction')
|
|
84
|
-
let _params = params.map((param) => {
|
|
85
|
-
if (typeof param == 'string')
|
|
86
|
-
return `"` + param + `"`
|
|
87
|
-
return param
|
|
88
|
-
})
|
|
89
|
-
return (`(async () => window.ReactNativeWebView.postMessage(JSON.stringify({ data: await ` + nameFunction + `(` + _params.join(", ") + `), id: ` + id + ` })))();true;`)
|
|
90
|
-
}
|
|
91
|
-
, '', res)
|
|
28
|
+
console.warn("Esoftplay Worker DEPRECATED, please remove from your code");
|
|
29
|
+
(async () => res(await func(...params)))()
|
|
92
30
|
},
|
|
93
31
|
job(func: Function, params: (string | number | boolean)[], res: (data: any) => void): void {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (Platform.Version <= 22) {
|
|
97
|
-
return res(func(...params))
|
|
98
|
-
}
|
|
99
|
-
Worker.dispatch(
|
|
100
|
-
(id: number) => {
|
|
101
|
-
const nameFunction = func.toString().replace('function', 'function tempFunction')
|
|
102
|
-
let _params = params.map((param) => {
|
|
103
|
-
if (typeof param == 'string')
|
|
104
|
-
return `"` + param + `"`
|
|
105
|
-
return param
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
const out = nameFunction + `\nwindow.ReactNativeWebView.postMessage(JSON.stringify({ data: tempFunction` + `(` + _params.join(",") + `), id: ` + id + ` }));true;`
|
|
109
|
-
return out
|
|
110
|
-
}
|
|
111
|
-
, '', res)
|
|
32
|
+
console.warn("Esoftplay Worker DEPRECATED, please remove from your code");
|
|
33
|
+
return res(func(...params))
|
|
112
34
|
},
|
|
113
35
|
dispatch(task: (id: number) => string, url: string, result: (r: string) => void): void {
|
|
114
|
-
|
|
115
|
-
_global.WorkerCount++
|
|
116
|
-
var _task = task(_global.WorkerCount)
|
|
117
|
-
_global.WorkerTasks.set(String(_global.WorkerCount), {
|
|
118
|
-
task: _task,
|
|
119
|
-
result: result
|
|
120
|
-
})
|
|
121
|
-
_global.WorkerBase?.current?.injectJavaScript?.(_task)
|
|
122
|
-
} else {
|
|
123
|
-
setTimeout(() => {
|
|
124
|
-
Worker.dispatch(task, url, result)
|
|
125
|
-
}, 1000);
|
|
126
|
-
}
|
|
36
|
+
|
|
127
37
|
},
|
|
128
38
|
onMessage(withRefName: string): any {
|
|
129
|
-
|
|
130
|
-
if (e.nativeEvent.data == withRefName) {
|
|
131
|
-
_global.WorkerReady += 1
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
const dt = e.nativeEvent.data
|
|
135
|
-
const x = JSON.parse(dt)
|
|
136
|
-
const itemTask = _global.WorkerTasks.get(String(x.id))
|
|
137
|
-
if (itemTask) {
|
|
138
|
-
itemTask.result(x.data)
|
|
139
|
-
Worker.delete(x.id)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
39
|
+
|
|
142
40
|
},
|
|
143
41
|
Provider(props: any): any {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return props.children
|
|
147
|
-
}
|
|
148
|
-
return (
|
|
149
|
-
<View style={{ flex: 1 }} >
|
|
150
|
-
<View style={{ height: 0, width: 0 }} >
|
|
151
|
-
<WebView
|
|
152
|
-
ref={_global.WorkerBase}
|
|
153
|
-
style={{ width: 0, height: 0 }}
|
|
154
|
-
javaScriptEnabled={true}
|
|
155
|
-
injectedJavaScript={`\nwindow.ReactNativeWebView.postMessage("BaseWorkerIsReady")\n` + _global.injectedJavaScripts.join('\n') + '\ntrue;'}
|
|
156
|
-
originWhitelist={["*"]}
|
|
157
|
-
source={{ uri: esp.config("protocol") + "://" + esp.config("domain") + esp.config("uri") + "dummyPageToBypassCORS" }}
|
|
158
|
-
onMessage={Worker.onMessage('BaseWorkerIsReady')}
|
|
159
|
-
/>
|
|
160
|
-
</View>
|
|
161
|
-
{props.children}
|
|
162
|
-
</View>
|
|
163
|
-
)
|
|
42
|
+
console.warn("Esoftplay Worker DEPRECATED, please remove from your code")
|
|
43
|
+
return props.children
|
|
164
44
|
}
|
|
165
45
|
}
|
|
166
46
|
export default Worker
|
package/modules/user/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// noPage
|
|
3
3
|
import { esp, useSafeState } from 'esoftplay';
|
|
4
4
|
import { LibDialog } from 'esoftplay/cache/lib/dialog/import';
|
|
5
|
+
import { LibIcon } from 'esoftplay/cache/lib/icon/import';
|
|
5
6
|
import { LibImage } from 'esoftplay/cache/lib/image/import';
|
|
6
7
|
import { LibNet_status } from 'esoftplay/cache/lib/net_status/import';
|
|
7
8
|
import { LibProgress } from 'esoftplay/cache/lib/progress/import';
|
|
@@ -14,14 +15,12 @@ import Navs from 'esoftplay/cache/navs';
|
|
|
14
15
|
import { UseDeeplink } from 'esoftplay/cache/use/deeplink/import';
|
|
15
16
|
import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
16
17
|
import { UserHook } from 'esoftplay/cache/user/hook/import';
|
|
17
|
-
import { LibIcon } from 'esoftplay/cache/lib/icon/import';
|
|
18
18
|
import { UserLoading } from 'esoftplay/cache/user/loading/import';
|
|
19
19
|
import { UserRoutes } from 'esoftplay/cache/user/routes/import';
|
|
20
20
|
import useGlobalState from 'esoftplay/global';
|
|
21
|
-
import _global from 'esoftplay/_global';
|
|
22
21
|
import * as Font from "expo-font";
|
|
23
22
|
import React, { useEffect, useLayoutEffect } from 'react';
|
|
24
|
-
import { Platform, Pressable,
|
|
23
|
+
import { Platform, Pressable, View } from "react-native";
|
|
25
24
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
26
25
|
|
|
27
26
|
export interface UserIndexProps {
|
|
@@ -46,18 +45,6 @@ function setFonts(): Promise<void> {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
function isWorkerReady(onReady: () => void): void {
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
if (_global.WorkerReady < 1) {
|
|
53
|
-
|
|
54
|
-
setTimeout(() => isWorkerReady(onReady), 10)
|
|
55
|
-
} else {
|
|
56
|
-
onReady()
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
48
|
const route = useGlobalState<any>(undefined, { persistKey: 'user_index_routes_initial' })
|
|
62
49
|
export default function m(props: UserIndexProps): any {
|
|
63
50
|
const [loading, setLoading] = useSafeState(true)
|
|
@@ -77,7 +64,7 @@ export default function m(props: UserIndexProps): any {
|
|
|
77
64
|
}
|
|
78
65
|
|
|
79
66
|
useLayoutEffect(() => {
|
|
80
|
-
let limitReady =
|
|
67
|
+
let limitReady = 2
|
|
81
68
|
|
|
82
69
|
if (esp.config("asyncWorker") == true) {
|
|
83
70
|
limitReady = 2
|
|
@@ -89,16 +76,6 @@ export default function m(props: UserIndexProps): any {
|
|
|
89
76
|
}
|
|
90
77
|
}
|
|
91
78
|
|
|
92
|
-
if (limitReady == 3) {
|
|
93
|
-
|
|
94
|
-
isWorkerReady(() => {
|
|
95
|
-
ready.current += 1
|
|
96
|
-
if (ready.current >= limitReady) {
|
|
97
|
-
setLoading(false)
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
|
|
102
79
|
(async () => {
|
|
103
80
|
await setFonts()
|
|
104
81
|
ready.current += 1
|