esoftplay 0.0.119-b → 0.0.119-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.
Files changed (69) hide show
  1. package/bin/router.js +77 -49
  2. package/global.ts +0 -2
  3. package/import_migrator.mjs +44 -0
  4. package/{modules/lib → libs}/worker.tsx +63 -75
  5. package/modules/lib/carrousel.tsx +4 -1
  6. package/modules/lib/carrousel_snap.tsx +3 -1
  7. package/modules/lib/collaps.tsx +2 -1
  8. package/modules/lib/{component.ts → component.tsx} +0 -0
  9. package/modules/lib/crypt.js +3 -1
  10. package/modules/lib/curl.ts +9 -1
  11. package/modules/lib/datepicker.tsx +6 -1
  12. package/modules/lib/dialog.tsx +8 -1
  13. package/modules/lib/direct_image.tsx +3 -1
  14. package/modules/lib/direct_text.tsx +3 -1
  15. package/modules/lib/document.ts +4 -1
  16. package/modules/lib/effect.tsx +3 -1
  17. package/modules/lib/gallery.tsx +5 -1
  18. package/modules/lib/icon.tsx +27 -22
  19. package/modules/lib/image.tsx +7 -1
  20. package/modules/lib/image_crop.tsx +8 -1
  21. package/modules/lib/image_multi.tsx +11 -2
  22. package/modules/lib/image_shadow.tsx +2 -1
  23. package/modules/lib/infinite.tsx +12 -2
  24. package/modules/lib/input.tsx +6 -1
  25. package/modules/lib/input_base.tsx +3 -1
  26. package/modules/lib/lazy.tsx +1 -1
  27. package/modules/lib/list.tsx +6 -2
  28. package/modules/lib/loading.tsx +3 -1
  29. package/modules/lib/locale.ts +2 -1
  30. package/modules/lib/navigation.ts +8 -2
  31. package/modules/lib/net_status.tsx +2 -2
  32. package/modules/lib/notification.ts +9 -1
  33. package/modules/lib/notify.ts +3 -1
  34. package/modules/lib/picture.tsx +5 -2
  35. package/modules/lib/progress.tsx +5 -1
  36. package/modules/lib/roll.tsx +6 -1
  37. package/modules/lib/scroll.tsx +2 -1
  38. package/modules/lib/scrollpicker.tsx +2 -1
  39. package/modules/lib/skeleton.tsx +3 -2
  40. package/modules/lib/slidingup.tsx +5 -1
  41. package/modules/lib/sociallogin.tsx +4 -2
  42. package/modules/lib/tabs.tsx +4 -1
  43. package/modules/lib/textstyle.tsx +2 -1
  44. package/modules/lib/theme.tsx +3 -2
  45. package/modules/lib/timepicker.tsx +3 -1
  46. package/modules/lib/toast.tsx +2 -1
  47. package/modules/lib/updater.tsx +8 -5
  48. package/modules/lib/utils.ts +2 -1
  49. package/modules/lib/version.tsx +9 -1
  50. package/modules/lib/video.tsx +3 -1
  51. package/modules/lib/webview.tsx +2 -1
  52. package/modules/lib/workloop.tsx +4 -1
  53. package/modules/use/connect.ts +2 -1
  54. package/modules/use/curl.ts +3 -1
  55. package/modules/use/deeplink.ts +4 -1
  56. package/modules/use/form.ts +1 -1
  57. package/modules/use/form_persist.ts +1 -2
  58. package/modules/user/class.ts +6 -2
  59. package/modules/user/data.ts +1 -2
  60. package/modules/user/hook.tsx +2 -1
  61. package/modules/user/index.tsx +20 -8
  62. package/modules/user/loading.tsx +1 -1
  63. package/modules/user/login.tsx +8 -5
  64. package/modules/user/notifbadge.tsx +3 -2
  65. package/modules/user/notification.tsx +8 -1
  66. package/modules/user/notification_item.tsx +3 -1
  67. package/modules/user/routes.ts +1 -1
  68. package/package.json +1 -1
  69. package/modules/lib/workview.tsx +0 -33
