esoftplay 0.0.112 → 0.0.113-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
@@ -5,6 +5,7 @@ const fs = require('fs');
5
5
  const DIR = "../../"
6
6
  const packjson = DIR + "package.json"
7
7
  const appjson = DIR + "app.json"
8
+ const easjson = DIR + "eas.json"
8
9
  const confjson = DIR + "config.json"
9
10
  const gitignore = DIR + ".gitignore"
10
11
  const babelconfig = DIR + "babel.config.js"
@@ -27,7 +28,7 @@ if (fs.existsSync(packjson)) {
27
28
  /* ADD SCRIPTS.PRESTART AND SCRIPTS.POSTSTOP */
28
29
 
29
30
  if (args[0] == "install") {
30
- $package.scripts.start = "esp start && expo start"
31
+ $package.scripts.start = "esp start && expo start --dev-client"
31
32
  fs.writeFile(packjson, JSON.stringify($package, null, 2), (err) => {
32
33
  if (err) throw err;
33
34
  console.log('package.json has been updated');
@@ -116,6 +117,35 @@ if (fs.existsSync(packjson)) {
116
117
  fs.writeFileSync(pathJSTimer, JSTimers)
117
118
  }
118
119
 
120
+ const easconfg = `{
121
+ "cli": {
122
+ "version": ">= 0.52.0"
123
+ },
124
+ "build": {
125
+ "development": {
126
+ "developmentClient": true,
127
+ "distribution": "internal",
128
+ "ios": {
129
+ "simulator": true
130
+ }
131
+ },
132
+ "preview": {
133
+ "distribution": "internal",
134
+ "ios": {
135
+ "simulator": true
136
+ }
137
+ },
138
+ "production": {}
139
+ },
140
+ "submit": {
141
+ "production": {}
142
+ }
143
+ }`
144
+
145
+ fs.writeFile(easjson, easconfg, (err) => {
146
+ if (err) throw err;
147
+ console.log('eas.json has been updated');
148
+ })
119
149
 
120
150
  const babelconf = `module.exports = function (api) {
121
151
  api.cache(true);
@@ -210,9 +240,11 @@ yarn-error.log\n\
210
240
  import * as ErrorReport from 'esoftplay/error';
211
241
  import * as Notifications from 'expo-notifications';
212
242
  import React, { useEffect, useRef } from 'react';
213
- import { enableScreens } from 'react-native-screens';
243
+ import { GestureHandlerRootView } from 'react-native-gesture-handler';
244
+ import { enableScreens, enableFreeze } from 'react-native-screens';
214
245
  const { globalIdx } = require('esoftplay/global');
215
246
  enableScreens();
247
+ enableFreeze();
216
248
 
217
249
  Notifications.addNotificationResponseReceivedListener(x => LibNotification.onAction(x));
218
250
 
@@ -224,7 +256,11 @@ export default function App() {
224
256
  ErrorReport.getError()
225
257
  }, [])
226
258
 
227
- return <Home />
259
+ return (
260
+ <GestureHandlerRootView style={{ flex: 1 }}>
261
+ <Home />
262
+ </GestureHandlerRootView>
263
+ )
228
264
  }`;
229
265
  let expoLib = [
230
266
  '@expo/vector-icons',
@@ -235,14 +271,13 @@ export default function App() {
235
271
  '@react-navigation/native',
236
272
  '@react-navigation/stack',
237
273
  'buffer',
238
- 'axios',
239
274
  'expo-av',
240
275
  'expo-application',
241
- 'expo-blur',
242
276
  'expo-camera',
243
277
  'expo-clipboard',
244
278
  'expo-constants',
245
279
  'expo-document-picker',
280
+ 'expo-dev-client',
246
281
  'expo-file-system',
247
282
  'expo-font',
248
283
  'expo-image-manipulator',
@@ -251,6 +286,7 @@ export default function App() {
251
286
  'expo-media-library',
252
287
  'expo-notifications',
253
288
  'expo-status-bar',
289
+ 'expo-splash-screen',
254
290
  'expo-secure-store',
255
291
  'expo-updates',
256
292
  'immhelper',
@@ -258,6 +294,7 @@ export default function App() {
258
294
  'react-fast-compare',
259
295
  'react-native-gesture-handler',
260
296
  'react-native-awesome-gallery',
297
+ 'react-native-fast-image',
261
298
  'react-native-picker-scrollview',
262
299
  'react-native-pinch-zoom-view-movable',
263
300
  'react-native-reanimated',
@@ -309,7 +346,7 @@ export default function App() {
309
346
  cmd += "&& yarn add " + installDevLibs.join(" ") + " --dev "
310
347
  if (installExpoLibs.length > 0)
311
348
  cmd += "&& expo install " + installExpoLibs.join(" ")
312
- // cmd += " && npm i -s esoftplay"
349
+ cmd += " && node ./node_modules/esoftplay/bin/router.js"
313
350
  execSync(cmd)
314
351
  console.log('App.js has been replace to App.tsx');
315
352
  // /* bugfix AsyncStorage @firebase, remove this section if firebase has update the AsyncStorage */
package/bin/cli.js CHANGED
@@ -5,6 +5,8 @@ const fs = require('fs');
5
5
  const exec = require('child_process').execSync;
6
6
  const path = require('path');
7
7
  const os = require('os')
8
+ const readline = require('readline');
9
+
8
10
 
9
11
  const DIR = "./"
10
12
  const appjson = DIR + "app.json"
@@ -14,6 +16,7 @@ const packjson = DIR + "package.json"
14
16
  const confjson = DIR + "config.json"
15
17
  const conflive = DIR + "config.live.json"
16
18
  const confdebug = DIR + "config.debug.json"
19
+ const gitignore = DIR + ".gitignore"
17
20
 
18
21
  const gplist = DIR + "GoogleService-Info.plist"
19
22
  const gplistlive = DIR + "GoogleService-Info.live.plist"
@@ -91,6 +94,9 @@ switch (args[0]) {
91
94
  createMaster(args[1])
92
95
  break;
93
96
  case "start":
97
+ jsEng(appjson, false)
98
+ jsEng(appdebug, false)
99
+ jsEng(applive, false)
94
100
  excludeModules()
95
101
  execution();
96
102
  break;
@@ -136,6 +142,23 @@ function consoleFunc(msg, success) {
136
142
  }
137
143
  }
138
144
 
145
+
146
+ function jsEng(file, isHermes) {
147
+ if (fs.existsSync(file)) {
148
+ var txt = fs.readFileSync(file, 'utf8');
149
+ let isJSON = txt.startsWith('{') || txt.startsWith('[')
150
+ if (!isJSON) {
151
+ consoleError('app.json tidak valid')
152
+ return
153
+ }
154
+ let app = JSON.parse(txt)
155
+ app.expo.jsEngine = isHermes ? "hermes" : "jsc"
156
+ fs.writeFileSync(file, JSON.stringify(app, undefined, 2))
157
+ } else {
158
+ consoleError(file)
159
+ }
160
+ }
161
+
139
162
  function configUpdate(state) {
140
163
  let _path;
141
164
  let _slug
@@ -390,6 +413,9 @@ function readToJSON(path) {
390
413
  }
391
414
 
392
415
  function publish(notes) {
416
+ jsEng(appjson, true)
417
+ jsEng(appdebug, true)
418
+ jsEng(applive, true)
393
419
  let status = "-"
394
420
  let ajson = readToJSON(appjson)
395
421
  let pack = readToJSON(packjson)
@@ -556,22 +582,158 @@ function command(command) {
556
582
  }
557
583
  }
558
584
 
585
+
586
+ function devClientPre(file) {
587
+ if (fs.existsSync(file)) {
588
+ var txt = fs.readFileSync(file, 'utf8');
589
+ let isJSON = txt.startsWith('{') || txt.startsWith('[')
590
+ if (!isJSON) {
591
+ consoleError('app.json tidak valid')
592
+ return
593
+ }
594
+ let app = JSON.parse(txt)
595
+ app.expo.name = app.expo.name.includes("DC-") ? app.expo.name : ("DC-" + app.expo.name)
596
+ fs.writeFileSync(file, JSON.stringify(app, undefined, 2))
597
+ } else {
598
+ consoleError(file)
599
+ }
600
+ }
601
+ function devClientPos(file) {
602
+ if (fs.existsSync(file)) {
603
+ var txt = fs.readFileSync(file, 'utf8');
604
+ let isJSON = txt.startsWith('{') || txt.startsWith('[')
605
+ if (!isJSON) {
606
+ consoleError('app.json tidak valid')
607
+ return
608
+ }
609
+ let app = JSON.parse(txt)
610
+ app.expo.name = app.expo.name.replace("DC-", "")
611
+ fs.writeFileSync(file, JSON.stringify(app, undefined, 2))
612
+ } else {
613
+ consoleError(file)
614
+ }
615
+ }
616
+
617
+ function configAvailable(enabled) {
618
+ if (fs.existsSync(gitignore)) {
619
+ let _git = fs.readFileSync(gitignore, 'utf8')
620
+ const ignore = "config.json"
621
+ const notignore = "#config.json"
622
+ if (enabled) {
623
+ _git = _git.replace(ignore, notignore)
624
+ } else {
625
+ _git = _git.replace(notignore, ignore)
626
+ }
627
+ fs.writeFileSync(gitignore, _git, { encoding: 'utf8' })
628
+ } else {
629
+ consoleError(gitignore)
630
+ }
631
+ }
632
+
559
633
  function build() {
560
- if (args[0] == "build") {
561
- askPerm("Yakin akan membuild app " + (args[1] ? args[1] : "") + (args[2] ? " " + (args[2]) : "") + "?", () => {
562
- if (args[1] == "debug" || args[1] == "live") {
563
- switchStatus(args[1])
564
- console.log('+ status ' + args[1])
634
+ const types = [
635
+ {
636
+ name: "1. IOS (Development) - Simulator",
637
+ cmd: "eas build --platform ios --profile development",
638
+ pre: () => {
639
+ configAvailable(true)
640
+ devClientPre(appjson)
641
+ jsEng(appjson, false)
642
+ jsEng(appdebug, false)
643
+ jsEng(applive, false)
644
+ consoleSucces("Hermes dinonaktifkan")
565
645
  }
566
- if (args[2] == "offline" || args[2] == "online") {
567
- switchMode(args[2])
568
- console.log('+ mode ' + args[2])
646
+ },
647
+ {
648
+ name: "2. IOS (Preview) - Simulator",
649
+ cmd: "eas build --platform ios --profile preview",
650
+ pre: () => {
651
+ configAvailable(true)
652
+ devClientPos(appjson)
653
+ jsEng(appjson, true)
654
+ jsEng(appdebug, true)
655
+ jsEng(applive, true)
656
+ consoleSucces("Hermes diaktifkan")
569
657
  }
570
- command("expo build:android")
571
- command("expo build:ios")
572
- command("expo build:android -t app-bundle")
573
- consoleError("silahkan cek build pada halaman https://expo.io/builds")
574
- })
658
+ },
659
+ {
660
+ name: "3. IOS (Production) - ipa",
661
+ cmd: "eas build --platform ios --profile production",
662
+ pre: () => {
663
+ configAvailable(true)
664
+ devClientPos(appjson)
665
+ jsEng(appjson, true)
666
+ jsEng(appdebug, true)
667
+ jsEng(applive, true)
668
+ consoleSucces("Hermes diaktifkan")
669
+ }
670
+ },
671
+ {
672
+ name: "4. Android (Development) - apk",
673
+ cmd: "eas build --platform android --profile development",
674
+ pre: () => {
675
+ configAvailable(true)
676
+ devClientPre(appjson)
677
+ jsEng(appjson, false)
678
+ jsEng(appdebug, false)
679
+ jsEng(applive, false)
680
+ consoleSucces("Hermes dinonaktifkan")
681
+ }
682
+ },
683
+ {
684
+ name: "5. Android (Preview) - apk",
685
+ cmd: "eas build --platform android --profile preview",
686
+ pre: () => {
687
+ configAvailable(true)
688
+ devClientPos(appjson)
689
+ jsEng(appjson, true)
690
+ jsEng(appdebug, true)
691
+ jsEng(applive, true)
692
+ consoleSucces("Hermes diaktifkan")
693
+ }
694
+ },
695
+ {
696
+ name: "6. Android (Production) - aab",
697
+ cmd: "eas build --platform android --profile production",
698
+ pre: () => {
699
+ configAvailable(true)
700
+ devClientPos(appjson)
701
+ jsEng(appjson, true)
702
+ jsEng(appdebug, true)
703
+ jsEng(applive, true)
704
+ consoleSucces("Hermes diaktifkan")
705
+ }
706
+ }
707
+ ]
708
+
709
+ if (args[0] == "build" || args[0] == "b") {
710
+ let d = false
711
+ const rl = readline.createInterface({
712
+ input: process.stdin,
713
+ output: process.stdout
714
+ });
715
+
716
+ rl.question("Pilih build type :\n\n" + types.map((x) => x.name).join("\n") + '\n\nMasukkan nomor build type: ', function (idx) {
717
+ d = types[idx - 1]
718
+ rl.close();
719
+ });
720
+
721
+ rl.on("close", function () {
722
+ if (d) {
723
+ let cmd = d.cmd
724
+ let pre = d.pre
725
+ if (pre) pre()
726
+ consoleSucces("⚙⚙⚙ ... \n" + cmd)
727
+ command(cmd)
728
+ configAvailable(false)
729
+ devClientPos(appjson)
730
+ } else if (d === false) {
731
+ consoleError("Build Canceled")
732
+ } else {
733
+ consoleError("Build type tidak ditemukan")
734
+ }
735
+ });
736
+
575
737
  }
576
738
  }
577
739
 
@@ -625,6 +787,7 @@ function doInc(file) {
625
787
  consoleSucces(file + " Versi yang lama " + app.expo.version)
626
788
  app.expo.android.versionCode = lastVersion + 1
627
789
  app.expo.ios.buildNumber = String(lastVersion + 1)
790
+ app.expo.runtimeVersion = String(lastVersion + 1)
628
791
  app.expo.version = args[1] || ('0.' + String(lastVersion + 1))
629
792
  consoleSucces(file + " Berhasil diupdate ke versi " + app.expo.version)
630
793
  fs.writeFileSync(file, JSON.stringify(app, undefined, 2))
@@ -669,6 +832,7 @@ function help() {
669
832
  "\n - u|update : untuk update esp module ke versi terakhir",
670
833
  "\n - u|update all : untuk update semua esp module ke versi terakhir",
671
834
  "\n - start : start esoftplay framework",
835
+ "\n - b|build : untuk build app .ipa .apk .aab",
672
836
  "\n - f|file : untuk check status file",
673
837
  "\n - c|check : untuk check status",
674
838
  "\n - create-master [moduleName] : untuk create master module terpisah",
@@ -681,7 +845,6 @@ function help() {
681
845
  "\n - p|publish [notes] : untuk mempublish dan menambahkan id",
682
846
  "\n - bcl|backup-config-live : untuk backup config live",
683
847
  "\n - bcd|backup-config-debug : untuk backup config debug",
684
- // "\n - b|build : untuk build app .ipa .apk .aab",
685
848
  // "\n - build debug : untuk build app .ipa .apk .aab status DEBUG",
686
849
  // "\n - build debug offline : untuk build app .ipa .apk .aab status DEBUG mode OFFLINE",
687
850
  // "\n - build debug online : untuk build app .ipa .apk .aab status DEBUG mode ONLINE",
package/error.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage';
2
2
  import { LibCurl, UserClass } from 'esoftplay';
3
- import esp from 'esoftplay/esp';
4
3
  import Constants from 'expo-constants';
5
- import { Alert, Platform } from 'react-native';
4
+ import { Platform } from 'react-native';
5
+ import esp from './esp';
6
6
  import { default as UserRoutes } from './modules/user/routes';
7
7
  let pack = require('../../package.json');
8
8
  let app = require('../../app.json');
@@ -51,19 +51,12 @@ export function reportApiError(fetch: any, error: any) {
51
51
  }
52
52
  new LibCurl().custom('https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendMessage', post)
53
53
  } else {
54
- config?.errorReport?.telegramIds?.forEach?.((id: string) => {
55
- let post = {
56
- text: msg.slice(0, 4000),
57
- chat_id: id,
58
- disable_web_page_preview: true
59
- }
60
- new LibCurl().custom('https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendMessage', post, (res) => {
61
- // debug sementara sampe tahu masalahnya
62
- if (user.username.includes("@fisip.net")) {
63
- Alert.alert("DEBUG Telegram api error", res, [{ text: 'OK' }])
64
- }
65
- })
66
- })
54
+ let post = {
55
+ text: msg,
56
+ chat_id: "-1001212227631",
57
+ disable_web_page_preview: true
58
+ }
59
+ new LibCurl().custom('https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendMessage', post)
67
60
  }
68
61
  }
69
62
 
@@ -84,14 +77,14 @@ export function getError() {
84
77
  'module: ' + _e.routes,
85
78
  'error: \n' + _e.error,
86
79
  ].join('\n')
87
- config?.errorReport?.telegramIds?.forEach?.((id: string) => {
88
- let post = {
89
- text: msg,
90
- chat_id: id,
91
- disable_web_page_preview: true
92
- }
93
- new LibCurl().custom('https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendMessage', post)
94
- });
80
+ // config?.errorReport?.telegramIds?.forEach?.((id: string) => {
81
+ let post = {
82
+ text: msg,
83
+ chat_id: "-1001212227631",
84
+ disable_web_page_preview: true
85
+ }
86
+ new LibCurl().custom('https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendMessage', post)
87
+ // });
95
88
  AsyncStorage.removeItem(config.domain + 'error')
96
89
  }
97
90
  })
@@ -1,9 +1,8 @@
1
- import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibToastProperty, LibUtils, LogStateProperty } from 'esoftplay';
1
+ import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibUtils, LogStateProperty } from 'esoftplay';
2
2
  import { reportApiError } from "esoftplay/error";
3
3
  import moment from "esoftplay/moment";
4
4
  import Constants from 'expo-constants';
5
5
 
6
- const axios = require('axios');
7
6
  const { manifest } = Constants;
8
7
 
9
8
  export default class ecurl {
@@ -25,9 +24,7 @@ export default class ecurl {
25
24
  cancel: "Tutup"
26
25
  }
27
26
 
28
- abort = axios.CancelToken.source();
29
-
30
- constructor(uri?: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) {
27
+ constructor(uri?: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) {
31
28
  this.header = {}
32
29
  this.maxRetry = 2;
33
30
  this.setUri = this.setUri.bind(this);
@@ -52,17 +49,17 @@ export default class ecurl {
52
49
  if (uri && str.isOnline) {
53
50
  this.init(uri, post, onDone, onFailed, debug);
54
51
  } else if (!str.isOnline && onFailed) {
55
- onFailed(this.refineErrorMessage("Failed to access"), false);
52
+ onFailed({ msg: this.refineErrorMessage("Failed to access") }, false);
56
53
  }
57
54
  }
58
55
 
59
56
  protected initTimeout(customTimeout?: number): void {
60
57
  this.cancelTimeout()
61
58
  this.timeoutContext = setTimeout(() => {
62
- if (this.abort?.cancel) {
63
- this.closeConnection()
64
- LibProgress.hide()
65
- }
59
+ // if (this.abort?.cancel) {
60
+ // this.closeConnection()
61
+ // LibProgress.hide()
62
+ // }
66
63
  }, customTimeout ?? this.timeout);
67
64
  }
68
65
 
@@ -131,14 +128,14 @@ export default class ecurl {
131
128
  }
132
129
 
133
130
  protected closeConnection(): void {
134
- this?.abort?.cancel('Oops, Sepertinya ada gangguan jaringan... Silahkan coba beberapa saat lagi');
131
+ // this?.abort?.cancel('Oops, Sepertinya ada gangguan jaringan... Silahkan coba beberapa saat lagi');
135
132
  }
136
133
 
137
134
  protected onDone(result: any, msg?: string): void {
138
135
 
139
136
  }
140
137
 
141
- protected onFailed(msg: string, timeout: boolean): void {
138
+ protected onFailed(error: any, timeout: boolean): void {
142
139
 
143
140
  }
144
141
 
@@ -146,9 +143,9 @@ export default class ecurl {
146
143
  return true
147
144
  }
148
145
 
149
- public secure(token_uri?: string): (apiKey?: string) => (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
150
- return (apiKey?: string): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void => {
151
- return async (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => {
146
+ public secure(token_uri?: string): (apiKey?: string) => (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => void {
147
+ return (apiKey?: string): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => void => {
148
+ return async (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => {
152
149
  this.isSecure = true
153
150
  await this.setHeader();
154
151
  const _apiKey = apiKey || this.apiKey
@@ -167,7 +164,6 @@ export default class ecurl {
167
164
  }
168
165
  let ps = Object.keys(_post).map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(_post[key])).join('&');
169
166
  var options: any = {
170
- signal: this.signal,
171
167
  method: "POST",
172
168
  headers: {
173
169
  ...this.header,
@@ -196,12 +192,12 @@ export default class ecurl {
196
192
  }
197
193
  }
198
194
 
199
- public withHeader(header: any): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => void {
195
+ public withHeader(header: any): (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => void {
200
196
  this.header = { ...this.header, ...header }
201
- return (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number) => this.init(uri, post, onDone, onFailed, debug)
197
+ return (uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number) => this.init(uri, post, onDone, onFailed, debug)
202
198
  }
203
199
 
204
- public upload(uri: string, postKey: string, fileUri: string, mimeType: string, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
200
+ public upload(uri: string, postKey: string, fileUri: string, mimeType: string, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number): void {
205
201
  postKey = postKey || "image";
206
202
  var uName = fileUri.substring(fileUri.lastIndexOf("/") + 1, fileUri.length);
207
203
  if (!uName.includes('.')) {
@@ -286,7 +282,6 @@ export default class ecurl {
286
282
  }
287
283
  await this.setHeader()
288
284
  var options: any = {
289
- signal: this.signal,
290
285
  method: !this.post ? "GET" : "POST",
291
286
  headers: {
292
287
  ...this.header,
@@ -346,7 +341,7 @@ export default class ecurl {
346
341
  }
347
342
  }
348
343
 
349
- private async init(uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number, upload?: boolean): Promise<void> {
344
+ private async init(uri: string, post?: any, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number, upload?: boolean): Promise<void> {
350
345
  if (post) {
351
346
  if (upload) {
352
347
  let fd = new FormData();
@@ -372,10 +367,11 @@ export default class ecurl {
372
367
  this.setUrl(esp.config("url"))
373
368
  }
374
369
  await this.setHeader();
375
- if (!upload)
370
+ if (upload)
371
+ this.header["Content-Type"] = "multipart/form-data"
372
+ else
376
373
  this.header["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8"
377
374
  var options: any = {
378
- signal: this.signal,
379
375
  method: !this.post ? "GET" : "POST",
380
376
  headers: this.header,
381
377
  body: this.post,
@@ -485,7 +481,7 @@ export default class ecurl {
485
481
 
486
482
 
487
483
 
488
- protected onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (msg: string, timeout: boolean) => void, debug?: number): void {
484
+ protected onFetched(resText: string | Object, onDone?: (res: any, msg: string) => void, onFailed?: (error: any, timeout: boolean) => void, debug?: number): void {
489
485
  var resJson = typeof resText == 'string' && ((resText.startsWith("{") && resText.endsWith("}")) || (resText.startsWith("[") && resText.endsWith("]"))) ? JSON.parse(resText) : resText
490
486
  if (typeof resJson == "object") {
491
487
  if (!resJson.status_code || this.onStatusCode(resJson.ok, resJson.status_code, resJson.message, resJson.result)) {
@@ -493,8 +489,8 @@ export default class ecurl {
493
489
  if (onDone) onDone(resJson.result, resJson.message)
494
490
  this.onDone(resJson.result, resJson.message)
495
491
  } else {
496
- if (onFailed) onFailed(this.refineErrorMessage(resJson.message), false)
497
- this.onFailed(this.refineErrorMessage(resJson.message), false)
492
+ if (onFailed) onFailed(resJson, false)
493
+ this.onFailed(resJson, false)
498
494
  }
499
495
  }
500
496
  } else {
@@ -531,11 +527,20 @@ export default class ecurl {
531
527
  // return
532
528
  // }
533
529
  delete this.fetchConf.options.cancelToken
534
- reportApiError(this.fetchConf.options, msg)
530
+ reportApiError(this.fetchConf, msg)
535
531
  LibProgress.hide()
536
532
  }
537
533
 
538
534
  protected getTimeByTimeZone(timeZone: string): number {
539
- return moment(new Date()).tz(timeZone).toMiliseconds();
535
+ let localTimezoneOffset = new Date().getTimezoneOffset()
536
+ let serverTimezoneOffset = -420 // -420 for Asia/Jakarta
537
+ let diff
538
+ if (localTimezoneOffset < serverTimezoneOffset) {
539
+ diff = localTimezoneOffset - serverTimezoneOffset
540
+ } else {
541
+ diff = (serverTimezoneOffset - localTimezoneOffset) * -1
542
+ }
543
+ let time = new Date().getTime() + (diff * 60 * 1000 * -1);
544
+ return time;
540
545
  }
541
546
  }
@@ -29,7 +29,7 @@ export default class m {
29
29
  },
30
30
  (msg) => {
31
31
  LibProgress.hide()
32
- esp.log('Document Gagal di Upload', msg)
32
+ esp.log('Document Gagal di Upload', msg.msg)
33
33
  }
34
34
  )
35
35
  })
@@ -160,7 +160,7 @@ class m extends LibComponent<LibImageProps, LibImageState> {
160
160
  max = 1
161
161
  }
162
162
  if (max == 1) {
163
- ImagePicker.launchImageLibraryAsync({ presentationStyle: 0 }).then(async (x: any) => {
163
+ ImagePicker.launchImageLibraryAsync({ presentationStyle: ImagePicker.UIImagePickerPresentationStyle.FULL_SCREEN }).then(async (x: any) => {
164
164
  if (!x.cancelled) {
165
165
  if (options && options.crop) {
166
166
  m.showCropper(x.uri, options.crop.forceCrop, options.crop.ratio, options.crop?.message, async (x) => {
@@ -191,7 +191,7 @@ class m extends LibComponent<LibImageProps, LibImageState> {
191
191
  let a: string[] = []
192
192
  x.forEach(async (t: any, i) => {
193
193
  if (i == 0) {
194
- LibProgress.show("Mohon Tunggu, Sedang mengunggah foto")
194
+ LibProgress.show("Mohon tunggu, Sedang mengunggah foto")
195
195
  }
196
196
  var wantedMaxSize = options?.maxDimension || 1280
197
197
  var rawheight = t.height
@@ -221,8 +221,8 @@ class m extends LibComponent<LibImageProps, LibImageState> {
221
221
  LibProgress.hide()
222
222
  }
223
223
  },
224
- (msg: string) => {
225
- console.log(msg, "NOOO")
224
+ (msg: any) => {
225
+ console.log(msg.msg, "NOOO")
226
226
  if (x.length - 1 == i)
227
227
  LibProgress.hide()
228
228
  }, 1)
@@ -259,9 +259,9 @@ class m extends LibComponent<LibImageProps, LibImageState> {
259
259
  r(res);
260
260
  LibProgress.hide()
261
261
  },
262
- (msg: string) => {
262
+ (msg: any) => {
263
263
  LibProgress.hide()
264
- r(msg);
264
+ r(msg.msg);
265
265
  }, 1)
266
266
  }, 1);
267
267
  }
@@ -134,12 +134,12 @@ export default class m extends LibComponent<LibInfiniteProps, LibInfiniteState>{
134
134
  },
135
135
  (msg) => {
136
136
  if (this.props.isDebug) {
137
- esp.log(msg)
137
+ esp.log(msg.msg)
138
138
  }
139
139
  this.page = page
140
140
  this.isStop = true
141
141
  this.setState({
142
- error: msg,
142
+ error: msg.msg,
143
143
  })
144
144
  }, this.props.isDebug
145
145
  )
@@ -4,7 +4,8 @@
4
4
  import { esp, LibStyle, LibWorker, LibWorkloop, useSafeState } from 'esoftplay';
5
5
  import * as FileSystem from 'expo-file-system';
6
6
  import React, { useMemo } from 'react';
7
- import { Image, PixelRatio, Platform, View } from 'react-native';
7
+ import { PixelRatio, Platform, View } from 'react-native';
8
+ import FastImage from 'react-native-fast-image'
8
9
  const sh = require("shorthash")
9
10
 
10
11
  export interface LibPictureSource {
@@ -86,6 +87,18 @@ export default function m(props: LibPictureProps): any {
86
87
  let { width, height } = props.style
87
88
  const valid = b_uri?.includes?.(esp.config('domain'))
88
89
 
90
+ let resizeMode
91
+ if (props?.style?.resizeMode == 'cover')
92
+ resizeMode = FastImage.resizeMode.cover
93
+ else if (props?.style?.resizeMode == 'contain')
94
+ resizeMode = FastImage.resizeMode.contain
95
+ else if (props?.resizeMode == 'cover')
96
+ resizeMode = FastImage.resizeMode.cover
97
+ else if (props?.resizeMode == 'contain')
98
+ resizeMode = FastImage.resizeMode.contain
99
+ else
100
+ resizeMode = FastImage.resizeMode.cover
101
+
89
102
  if (props.source.hasOwnProperty("uri") && (!width || !height)) {
90
103
  if (width) {
91
104
  height = width
@@ -120,11 +133,11 @@ export default function m(props: LibPictureProps): any {
120
133
  if (typeof props.source != 'number' && !b_uri) {
121
134
  return <View style={props.style} />
122
135
  }
123
- return <Image {...props} />
136
+ return <FastImage {...props} resizeMode={resizeMode} />
124
137
  }
125
138
 
126
139
  if (!valid || (!props.source.hasOwnProperty("uri"))) {
127
- return <Image {...props} />
140
+ return <FastImage {...props} resizeMode={resizeMode} />
128
141
  }
129
142
 
130
143
  if (uri == '') {
@@ -134,6 +147,6 @@ export default function m(props: LibPictureProps): any {
134
147
  }
135
148
 
136
149
  return (
137
- <Image key={b_uri + uri} {...props} source={{ uri: uri }} style={props.style} />
150
+ <FastImage key={b_uri + uri} {...props} source={{ uri: uri }} style={props.style} resizeMode={resizeMode} />
138
151
  )
139
152
  }
@@ -74,7 +74,7 @@ export default class m extends LibComponent<LibRollProps, LibRollState>{
74
74
  })
75
75
  },
76
76
  (_msg) => {
77
- this.setState({ msg: _msg })
77
+ this.setState({ msg: _msg.msg })
78
78
  }
79
79
  )
80
80
  else
@@ -16,7 +16,7 @@ export default function m(initialWithLoading?: boolean, withProgressText?: strin
16
16
  }, (msg) => {
17
17
  LibProgress.hide()
18
18
  setLoading(false)
19
- setError(msg)
19
+ setError(msg.msg)
20
20
  }, debug)
21
21
  }
22
22
  return [curl, loading, error]
@@ -111,7 +111,7 @@ export default class eclass {
111
111
  AsyncStorage.setItem("token", String(token))
112
112
  resolve(res)
113
113
  }, (msg) => {
114
- resolve(msg)
114
+ resolve(msg.msg)
115
115
  })
116
116
  })
117
117
  }
@@ -90,7 +90,7 @@ export default class euserLogin extends LibComponent<UserLoginProps, UserLoginSt
90
90
  },
91
91
  (msg) => {
92
92
  // console.log("gagal => " + msg, email)
93
- this.onFailedLogin(msg)
93
+ this.onFailedLogin(msg.msg)
94
94
  this.setState({ isLoading: false, email: "" })
95
95
  }, 1
96
96
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.112",
3
+ "version": "0.0.113-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",