esoftplay 0.0.134 → 0.0.135-a

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
@@ -28,7 +28,7 @@ if (fs.existsSync(packjson)) {
28
28
  /* ADD SCRIPTS.PRESTART AND SCRIPTS.POSTSTOP */
29
29
 
30
30
  if (args[0] == "install") {
31
- $package.scripts.start = "esp start && expo start --dev-client"
31
+ $package.scripts.start = "esp start && npx expo start --dev-client"
32
32
  $package.trustedDependencies = [
33
33
  "esoftplay",
34
34
  "esoftplay-android-print",
@@ -39,6 +39,8 @@ if (fs.existsSync(packjson)) {
39
39
  "esoftplay-log",
40
40
  "esoftplay-market",
41
41
  "esoftplay-ppob",
42
+ "esoftplay-web",
43
+ "esoftplay-web-pwa"
42
44
  ]
43
45
  fs.writeFile(packjson, JSON.stringify($package, null, 2), (err) => {
44
46
  if (err) throw err;
@@ -87,7 +89,7 @@ if (fs.existsSync(packjson)) {
87
89
  try {
88
90
  $appjson = JSON.parse(fs.readFileSync(appjson, 'utf8')) || {};
89
91
  } catch (error) { }
90
- if (!$appjson.expo.hasOwnProperty('runtimeVersion')) {
92
+ if (!$appjson?.expo?.hasOwnProperty?.('runtimeVersion')) {
91
93
  $appjson.expo.runtimeVersion = "1"
92
94
  $appjson.expo.android = {
93
95
  "package": "com.domain",
@@ -248,6 +250,8 @@ config.json\n\
248
250
  config.debug.json\n\
249
251
  config.live.json\n\
250
252
  node_modules/\n\
253
+ code-signing/\n\
254
+ certificate.pem\n\
251
255
  web-build/\n\
252
256
  npm-debug.*\n\
253
257
  package-lock.json\n\
package/bin/cli.js CHANGED
@@ -480,6 +480,7 @@ function publish(notes) {
480
480
  jsEng(appdebug, true)
481
481
  jsEng(applive, true)
482
482
  let status = "-"
483
+ let isCustomServer = false
483
484
  let ajson = readToJSON(appjson)
484
485
  let pack = readToJSON(packjson)
485
486
  if (fs.existsSync(confjson)) {
@@ -500,6 +501,9 @@ function publish(notes) {
500
501
  if (fs.existsSync(appdebug)) {
501
502
  adebug = readToJSON(appdebug)
502
503
  }
504
+ if (ajson.expo.updates.url) {
505
+ isCustomServer = true
506
+ }
503
507
  if (clive) {
504
508
  if (clive.config.domain == cjson.config.domain) {
505
509
  status = "live"
@@ -565,38 +569,109 @@ function publish(notes) {
565
569
  ajson.config.publish_id = last_id + 1
566
570
  fs.writeFileSync(appjson, JSON.stringify(ajson, undefined, 2))
567
571
  consoleSucces("start publishing " + status.toUpperCase() + " - PUBLISH_ID : " + (last_id + 1))
568
- command("expo p")
569
- consoleSucces("Berhasil")
570
- const os = require('os')
571
- var d = new Date();
572
- d = new Date(d.getTime() - 3000000);
573
- var date_format_str = d.getFullYear().toString() + "-" + ((d.getMonth() + 1).toString().length == 2 ? (d.getMonth() + 1).toString() : "0" + (d.getMonth() + 1).toString()) + "-" + (d.getDate().toString().length == 2 ? d.getDate().toString() : "0" + d.getDate().toString());
574
- let stringBuilder = "#" + ajson.expo.slug + "\n" + cjson.config.domain + "\n" + os.userInfo().username + '@' + os.hostname() + "\n" + date_format_str + "\nsdk: " + pack.dependencies.expo + "\nruntimeVersion: " + ajson.expo.runtimeVersion
575
- stringBuilder += "\nid: " + (last_id + 1)
576
- let esplibs = Object.keys(pack.dependencies).filter((key) => key.includes("esoftplay"))
577
- esplibs.forEach((key) => {
578
- stringBuilder += ("\n" + key + ": " + pack.dependencies[key])
579
- })
580
- const { exec } = require('child_process');
581
- exec("publisher=$(npx expo whoami &); echo $publisher;", (error, stdout, stderr) => {
582
- if (error) {
583
- console.error(`exec error: ${error}`);
584
- return;
572
+ if (isCustomServer) {
573
+ if (!fs.existsSync('/var/www/html/ota/')) {
574
+ consoleError("ota not found at /var/www/html/ota, please clone it first!")
575
+ return
585
576
  }
586
- let accountName = stdout.trim();
587
- stringBuilder += "\npublisher: @" + accountName + "\n"
588
- stringBuilder += (notes != '' ? ("\n\n- " + notes) : '')
589
- tm(stringBuilder)
590
- if (notes.startsWith('*') && ajson.config.publish_id) {
591
- const config = readToJSON(confjson).config;
592
- const ajson = readToJSON(appjson);
593
- const url = config.publish_uri + ajson.config.publish_id
594
- const fetch = require('node-fetch')
595
- console.log("\n\nPROCESSING FORCE UPDATE")
596
- fetch(url).then((res) => JSON.stringify(res.json(), undefined, 2)).then(consoleSucces)
577
+ const isUpdateExist = fs.existsSync('/var/www/html/ota/updates/' + ajson.expo.runtimeVersion)
578
+ let currentUpdate;
579
+ let date_format_str;
580
+ if (isUpdateExist) {
581
+ currentUpdate = fs.readdirSync('/var/www/html/ota/updates/' + ajson.expo.runtimeVersion)[0]
582
+ var d = new Date(currentUpdate * 1000).toISOString();
583
+ date_format_str = d
597
584
  }
598
- });
585
+ var out = false
586
+ const rl = readline.createInterface({
587
+ input: process.stdin,
588
+ output: process.stdout
589
+ });
599
590
 
591
+ rl.question(`
592
+ --- Detail Publish ---
593
+ Nama Aplikasi : ${ajson.expo.name}
594
+ isDebug : ${cjson.config.isDebug}
595
+ runtimeVersion : ${ajson.expo.runtimeVersion}
596
+ Update terakhir: ${currentUpdate ? date_format_str : '- not found'}
597
+
598
+ Pastikan data sudah benar sebelum anda melanjutkan, lanjut publish(y/n)?`,
599
+ function (input) {
600
+ out = input
601
+ rl.close();
602
+ });
603
+
604
+ rl.on("close", function () {
605
+ if (out && out.toLowerCase() == 'y') {
606
+ command("rm -rf ./dist && esp start && currentPath=$(pwd) && cd /var/www/html/ota/ && npm run publish $currentPath \"" + notes + "\" && cd $currentPath && rm -rf ./dist")
607
+ consoleSucces("Berhasil")
608
+ const os = require('os')
609
+ var d = new Date();
610
+ d = new Date(d.getTime() - 3000000);
611
+ var date_format_str = d.getFullYear().toString() + "-" + ((d.getMonth() + 1).toString().length == 2 ? (d.getMonth() + 1).toString() : "0" + (d.getMonth() + 1).toString()) + "-" + (d.getDate().toString().length == 2 ? d.getDate().toString() : "0" + d.getDate().toString());
612
+ let stringBuilder = "#" + ajson.expo.slug + "\n" + cjson.config.domain + "\n" + os.userInfo().username + '@' + os.hostname() + "\n" + date_format_str + "\nsdk: " + pack.dependencies.expo + "\nruntimeVersion: " + ajson.expo.runtimeVersion
613
+ stringBuilder += "\nid: " + (last_id + 1)
614
+ let esplibs = Object.keys(pack.dependencies).filter((key) => key.includes("esoftplay"))
615
+ esplibs.forEach((key) => {
616
+ stringBuilder += ("\n" + key + ": " + pack.dependencies[key])
617
+ })
618
+ const { exec } = require('child_process');
619
+ exec("publisher=$(npx expo whoami &); echo $publisher;", (error, stdout, stderr) => {
620
+ if (error) {
621
+ console.error(`exec error: ${error}`);
622
+ return;
623
+ }
624
+ let accountName = stdout.trim();
625
+ stringBuilder += "\npublisher: @" + accountName + "\n"
626
+ stringBuilder += (notes != '' ? ("\n\n- " + notes) : '')
627
+ tm(stringBuilder)
628
+ if (notes.startsWith('*') && ajson.config.publish_id) {
629
+ const config = readToJSON(confjson).config;
630
+ const ajson = readToJSON(appjson);
631
+ const url = config.publish_uri + ajson.config.publish_id
632
+ const fetch = require('node-fetch')
633
+ console.log("\n\nPROCESSING FORCE UPDATE")
634
+ fetch(url).then((res) => JSON.stringify(res.json(), undefined, 2)).then(consoleSucces)
635
+ }
636
+ });
637
+ } else {
638
+ consoleError("Build Canceled")
639
+ }
640
+ });
641
+ return
642
+ } else {
643
+ command("expo p")
644
+ consoleSucces("Berhasil")
645
+ const os = require('os')
646
+ var d = new Date();
647
+ d = new Date(d.getTime() - 3000000);
648
+ var date_format_str = d.getFullYear().toString() + "-" + ((d.getMonth() + 1).toString().length == 2 ? (d.getMonth() + 1).toString() : "0" + (d.getMonth() + 1).toString()) + "-" + (d.getDate().toString().length == 2 ? d.getDate().toString() : "0" + d.getDate().toString());
649
+ let stringBuilder = "#" + ajson.expo.slug + "\n" + cjson.config.domain + "\n" + os.userInfo().username + '@' + os.hostname() + "\n" + date_format_str + "\nsdk: " + pack.dependencies.expo + "\nruntimeVersion: " + ajson.expo.runtimeVersion
650
+ stringBuilder += "\nid: " + (last_id + 1)
651
+ let esplibs = Object.keys(pack.dependencies).filter((key) => key.includes("esoftplay"))
652
+ esplibs.forEach((key) => {
653
+ stringBuilder += ("\n" + key + ": " + pack.dependencies[key])
654
+ })
655
+ const { exec } = require('child_process');
656
+ exec("publisher=$(npx expo whoami &); echo $publisher;", (error, stdout, stderr) => {
657
+ if (error) {
658
+ console.error(`exec error: ${error}`);
659
+ return;
660
+ }
661
+ let accountName = stdout.trim();
662
+ stringBuilder += "\npublisher: @" + accountName + "\n"
663
+ stringBuilder += (notes != '' ? ("\n\n- " + notes) : '')
664
+ tm(stringBuilder)
665
+ if (notes.startsWith('*') && ajson.config.publish_id) {
666
+ const config = readToJSON(confjson).config;
667
+ const ajson = readToJSON(appjson);
668
+ const url = config.publish_uri + ajson.config.publish_id
669
+ const fetch = require('node-fetch')
670
+ console.log("\n\nPROCESSING FORCE UPDATE")
671
+ fetch(url).then((res) => JSON.stringify(res.json(), undefined, 2)).then(consoleSucces)
672
+ }
673
+ });
674
+ }
600
675
  }
601
676
  }
602
677
 
@@ -761,6 +836,13 @@ function configAvailable(enabled) {
761
836
  } else {
762
837
  _git = _git.replace(notignore, ignore)
763
838
  }
839
+ var ignore = "code-signing/"
840
+ var notignore = "#code-signing/"
841
+ if (enabled) {
842
+ _git = _git.replace(ignore, notignore)
843
+ } else {
844
+ _git = _git.replace(notignore, ignore)
845
+ }
764
846
  fs.writeFileSync(gitignore, _git, { encoding: 'utf8' })
765
847
  } else {
766
848
  consoleError(gitignore)
@@ -930,7 +1012,11 @@ function build() {
930
1012
  // const oldFileName = fileName.replace(regexPattern, '$1');
931
1013
  let ext = fileName.split(".")
932
1014
  ext.shift()
933
- fs.renameSync('./' + fileName, './' + ajson.expo.name + "-" + Named + "-" + getTime() + "." + ext.join("."))
1015
+ const appname = ajson.expo.name + "-" + Named + "-" + getTime() + "." + ext.join(".")
1016
+ fs.renameSync('./' + fileName, './' + appname)
1017
+ // if (fs.existsSync('./build/post.js')) {
1018
+ // fs.writeFileSync("./build/latestBuildName", appname, { encoding: 'utf8' })
1019
+ // }
934
1020
  });
935
1021
  });
936
1022
  let tmId = "-1001429450501"
package/bin/router.js CHANGED
@@ -161,11 +161,23 @@ if (isChange(tmpDir + "assets.js", Text))
161
161
 
162
162
  /* CREATE INDEX.D.TS */
163
163
  function createIndex() {
164
+ let importer = []
165
+ importer.push(`import useGlobalState from 'esoftplay/global'`)
166
+ importer.push(`import usePersistState from 'esoftplay/persist'`)
167
+ importer.push(`import useGlobalSubscriber from 'esoftplay/subscribe'`)
168
+ importer.push(`import useSafeState from 'esoftplay/state'`)
169
+ importer.push(`import useLazyState from 'esoftplay/lazy'`)
170
+ importer.push(`import Storage from 'esoftplay/storage'`)
171
+ AllRoutes.forEach((nav) => {
172
+ const [module, task] = nav.split('/')
173
+ const comp = ucword(module) + ucword(task)
174
+ importer.push(`import { ${comp} } from ${'"esoftplay/cache/' + module + '/' + task + '/import"'} `)
175
+ })
164
176
  var PreText = ''
165
177
  var Text = `
166
178
  import { Component } from 'react';
167
179
  import { AntDesignTypes, EntypoTypes, EvilIconsTypes, FeatherTypes, FontAwesomeTypes, FontistoTypes, FoundationTypes, IoniconsTypes, MaterialCommunityIconsTypes, MaterialIconsTypes, OcticonsTypes, SimpleLineIconsTypes, ZocialTypes, } from '@expo/vector-icons/build/esoftplay_icons'
168
-
180
+ ${importer.join('\n')}
169
181
  declare module "esoftplay" {
170
182
  function applyStyle<T>(style: T): T;
171
183
  `;
@@ -209,6 +221,8 @@ var AllRoutes = []
209
221
  function createRouter() {
210
222
  var Task = "";
211
223
  var dTask = "";
224
+ var dImportArgs = "";
225
+ var dArgs = "";
212
226
  var dImportTask = "";
213
227
  var TaskProperty = "";
214
228
  var dTaskProperty = "";
@@ -240,6 +254,11 @@ function createRouter() {
240
254
  dImportTaskProperty += `import * as ${ucword(module) + ucword(task) + 'Property'} from '../../.${Modules[module][task]}';\n`;
241
255
  dTaskProperty += `"${nav}": typeof ${ucword(module) + ucword(task) + "Property"};\n\t`;
242
256
 
257
+ if (NavsExclude[nav] == false) {
258
+ dImportArgs += `import { ${ucword(module) + ucword(task) + 'Args }'} from '../../.${Modules[module][task]}';\n`;
259
+ dArgs += `"${nav}": ${ucword(module) + ucword(task) + "Args"};\n\t`;
260
+ }
261
+
243
262
  /* ADD ROUTER EACH FILE FOR STATIC IMPORT */
244
263
  var item = `import { stable } from 'usestable';\n`
245
264
  var deItem = ``
@@ -347,6 +366,18 @@ export interface EspRouterInterface {
347
366
  });
348
367
  }
349
368
 
369
+ Text = `\n${dImportArgs}
370
+ export interface EspArgsInterface {
371
+ ${dArgs}
372
+ }`
373
+ if (isChange(tmpDir + "args.d.ts", Text)) {
374
+ fs.writeFile(tmpDir + "args.d.ts", Text, { flag: 'w' }, function (err) {
375
+ if (err) {
376
+ return console.log(err);
377
+ }
378
+ });
379
+ }
380
+
350
381
  Text = 'function routers(modtask) {' + "\n\t" +
351
382
  'var Out = {}' + "\n\t" +
352
383
  'switch (modtask) {' + "\n" +
@@ -372,6 +403,7 @@ export interface EspRouterInterface {
372
403
  let importer = []
373
404
  let screens = []
374
405
 
406
+
375
407
  Navigations.forEach((nav) => {
376
408
  const orientation = NavsOrientation[nav]
377
409
  const [module, task] = nav.split('/')
package/lazy.ts CHANGED
@@ -1,34 +1,32 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
 
3
- export default function useLazyState<T>(initialState?: T): [T, (newState: T | ((newState: T) => T)) => void, () => T] {
4
- const [, rerender] = useState({})
5
- const dispatch = () => { rerender({}) }
6
- const value = useRef(initialState)
7
- const isMounted = useRef(true)
3
+ export default function useLazyState<T>(initialState?: T): [T, (newValue: T | ((prev: T) => T)) => () => void, () => T] {
4
+ const [, rerender] = useState({});
5
+ const dispatch = () => rerender({});
6
+ const value = useRef<T>(initialState as T);
7
+ const isMounted = useRef(true);
8
8
 
9
- const getter = () => {
10
- return value.current
11
- }
12
-
13
- const setter = (newValue: T) => {
9
+ const setter = (newValue: T | ((prev: T) => T)) => {
14
10
  if (isMounted.current) {
15
- if (typeof newValue == 'function') {
16
- value.current = newValue(value.current)
11
+ if (typeof newValue === 'function') {
12
+ value.current = (newValue as (prev: T) => T)(value.current);
17
13
  } else {
18
14
  value.current = newValue;
19
15
  }
20
16
  }
21
17
  return () => {
22
18
  if (isMounted.current) {
23
- dispatch()
19
+ dispatch();
24
20
  }
25
- }
26
- }
21
+ };
22
+ };
27
23
 
28
24
  useEffect(() => {
29
- isMounted.current = true
30
- return () => { isMounted.current = false }
31
- }, [])
25
+ isMounted.current = true;
26
+ return () => {
27
+ isMounted.current = false;
28
+ };
29
+ }, []);
32
30
 
33
- return [value.current, setter, getter]
34
- }
31
+ return [value.current, setter, () => value.current];
32
+ }
@@ -3,14 +3,14 @@
3
3
 
4
4
  import { useIsFocused } from '@react-navigation/native';
5
5
  import React, { useEffect } from 'react';
6
- import { InteractionManager, View } from 'react-native';
6
+ import { InteractionManager, View, ViewStyle } from 'react-native';
7
7
 
8
8
  export interface LibFocusProps {
9
9
  isFocused?: boolean
10
10
  blurView?: any,
11
11
  onFocus?: () => void,
12
12
  onBlur?: () => void,
13
- style?: any
13
+ style?: ViewStyle,
14
14
  children?: any
15
15
  }
16
16
  export interface LibFocusState {
@@ -26,85 +26,86 @@ import {
26
26
  } from '@expo/vector-icons/build/esoftplay_icons';
27
27
  import { LibComponent } from 'esoftplay/cache/lib/component/import';
28
28
  import React from 'react';
29
+ import { TextStyle } from 'react-native';
29
30
 
30
31
  export interface LibAntDesignIconProps {
31
32
  name: AntDesignTypes,
32
33
  size?: number,
33
34
  color?: string,
34
- style?: any
35
+ style?: TextStyle
35
36
  }
36
37
  export interface LibEvilIconsIconProps {
37
38
  name: EvilIconsTypes,
38
39
  size?: number,
39
40
  color?: string,
40
- style?: any
41
+ style?: TextStyle
41
42
  }
42
43
  export interface LibFeatherIconProps {
43
44
  name: FeatherTypes,
44
45
  size?: number,
45
46
  color?: string,
46
- style?: any
47
+ style?: TextStyle
47
48
  }
48
49
  export interface LibFontAwesomeIconProps {
49
50
  name: FontAwesomeTypes,
50
51
  size?: number,
51
52
  color?: string,
52
- style?: any
53
+ style?: TextStyle
53
54
  }
54
55
  export interface LibFontistoIconProps {
55
56
  name: FontistoTypes,
56
57
  size?: number,
57
58
  color?: string,
58
- style?: any
59
+ style?: TextStyle
59
60
  }
60
61
  export interface LibFoundationIconProps {
61
62
  name: FoundationTypes,
62
63
  size?: number,
63
64
  color?: string,
64
- style?: any
65
+ style?: TextStyle
65
66
  }
66
67
  export interface LibMaterialIconsIconProps {
67
68
  name: MaterialIconsTypes,
68
69
  size?: number,
69
70
  color?: string,
70
- style?: any
71
+ style?: TextStyle
71
72
  }
72
73
  export interface LibEntypoIconProps {
73
74
  name: EntypoTypes,
74
75
  size?: number,
75
76
  color?: string,
76
- style?: any
77
+ style?: TextStyle
77
78
  }
78
79
  export interface LibOcticonsIconProps {
79
80
  name: OcticonsTypes,
80
81
  size?: number,
81
82
  color?: string,
82
- style?: any
83
+ style?: TextStyle
83
84
  }
84
85
  export interface LibZocialIconProps {
85
86
  name: ZocialTypes,
86
87
  size?: number,
87
88
  color?: string,
88
- style?: any
89
+ style?: TextStyle
89
90
  }
90
91
  export interface LibSimpleLineIconProps {
91
92
  name: SimpleLineIconsTypes,
92
93
  size?: number,
93
94
  color?: string,
94
- style?: any
95
+ style?: TextStyle
95
96
  }
96
97
  export interface LibIoniconsProps {
97
98
  name: IoniconsTypes,
98
99
  size?: number,
99
100
  color?: string,
100
- style?: any
101
+ style?: TextStyle
101
102
  }
102
103
 
103
104
  export interface LibIconProps {
104
105
  name: MaterialCommunityIconsTypes,
105
106
  size?: number,
106
107
  color?: string,
107
- style?: any
108
+ style?: TextStyle
108
109
  }
109
110
 
110
111
  export type LibIconStyle = MaterialCommunityIconsTypes
@@ -1,8 +1,7 @@
1
1
  // noPage
2
- import { FlashList } from "@shopify/flash-list";
2
+ import { ContentStyle, FlashList } from "@shopify/flash-list";
3
3
  import { LibComponent } from 'esoftplay/cache/lib/component/import';
4
4
  import { LibCurl } from 'esoftplay/cache/lib/curl/import';
5
- import { LibListItemLayout } from 'esoftplay/cache/lib/list/import';
6
5
  import { LibLoading } from 'esoftplay/cache/lib/loading/import';
7
6
  import { LibStyle } from 'esoftplay/cache/lib/style/import';
8
7
  import { LibTextstyle } from 'esoftplay/cache/lib/textstyle/import';
@@ -54,7 +53,7 @@ export interface LibInfiniteProps {
54
53
  renderItem: (item: any, index: number) => any,
55
54
  viewabilityConfig?: any,
56
55
  removeClippedSubviews?: boolean,
57
- style?: any
56
+ style?: ContentStyle
58
57
  }
59
58
 
60
59
  export interface LibInfiniteState {
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  //
5
- import { FlashList } from "@shopify/flash-list";
5
+ import { ContentStyle, FlashList } from "@shopify/flash-list";
6
6
  import { LibComponent } from 'esoftplay/cache/lib/component/import';
7
7
  import React from "react";
8
8
  import { View } from 'react-native';
@@ -41,7 +41,7 @@ export interface LibListProps {
41
41
  renderFooter?: () => any,
42
42
  renderItem: (item: any, index: number) => any,
43
43
  viewabilityConfig?: any,
44
- style?: any,
44
+ style?: ContentStyle,
45
45
  removeClippedSubviews?: boolean,
46
46
  }
47
47
 
@@ -2,8 +2,10 @@
2
2
  // withObject
3
3
  import { CommonActions, StackActions } from '@react-navigation/native';
4
4
  import { LibNavigationRoutes } from 'esoftplay';
5
+ import { EspArgsInterface } from 'esoftplay/cache/args';
5
6
  import { UserClass } from 'esoftplay/cache/user/class/import';
6
7
  import { UserRoutes } from 'esoftplay/cache/user/routes/import';
8
+
7
9
  import esp from 'esoftplay/esp';
8
10
  import React from "react";
9
11
 
@@ -35,7 +37,7 @@ export default {
35
37
  }
36
38
  return props?.route?.params?.[key] || defOutput;
37
39
  },
38
- getArgsAll<S>(props: any, defOutput?: any): S {
40
+ getArgsAll<S extends keyof EspArgsInterface>(props: any, defOutput?: any): EspArgsInterface[S] {
39
41
  if (defOutput == undefined) {
40
42
  defOutput = "";
41
43
  }
@@ -61,7 +63,8 @@ export default {
61
63
  delete this._redirect[key]
62
64
  }
63
65
  },
64
- navigate<S>(route: LibNavigationRoutes, params?: S): void {
66
+ /* <T EspRouterInterface>(path: T): EspRouterInterface[T] { */
67
+ navigate<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
65
68
  this._ref?.navigate?.(route, params)
66
69
  },
67
70
  getResultKey(props: any): number {
@@ -85,7 +88,7 @@ export default {
85
88
  }
86
89
  this.back()
87
90
  },
88
- navigateForResult<S>(route: LibNavigationRoutes, params?: S | any, key?: number): Promise<any> {
91
+ navigateForResult<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S], key?: number): Promise<any> {
89
92
  if (!key) {
90
93
  key = 1
91
94
  }
@@ -102,12 +105,12 @@ export default {
102
105
  this.push(route, params)
103
106
  })
104
107
  },
105
- replace<S>(route: LibNavigationRoutes, params?: any): void {
108
+ replace<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
106
109
  this._ref.dispatch(
107
110
  StackActions.replace(route, params)
108
111
  )
109
112
  },
110
- push<S>(route: LibNavigationRoutes, params?: any): void {
113
+ push<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
111
114
  this._ref?.dispatch?.(
112
115
  StackActions.push(
113
116
  route,
@@ -1,6 +1,7 @@
1
1
  // withHooks
2
2
  // noPage
3
3
  import React from 'react';
4
+ import { ImageStyle } from 'react-native';
4
5
  import FastImage from 'react-native-fast-image';
5
6
 
6
7
  export interface LibPictureSource {
@@ -8,7 +9,7 @@ export interface LibPictureSource {
8
9
  }
9
10
  export interface LibPictureProps {
10
11
  source: LibPictureSource | any,
11
- style: any,
12
+ style: ImageStyle,
12
13
  resizeMode?: "contain" | "cover",
13
14
  noCache?: boolean,
14
15
  onError?: () => void,
@@ -2,15 +2,15 @@
2
2
  // noPage
3
3
 
4
4
  import React, { useEffect, useRef, useState } from 'react';
5
- import { TextInput, View } from 'react-native';
5
+ import { TextInput, View, ViewStyle } from 'react-native';
6
6
 
7
7
  export interface LibPinProps {
8
8
  length: number,
9
9
  onChangePin: (pin: string) => void
10
- boxStyle?: any,
10
+ boxStyle?: ViewStyle,
11
11
  overrideKeyboard?: boolean,
12
12
  pinValue?: string,
13
- pinStyle?: any
13
+ pinStyle?: ViewStyle
14
14
  }
15
15
  export default function m(props: LibPinProps): any {
16
16
  const [pin, setPin] = useState<string[]>([])
@@ -6,14 +6,15 @@ import {
6
6
  Dimensions,
7
7
  Platform, ScrollView, StyleSheet,
8
8
  Text,
9
- View
9
+ View,
10
+ ViewStyle
10
11
  } from 'react-native';
11
12
 
12
13
  export interface LibScrollpickerProps {
13
14
  itemHeight: number;
14
15
  wrapperHeight: number;
15
16
  selectedIndex: number;
16
- style?: any;
17
+ style?: ViewStyle;
17
18
  highlightColor: string;
18
19
  wrapperColor: string;
19
20
  renderItem: (item: any, index: number, isSelected: boolean) => any;
@@ -1,11 +1,11 @@
1
1
  // noPage
2
2
  import { LibComponent } from 'esoftplay/cache/lib/component/import';
3
3
  import React from "react";
4
- import { StyleSheet, Text } from "react-native";
4
+ import { StyleSheet, Text, TextStyle } from "react-native";
5
5
 
6
6
  export interface LibTextstyleProps {
7
7
  textStyle: "largeTitle" | "title1" | "title2" | "title3" | "headline" | "body" | "callout" | "subhead" | "footnote" | "caption1" | "caption2" | "m_h1" | "m_h2" | "m_h3" | "m_h4" | "m_h5" | "m_h6" | "m_subtitle1" | "m_subtitle2" | "m_body1" | "m_body2" | "m_button" | "m_caption" | "m_overline",
8
- style?: any,
8
+ style?: TextStyle,
9
9
  children?: string | "",
10
10
  numberOfLines?: number,
11
11
  ellipsizeMode?: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.134",
3
+ "version": "0.0.135-a",
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",
package/state.ts CHANGED
@@ -4,23 +4,23 @@ type useSafeStateReturn<T> = [T, (newState: T | ((newState: T) => T)) => void, (
4
4
 
5
5
  export default function useSafeState<T = any>(defaultValue?: T): useSafeStateReturn<T> {
6
6
  const isMountedRef = useRef<boolean>(true);
7
- const valueRef = useRef(defaultValue)
8
- const [, rerender] = useState({})
7
+ const valueRef = useRef<T>(defaultValue as T);
8
+ const [, rerender] = useState({});
9
9
 
10
- const updateState = useCallback((value: T | undefined) => {
10
+ const updateState = useCallback((value: T | ((prevState: T) => T)) => {
11
11
  if (isMountedRef.current) {
12
- if (typeof value == 'function') {
13
- valueRef.current = value(valueRef.current)
12
+ if (typeof value === 'function') {
13
+ valueRef.current = (value as (prevState: T) => T)(valueRef.current);
14
14
  } else {
15
15
  valueRef.current = value;
16
16
  }
17
- rerender({})
17
+ rerender({});
18
18
  }
19
19
  }, []);
20
20
 
21
21
  const getter = () => {
22
- return valueRef.current
23
- }
22
+ return valueRef.current;
23
+ };
24
24
 
25
25
  useEffect(() => {
26
26
  isMountedRef.current = true;