esoftplay 0.0.133-b → 0.0.133-d

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/bin/cli.js +14 -4
  2. package/bin/perf.js +44 -0
  3. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -40,6 +40,14 @@ switch (args[0]) {
40
40
  case "analyze clear":
41
41
  command('node ./node_modules/esoftplay/bin/analyze.js clear')
42
42
  break;
43
+ case "fr":
44
+ case "fastrefresh":
45
+ command('node ./node_modules/esoftplay/bin/perf.js')
46
+ break
47
+ case "frc":
48
+ case "fastrefresh clear":
49
+ command('node ./node_modules/esoftplay/bin/perf.js clear')
50
+ break;
43
51
  case "help":
44
52
  help()
45
53
  break;
@@ -468,10 +476,10 @@ function publish(notes) {
468
476
  if (status != 'debug' && status != 'live') {
469
477
  brokenConfig = "Gagal publish : CONFIG tidak valid"
470
478
  }
471
- if (!cjson.config.salt){
479
+ if (!cjson.config.salt) {
472
480
  brokenConfig = "Gagal publish : CONFIG tidak valid"
473
481
  }
474
- if (brokenConfig){
482
+ if (brokenConfig) {
475
483
  consoleError(brokenConfig)
476
484
  return
477
485
  }
@@ -726,10 +734,10 @@ function build() {
726
734
  if (!cjson.config.domain) {
727
735
  brokenConfig = "Gagal build : CONFIG tidak valid"
728
736
  }
729
- if (!cjson.config.salt){
737
+ if (!cjson.config.salt) {
730
738
  brokenConfig = "Gagal build : CONFIG tidak valid"
731
739
  }
732
- if (brokenConfig){
740
+ if (brokenConfig) {
733
741
  consoleError(brokenConfig)
734
742
  return
735
743
  }
@@ -1015,6 +1023,8 @@ function help() {
1015
1023
  "\n - help : panduan penggunaan",
1016
1024
  "\n - a|analyze : untuk menambahkan view render counter di semua component",
1017
1025
  "\n - ac|analyze clear : untuk menghapus view render counter di semua component",
1026
+ "\n - fr|fastrefresh : untuk mengaktfikan fast refresh di semua component",
1027
+ "\n - frc|fastrefresh clear : untuk menonaktifkan fast refresh di semua component",
1018
1028
  "\n - u|update : untuk update esp module ke versi terakhir",
1019
1029
  "\n - u|update all : untuk update semua esp module ke versi terakhir",
1020
1030
  "\n - start : start esoftplay framework",
package/bin/perf.js ADDED
@@ -0,0 +1,44 @@
1
+ //@ts-check
2
+ const fs = require('fs');
3
+
4
+ const param = process.argv[2]
5
+
6
+ if (param == 'clear') {
7
+ console.log("DEACTIVATING FAST REFRESH...")
8
+ fs.readdirSync('./modules/').forEach((module) => {
9
+ if (fs.statSync('./modules/' + module).isDirectory()) {
10
+ fs.readdirSync('./modules/' + module).forEach((task) => {
11
+ let text = fs.readFileSync('./modules/' + module + '/' + task, { encoding: 'utf8' })
12
+ const isHooks = (/\/\/\s{0,}withHooks/g).exec(text)
13
+ const memoiz = (/\nexport default memo\(([a-zA-Z0-9]+)\)\;/g).exec(text)
14
+ if (isHooks && memoiz && memoiz.length > 1) {
15
+ const [exdefCurrent, currentNameFunction] = memoiz
16
+ text = text.replace("\nimport {memo} from 'react';", "")
17
+ text = text.replace(exdefCurrent, '')
18
+ text = text.replace("function " + currentNameFunction + "(", "export default function " + currentNameFunction + "(")
19
+ fs.writeFileSync('./modules/' + module + '/' + task, text, { encoding: 'utf8' })
20
+ }
21
+ })
22
+ }
23
+ })
24
+ } else {
25
+ console.log("ACTIVATING FAST REFRESH...")
26
+ fs.readdirSync('./modules/').forEach((module) => {
27
+ if (fs.statSync('./modules/' + module).isDirectory()) {
28
+ fs.readdirSync('./modules/' + module).forEach((task) => {
29
+ let text = fs.readFileSync('./modules/' + module + '/' + task, { encoding: 'utf8' })
30
+ const isHooks = (/\/\/\s{0,}withHooks/g).exec(text)
31
+ if (isHooks) {
32
+ const exdef = (/\nexport default function ([a-zA-Z0-9]+)\(/g).exec(text)
33
+ if (exdef && exdef.length > 1) {
34
+ const [exdefCurrent, currentNameFunction] = exdef
35
+ text = text.replace('withHooks', "withHooks\nimport {memo} from 'react';")
36
+ text = text.replace(exdefCurrent, "\nfunction " + currentNameFunction + '(')
37
+ text = text + '\nexport default memo(' + currentNameFunction + ');'
38
+ fs.writeFileSync('./modules/' + module + '/' + task, text, { encoding: 'utf8' })
39
+ }
40
+ }
41
+ })
42
+ }
43
+ })
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.133-b",
3
+ "version": "0.0.133-d",
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",