package/bin/router.js CHANGED
@@ -239,7 +239,7 @@ checks.forEach(modules => {
239
239
  tmpTask[clsName]["class"] = m[1].replace(m[2], clsName).trim();
240
240
 
241
241
  /* tambahkan fungsi Crypt */
242
- if (clsName == 'LibCrypt') {
242
+ if (clsName === 'LibCrypt') {
243
243
  tmpTask[clsName]["function"]['encode'] = 'encode(text: string): string;';
244
244
  tmpTask[clsName]["function"]['decode'] = 'decode(text: string): string;';
245
245
  }
@@ -378,7 +378,7 @@ if (isChange(tmpDir + "assets.js", Text))
378
378
 
379
379
  /* CREATE INDEX.D.TS */
380
380
  function createIndex() {
381
-
381
+ var PreText = ''
382
382
  var Text = `
383
383
  import { Component } from 'react';
384
384
  import { AntDesignTypes, EntypoTypes, EvilIconsTypes, FeatherTypes, FontAwesomeTypes, FontistoTypes, FoundationTypes, IoniconsTypes, MaterialCommunityIconsTypes, MaterialIconsTypes, OcticonsTypes, SimpleLineIconsTypes, ZocialTypes, } from '@expo/vector-icons/build/esoftplay_icons'
@@ -460,71 +460,88 @@ declare module "esoftplay" {
460
460
  }
461
461
  function createCache<S>(initialCache?: S, option?: createCacheOption): createCacheReturn<S>;`;
462
462
  for (clsName in tmpTask) {
463
+ let ItemText = ""
464
+ if (clsName === 'LibCrypt') {
465
+ tmpTask[clsName]["class"] = "class LibCrypt"
466
+ tmpTask[clsName]["function"]['encode'] = 'encode(text: string): string;';
467
+ tmpTask[clsName]["function"]['decode'] = 'decode(text: string): string;';
468
+ }
463
469
  if (tmpTask[clsName]["class"]) {
464
- // Text += "\n";
470
+ // ItemText += "\n";
465
471
  for (var i = 0; i < tmpTask[clsName]["type"].length; i++) {
466
- Text += "\n " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
472
+ ItemText += "\n " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
467
473
  }
468
474
  for (var i = 0; i < tmpTask[clsName]["interface"].length; i++) {
469
- Text += "\n " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
475
+ ItemText += "\n " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
470
476
  }
471
- Text += "\n " + tmpTask[clsName]["class"] + " {";
477
+ ItemText += "\n export " + tmpTask[clsName]["class"] + " {";
472
478
  var isFilled = false;
473
479
  for (fun in tmpTask[clsName]["var"]) {
474
- Text += "\n " + tmpTask[clsName]["var"][fun];
480
+ ItemText += "\n " + tmpTask[clsName]["var"][fun];
475
481
  }
476
482
  for (fun in tmpTask[clsName]["function"]) {
477
- Text += "\n " + tmpTask[clsName]["function"][fun];
483
+ ItemText += "\n " + tmpTask[clsName]["function"][fun];
478
484
  isFilled = true;
479
485
  }
480
486
  if (isFilled) {
481
- Text += "\n ";
487
+ ItemText += "\n ";
482
488
  }
483
- // Text += "}\n";
484
- Text += "}";
489
+ // ItemText += "}\n";
490
+ ItemText += "}";
485
491
  } else if (tmpTask[clsName]["hooks"]) {
486
492
  for (var i = 0; i < tmpTask[clsName]["interface"].length; i++) {
487
- Text += "\n " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
493
+ ItemText += "\n export " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
488
494
  }
489
- Text += "\n " + tmpTask[clsName]["hooks"];
495
+ ItemText += "\n export " + tmpTask[clsName]["hooks"];
490
496
  for (var i = 0; i < tmpTask[clsName]["type"].length; i++) {
491
- Text += "\n " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
497
+ ItemText += "\n export " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
492
498
  }
493
499
  var isFilled = false;
494
- Text += "\n " + tmpTask[clsName]["namespaces"] + " {";
500
+ ItemText += "\n export " + tmpTask[clsName]["namespaces"] + " {";
495
501
  for (fun in tmpTask[clsName]["var"]) {
496
- Text += "\n " + tmpTask[clsName]["var"][fun];
502
+ ItemText += "\n export " + tmpTask[clsName]["var"][fun];
497
503
  }
498
504
  for (fun in tmpTask[clsName]["function"]) {
499
- Text += "\n " + tmpTask[clsName]["function"][fun];
505
+ ItemText += "\n export " + tmpTask[clsName]["function"][fun];
500
506
  isFilled = true;
501
507
  }
502
508
  if (isFilled) {
503
- Text += "\n ";
509
+ ItemText += "\n ";
504
510
  }
505
- Text += "}";
511
+ ItemText += "}";
506
512
  } else if (tmpTask[clsName]["uselibs"]) {
507
513
  for (var i = 0; i < tmpTask[clsName]["interface"].length; i++) {
508
- Text += "\n " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
514
+ ItemText += "\n export " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
509
515
  }
510
- Text += "\n " + tmpTask[clsName]["uselibs"];
516
+ ItemText += "\n export " + tmpTask[clsName]["uselibs"];
511
517
  for (var i = 0; i < tmpTask[clsName]["type"].length; i++) {
512
- Text += "\n " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
518
+ ItemText += "\n export " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
513
519
  }
514
520
  var isFilled = false;
515
- Text += "\n " + tmpTask[clsName]["namespaces"] + " {";
521
+ ItemText += "\n export " + tmpTask[clsName]["namespaces"] + " {";
516
522
  for (fun in tmpTask[clsName]["var"]) {
517
- Text += "\n " + tmpTask[clsName]["var"][fun];
523
+ ItemText += "\n export " + tmpTask[clsName]["var"][fun];
518
524
  }
519
525
  for (fun in tmpTask[clsName]["function"]) {
520
- Text += "\n " + tmpTask[clsName]["function"][fun];
526
+ ItemText += "\n export " + tmpTask[clsName]["function"][fun];
521
527
  isFilled = true;
522
528
  }
523
529
  if (isFilled) {
524
- Text += "\n ";
530
+ ItemText += "\n ";
525
531
  }
526
- Text += "}";
532
+ ItemText += "}";
527
533
  }
534
+ const [module, task] = clsName.split(/(?=[A-Z])/)
535
+ const nav = module?.toLowerCase() + '/' + task?.toLowerCase()
536
+ try {
537
+ fs.mkdirSync(tmpDir + module?.toLowerCase())
538
+ } catch (error) { }
539
+ PreText += "import '" + tmpDir + nav + ".import.d';\n"
540
+ fs.writeFile(tmpDir + nav + '.import.d.ts', ItemText, { flag: 'w' }, function (err) {
541
+ if (err) {
542
+ return console.log(err);
543
+ }
544
+ });
528
545
  }
529
546
  Text += "\n\ttype LibNavigationRoutes = \"" + Navigations.join("\" |\n\t\t\t \"") + "\"\n"
530
547
  Text += "\n\ttype AllRoutes = \"" + AllRoutes.join("\" |\n\t\t\t \"") + "\"\n"
@@ -536,8 +553,8 @@ declare module "esoftplay" {
536
553
  const Words = v.split("/")
537
554
  return `\t\tT extends "${v}" ? typeof ${ucword(Words[0]) + ucword(Words[1]) + "Property"} :`
538
555
  }).join("\n") + "\nnever;\n"
539
- Text += "}"
540
-
556
+ Text += "}\n"
557
+ Text = PreText + Text
541
558
  if (isChange(typesDir + "index.d.ts", Text)) {
542
559
  fs.writeFile(typesDir + "index.d.ts", Text, { flag: 'w' }, function (err) {
543
560
  if (err) {
@@ -584,12 +601,16 @@ function createRouter() {
584
601
  var nav = "";
585
602
  var staticImport = []
586
603
 
587
- staticImport.push("var isEqual = require('react-fast-compare');\n")
604
+ // staticImport.push("var isEqual = require('react-fast-compare');\n")
588
605
  staticImport.push("export function applyStyle(style){ return style };\n")
589
606
  staticImport.push("export { default as useGlobalState } from '../../../node_modules/esoftplay/global';\n")
590
607
  staticImport.push("export { default as usePersistState } from '../../../node_modules/esoftplay/persist';\n")
591
608
  staticImport.push("export { default as useSafeState } from '../../../node_modules/esoftplay/state';\n")
592
609
  staticImport.push("export { default as esp } from '../../../node_modules/esoftplay/esp';\n")
610
+ staticImport.push("export { default as createCache } from '../../../node_modules/esoftplay/_cache';\n")
611
+ staticImport.push("export { default as _global } from '../../../node_modules/esoftplay/_global';\n")
612
+ staticImport.push("import { stable } from 'usestable';\n")
613
+
593
614
  for (const module in Modules) {
594
615
  for (const task in Modules[module]) {
595
616
  nav = module + '/' + task;
@@ -600,7 +621,7 @@ function createRouter() {
600
621
  Task += "\t\t" + 'case "' + nav + '":' + "\n\t\t\t" + 'Out = require("../../.' + Modules[module][task] + '")?.default' + "\n\t\t\t" + 'break;' + "\n";
601
622
  TaskProperty += "\t\t" + 'case "' + nav + '":' + "\n\t\t\t" + 'Out = require("../../.' + Modules[module][task] + '")' + "\n\t\t\t" + 'break;' + "\n";
602
623
  /* ADD ROUTER EACH FILE FOR STATIC IMPORT */
603
- var item = "import { default as _" + ucword(module) + ucword(task) + " } from '../../." + Modules[module][task] + "';\n"
624
+ var item = "import { stable } from 'usestable';\nimport { default as _" + ucword(module) + ucword(task) + " } from '../../." + Modules[module][task] + "';\n"
604
625
  if (HookModules.includes(nav)) {
605
626
  item += "" +
606
627
  "import * as " + ucword(module) + ucword(task) + SuffixHooksProperty + " from '../../." + Modules[module][task] + "';\n" +
@@ -614,26 +635,33 @@ function createRouter() {
614
635
  } else {
615
636
  item += "export { _" + ucword(module) + ucword(task) + " as " + ucword(module) + ucword(task) + " };\n"
616
637
  }
617
- if (module == 'lib' && task == 'component') {
618
- staticImport.splice(2, 0, item)
619
- } else if (module == 'lib' && task == 'style') {
620
- staticImport.splice(4, 0, item)
621
- } else if (module == 'lib' && task == 'worker') {
622
- staticImport.splice(4, 0, item)
623
- } else if (module == 'lib' && task == 'navigation') {
624
- staticImport.splice(4, 0, item)
625
- } else if (task == 'style') {
626
- staticImport.splice(9, 0, item)
627
- } else if (task == 'scrollpicker') {
628
- staticImport.splice(10, 0, item)
629
- } else {
630
- staticImport.push(item);
631
- }
638
+ try {
639
+ fs.mkdirSync(tmpDir + module)
640
+ } catch (error) { }
641
+ fs.writeFile(tmpDir + nav + '.import.js', item, { flag: 'w' }, function (err) {
642
+ if (err) {
643
+ return console.log(err);
644
+ }
645
+ });
646
+
647
+ // if (module == 'lib' && task == 'component') {
648
+ // staticImport.splice(2, 0, item)
649
+ // } else if (module == 'lib' && task == 'style') {
650
+ // staticImport.splice(4, 0, item)
651
+ // } else if (module == 'lib' && task == 'worker') {
652
+ // staticImport.splice(4, 0, item)
653
+ // } else if (module == 'lib' && task == 'navigation') {
654
+ // staticImport.splice(4, 0, item)
655
+ // } else if (task == 'style') {
656
+ // staticImport.splice(9, 0, item)
657
+ // } else if (task == 'scrollpicker') {
658
+ // staticImport.splice(10, 0, item)
659
+ // } else {
660
+ // staticImport.push(item);
661
+ // }
632
662
  }
633
663
  }
634
- staticImport.splice(2, 0, "export { default as createCache } from '../../../node_modules/esoftplay/_cache';\n")
635
- staticImport.splice(2, 0, "export { default as _global } from '../../../node_modules/esoftplay/_global';\n")
636
- staticImport.splice(2, 0, "import { stable } from 'usestable';\n")
664
+
637
665
  const x = staticImport.join('')
638
666
  if (isChange(tmpDir + 'index.js', x))
639
667
  fs.writeFile(tmpDir + 'index.js', x, { flag: 'w' }, function (err) {
package/global.ts CHANGED
@@ -4,8 +4,6 @@ import { fastFilter, fastLoop } from './fast';
4
4
  const _global = require('./_global')
5
5
  const isEqual = require('react-fast-compare');
6
6
 
7
-
8
-
9
7
  export interface useGlobalReturn<T> {
10
8
  useState: () => [T, (newState: T) => void, () => void],
11
9
  get: () => T,
@@ -0,0 +1,44 @@
1
+ import fs from 'fs'
2
+ const pattern = new RegExp(/\n{0,}import ((.*)) from (?:"esoftplay"|'esoftplay');?/gs)
3
+ if (fs.existsSync('./modules')) {
4
+ fs.readdirSync('./modules').forEach((module) => {
5
+ if (!module.startsWith('.')) {
6
+ fs.readdirSync('./modules/' + module).forEach((task) => {
7
+ // if (task == 'card.tsx') {
8
+ var dFile = fs.readFileSync('./modules/' + module + '/' + task, { encoding: 'utf8' })
9
+ const matchs = dFile.match(pattern)
10
+ if (matchs) {
11
+ let espMod = []
12
+ let nonEspMod = []
13
+ const cmatch = matchs[0]
14
+ const arrModules = cmatch.substring(cmatch.indexOf('{') + 1, cmatch.lastIndexOf('}')).split(',')
15
+ arrModules.forEach((mod) => {
16
+ const modTrim = mod.trim()
17
+ if (modTrim.match(/^[a-z]/g)) {
18
+ console.log("ESP MODULE : " + modTrim)
19
+ espMod.push(modTrim)
20
+ } else {
21
+ nonEspMod.push(modTrim)
22
+ console.log("NON ESP MODULE : " + modTrim)
23
+ }
24
+ })
25
+ let adder = ""
26
+ if (nonEspMod.length > 0) {
27
+ nonEspMod.forEach((non) => {
28
+ if (non) {
29
+ const [module, task] = non.split(/(?=[A-Z])/)
30
+ if (module && task)
31
+ adder += `import { ${non} } from 'esoftplay/cache/${module.toLowerCase()}/${task.toLowerCase()}.import';\n`
32
+ }
33
+ })
34
+ }
35
+ dFile = dFile.replace(cmatch, "\nimport { " + espMod.join(", ") + " } from 'esoftplay';\n" + adder)
36
+ fs.writeFileSync('./modules/' + module + '/' + task, dFile, { encoding: 'utf8' })
37
+ // }
38
+
39
+ }
40
+ // return
41
+ })
42
+ }
43
+ })
44
+ }
@@ -1,47 +1,30 @@
1
- // noPage
2
-
3
- import { _global } from 'esoftplay';
4
- import React, { Component } from "react";
5
- import { Platform } from 'react-native';
6
-
7
-
8
- export interface LibWorkerInit {
9
- task: string,
10
- taskId: string,
11
- result: (res: string) => void
12
- }
13
-
14
- export interface LibWorkerProps {
15
- tasks?: LibWorkerInit[],
16
- }
17
- export interface LibWorkerState {
18
-
19
- }
20
- _global.LibWorkerBase = React.createRef()
21
- _global.LibWorkerTasks = new Map()
1
+ import React from "react";
2
+ import { Platform, View } from 'react-native';
3
+ import WebView from "react-native-webview";
4
+ const _global = require('../_global').default
5
+ const esp = require('../esp').default
6
+
7
+ _global.WorkerBase = React.createRef()
8
+ _global.WorkerTasks = new Map()
22
9
  _global.injectedJavaScripts = []
23
- _global.LibWorkerReady = 0
24
- _global.LibWorkerCount = 0
25
-
26
- export default class m extends Component<LibWorkerProps, LibWorkerState> {
27
- constructor(props: LibWorkerProps) {
28
- super(props)
29
- }
30
- static delete(taskId: string): void {
31
- _global.LibWorkerTasks.delete(taskId)
32
- }
33
-
34
- static registerJob(name: string, func: Function): (params: any[], res: (data: any) => void) => void {
10
+ _global.WorkerReady = 0
11
+ _global.WorkerCount = 0
12
+
13
+ const Worker = {
14
+ delete(taskId: string) {
15
+ _global.WorkerTasks.delete(taskId)
16
+ },
17
+ registerJob(name: string, func: Function): (params: any[], res: (data: any) => void) => void {
35
18
  'show source';
36
19
  const x = func.toString().replace('function', 'function ' + name)
37
20
  _global.injectedJavaScripts.push(x)
38
- m.dispatch(() => x, '', () => { })
21
+ Worker.dispatch(() => x, '', () => { })
39
22
  return (params: (string | number | boolean)[], res: (data: string) => void) => {
40
23
  if (Platform.OS == 'android')
41
24
  if (Platform.Version <= 22) {
42
25
  return res(func(...params))
43
26
  }
44
- m.dispatch(
27
+ Worker.dispatch(
45
28
  (id: number) => {
46
29
  let _params = params.map((param) => {
47
30
  if (typeof param == 'string')
@@ -52,13 +35,12 @@ export default class m extends Component<LibWorkerProps, LibWorkerState> {
52
35
  }
53
36
  , '', res)
54
37
  }
55
- }
56
-
57
- static registerJobAsync(name: string, func: (...fparams: any[]) => Promise<any>): (params: any[], res: (data: any) => void) => void {
38
+ },
39
+ registerJobAsync(name: string, func: (...fparams: any[]) => Promise<any>): (params: any[], res: (data: any) => void) => void {
58
40
  'show source';
59
41
  const x = func.toString().replace('function', 'function ' + name)
60
42
  _global.injectedJavaScripts.push(x)
61
- m.dispatch(() => x, '', () => { })
43
+ Worker.dispatch(() => x, '', () => { })
62
44
  return (params: (string | number | boolean)[], res: (data: string) => void) => {
63
45
  if (Platform.OS == 'android')
64
46
  if (Platform.Version <= 22) {
@@ -66,7 +48,7 @@ export default class m extends Component<LibWorkerProps, LibWorkerState> {
66
48
  return
67
49
  }
68
50
 
69
- m.dispatch(
51
+ Worker.dispatch(
70
52
  (id: number) => {
71
53
  let _params = params.map((param) => {
72
54
  if (typeof param == 'string')
@@ -77,24 +59,22 @@ export default class m extends Component<LibWorkerProps, LibWorkerState> {
77
59
  }
78
60
  , '', res)
79
61
  }
80
- }
81
-
82
- static objToString(data: any): string {
62
+ },
63
+ objToString(data: any): string {
83
64
  if (Platform.OS == 'android')
84
65
  if (Platform.Version <= 22) {
85
66
  return JSON.stringify(data)
86
67
  }
87
68
  return JSON.stringify(JSON.stringify(data)).slice(1, -1);
88
- }
89
-
90
- static jobAsync(func: (...fparams: any[]) => Promise<any>, params: (string | number | boolean)[], res: (data: any) => void): void {
69
+ },
70
+ jobAsync(func: (...fparams: any[]) => Promise<any>, params: (string | number | boolean)[], res: (data: any) => void): void {
91
71
  'show source';
92
72
  if (Platform.OS == 'android')
93
73
  if (Platform.Version <= 22) {
94
74
  (async () => res(await func(...params)))()
95
75
  return
96
76
  }
97
- m.dispatch(
77
+ Worker.dispatch(
98
78
  (id: number) => {
99
79
  const nameFunction = func.toString().replace('function', 'function tempFunction')
100
80
  let _params = params.map((param) => {
@@ -105,15 +85,14 @@ export default class m extends Component<LibWorkerProps, LibWorkerState> {
105
85
  return (`(async () => window.ReactNativeWebView.postMessage(JSON.stringify({ data: await ` + nameFunction + `(` + _params.join(", ") + `), id: ` + id + ` })))();true;`)
106
86
  }
107
87
  , '', res)
108
- }
109
-
110
- static job(func: Function, params: (string | number | boolean)[], res: (data: any) => void): void {
88
+ },
89
+ job(func: Function, params: (string | number | boolean)[], res: (data: any) => void): void {
111
90
  'show source';
112
91
  if (Platform.OS == 'android')
113
92
  if (Platform.Version <= 22) {
114
93
  return res(func(...params))
115
94
  }
116
- m.dispatch(
95
+ Worker.dispatch(
117
96
  (id: number) => {
118
97
  const nameFunction = func.toString().replace('function', 'function tempFunction')
119
98
  let _params = params.map((param) => {
@@ -126,46 +105,55 @@ export default class m extends Component<LibWorkerProps, LibWorkerState> {
126
105
  return out
127
106
  }
128
107
  , '', res)
129
- }
130
-
131
- // static image(url: string, toSize: number, result: (r: string) => void): void {
132
- // m.dispatch((id) => `imageCompress("` + id + `", "` + url + `", ` + PixelRatio.getPixelSizeForLayoutSize(toSize) + `)`, url, result)
133
- // }
134
-
135
- static dispatch(task: (id: number) => string, url: string, result: (r: string) => void): void {
136
- if (_global.LibWorkerReady > 0 && typeof _global.LibWorkerBase?.current?.injectJavaScript == 'function') {
137
- _global.LibWorkerCount++
138
- var _task = task(_global.LibWorkerCount)
139
- _global.LibWorkerTasks.set(String(_global.LibWorkerCount), {
108
+ },
109
+ dispatch(task: (id: number) => string, url: string, result: (r: string) => void): void {
110
+ if (_global.WorkerReady > 0 && typeof _global.WorkerBase?.current?.injectJavaScript == 'function') {
111
+ _global.WorkerCount++
112
+ var _task = task(_global.WorkerCount)
113
+ _global.WorkerTasks.set(String(_global.WorkerCount), {
140
114
  task: _task,
141
115
  result: result
142
116
  })
143
- _global.LibWorkerBase?.current?.injectJavaScript?.(_task)
117
+ _global.WorkerBase?.current?.injectJavaScript?.(_task)
144
118
  } else {
145
119
  setTimeout(() => {
146
- m.dispatch(task, url, result)
120
+ Worker.dispatch(task, url, result)
147
121
  }, 1000);
148
122
  }
149
- }
150
-
151
- static onMessage(withRefName: string): any {
123
+ },
124
+ onMessage(withRefName: string): any {
152
125
  return (e: any) => {
153
126
  if (e.nativeEvent.data == withRefName) {
154
- _global.LibWorkerReady += 1
127
+ _global.WorkerReady += 1
155
128
  return
156
129
  }
157
130
  const dt = e.nativeEvent.data
158
131
  const x = JSON.parse(dt)
159
- const itemTask = _global.LibWorkerTasks.get(String(x.id))
132
+ const itemTask = _global.WorkerTasks.get(String(x.id))
160
133
  if (itemTask) {
161
134
  itemTask.result(x.data)
162
- m.delete(x.id)
135
+ Worker.delete(x.id)
163
136
  }
164
137
  }
165
- }
166
-
167
- render(): any {
168
- return null
138
+ },
139
+ View(): any {
140
+ if (Platform.OS == 'android')
141
+ if (Platform.Version <= 22) {
142
+ return null
143
+ }
144
+ return (
145
+ <View style={{ height: 0, width: 0 }} >
146
+ <WebView
147
+ ref={_global.WorkerBase}
148
+ style={{ width: 0, height: 0 }}
149
+ javaScriptEnabled={true}
150
+ injectedJavaScript={`\nwindow.ReactNativeWebView.postMessage("BaseWorkerIsReady")\n` + _global.injectedJavaScripts.join('\n') + '\ntrue;'}
151
+ originWhitelist={["*"]}
152
+ source={{ uri: esp.config("protocol") + "://" + esp.config("domain") + esp.config("uri") + "dummyPageToBypassCORS" }}
153
+ onMessage={Worker.onMessage('BaseWorkerIsReady')}
154
+ />
155
+ </View>
156
+ )
169
157
  }
170
158
  }
171
-
159
+ export default Worker
@@ -1,6 +1,9 @@
1
1
  // noPage
2
+ import { } from 'esoftplay';
3
+
4
+ import { LibComponent } from 'esoftplay/cache/lib/component.import';
5
+ import { LibFocus } from 'esoftplay/cache/lib/focus.import';
2
6
 
3
- import { LibComponent, LibFocus } from 'esoftplay';
4
7
  import React from 'react';
5
8
  import { Platform, ScrollView, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
6
9
 
@@ -1,7 +1,9 @@
1
1
  // withHooks
2
2
  // noPage
3
+ import { } from 'esoftplay';
4
+
5
+ import { LibFocus } from 'esoftplay/cache/lib/focus.import';
3
6
 
4
- import { LibFocus } from "esoftplay";
5
7
  import React, { useEffect, useMemo, useRef } from 'react';
6
8
  import { ScrollView, View } from 'react-native';
7
9
 
@@ -1,7 +1,8 @@
1
1
  // withHooks
2
2
  // noPage
3
-
4
3
  import { useSafeState } from 'esoftplay';
4
+
5
+
5
6
  import React, { useCallback } from 'react';
6
7
  import { Pressable } from 'react-native';
7
8
  import Animated, { interpolate, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
File without changes