esoftplay 0.0.142-c → 0.0.142-e

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
@@ -1237,6 +1237,12 @@ function switchStatus(status) {
1237
1237
  const [usr, pwd] = cjson.config.build
1238
1238
  command(`eas logout && expect -c 'spawn eas login; expect "Email or username"; send "${usr}\r"; expect "Password"; send "${pwd}\r"; expect eof;'`)
1239
1239
  }
1240
+ if (cjson.config.hasOwnProperty('post_script')) {
1241
+ eval(cjson.config.post_script)
1242
+ }
1243
+ }
1244
+ if (valid) {
1245
+
1240
1246
  }
1241
1247
  }
1242
1248
  if (valid && fs.existsSync(gplist))
@@ -0,0 +1,68 @@
1
+ // withHooks
2
+
3
+ import { ComponentMessage } from 'esoftplay/cache/component/message/import';
4
+ import { LibCurl } from 'esoftplay/cache/lib/curl/import';
5
+ import { LibLoading } from 'esoftplay/cache/lib/loading/import';
6
+ import { LibUtils } from 'esoftplay/cache/lib/utils/import';
7
+ import { UserData } from 'esoftplay/cache/user/data/import';
8
+ import FastStorage from 'esoftplay/mmkv';
9
+ import useSafeState from 'esoftplay/state';
10
+ import React, { ReactElement, useEffect } from 'react';
11
+
12
+
13
+ export interface LibCurl_viewArgs {
14
+
15
+ }
16
+
17
+ export interface LibCurl_viewProps {
18
+ url: string;
19
+ post?: any;
20
+ cache?: boolean;
21
+ isUserData?: boolean;
22
+ onSuccess?: (res: any, message: string) => ReactElement;
23
+ onError?: (err: any, retry: Function) => ReactElement;
24
+ onLoading?: ReactElement;
25
+ }
26
+ export default function m(props: LibCurl_viewProps): any {
27
+
28
+ let key = ""
29
+ let initialData: any = undefined
30
+ if (props.cache) {
31
+
32
+ key = "curl-view" + LibUtils.shorten(props.url + JSON.stringify(props.post))
33
+ if (props.isUserData) {
34
+ UserData.register(key)
35
+ }
36
+ try {
37
+ initialData = JSON.parse(FastStorage.getItemSync(key))
38
+ } catch (error) { }
39
+ }
40
+
41
+ const [data, setData] = useSafeState(initialData)
42
+
43
+ function fetchData() {
44
+ new LibCurl(props.url, props.post, (result, message) => {
45
+ if (props.cache) {
46
+ FastStorage.setItem(key, JSON.stringify({ result, message }))
47
+ }
48
+ setData({ result, message })
49
+ }, (err) => {
50
+ setData(err)
51
+ })
52
+ }
53
+
54
+ function retry() {
55
+ setData(initialData)
56
+ fetchData()
57
+ }
58
+
59
+ useEffect(fetchData, []);
60
+
61
+ if (!data) {
62
+ return props.onLoading ? props.onLoading : <LibLoading />
63
+ }
64
+ if (data.ok == 0) {
65
+ return props.onError ? props.onError(data, retry) : <ComponentMessage message={data.message} />
66
+ }
67
+ return props.onSuccess ? props.onSuccess(data.result, data.message) : null
68
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.142-c",
3
+ "version": "0.0.142-e",
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",