esoftplay 0.0.268 → 0.0.269

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.
@@ -2,8 +2,8 @@
2
2
  // noPage
3
3
 
4
4
  import { useIsFocused } from '@react-navigation/native';
5
- import React, { useEffect } from 'react';
6
- import { InteractionManager, View, ViewStyle } from 'react-native';
5
+ import { useEffect } from 'react';
6
+ import { View, ViewStyle } from 'react-native';
7
7
 
8
8
  export interface LibFocusProps {
9
9
  isFocused?: boolean
@@ -21,10 +21,10 @@ export default function m(props: LibFocusProps): any {
21
21
  const isFocused = useIsFocused()
22
22
 
23
23
  useEffect(() => {
24
- if (isFocused) {
25
- InteractionManager.runAfterInteractions(props?.onFocus)
26
- } else {
27
- InteractionManager.runAfterInteractions(props?.onBlur)
24
+ const callback = isFocused ? props.onFocus : props.onBlur
25
+ if (typeof callback === "function") {
26
+ const task = requestIdleCallback(callback)
27
+ return () => cancelIdleCallback(task)
28
28
  }
29
29
  }, [isFocused]);
30
30
 
@@ -3,7 +3,6 @@
3
3
 
4
4
  import useSafeState from 'esoftplay/state';
5
5
  import { useEffect } from 'react';
6
- import { InteractionManager } from 'react-native';
7
6
 
8
7
  export interface LibLazyProps {
9
8
  children?: any;
@@ -32,10 +31,10 @@ export default function m(props: LibLazyProps): any {
32
31
  const [done, setDone] = useSafeState(false);
33
32
 
34
33
  useEffect(() => {
35
- const int = InteractionManager.runAfterInteractions(() => {
34
+ const int = requestIdleCallback(() => {
36
35
  setDone(true)
37
36
  })
38
- return () => int.cancel()
37
+ return () => cancelIdleCallback(int)
39
38
  }, [])
40
39
 
41
40
  // const [sync] = useTasks((item) => new Promise((next) => {
@@ -8,7 +8,6 @@ import { createTimeout } from 'esoftplay/timeout';
8
8
 
9
9
  import Constants from 'expo-constants';
10
10
  import * as Updates from 'expo-updates';
11
- import React from 'react';
12
11
  import { Alert, Pressable } from 'react-native';
13
12
 
14
13
  export interface LibUpdaterProps {
@@ -47,6 +46,7 @@ export function check(callback?: (isNew: boolean) => void): void {
47
46
  return
48
47
  }
49
48
  Updates.checkForUpdateAsync().then(({ isAvailable }) => {
49
+ Updates.clearLogEntriesAsync()
50
50
  if (!isAvailable) {
51
51
  callback?.(false)
52
52
  LibProgress?.hide?.()
@@ -4,7 +4,7 @@ import { LibNotification } from 'esoftplay/cache/lib/notification/import';
4
4
  import { UserClass } from 'esoftplay/cache/user/class/import';
5
5
  import esp from 'esoftplay/esp';
6
6
  import React from 'react';
7
- import { InteractionManager, View } from 'react-native';
7
+ import { View } from 'react-native';
8
8
  import { WebView } from 'react-native-webview';
9
9
 
10
10
  export interface LibWorkloopProps {
@@ -58,7 +58,7 @@ export default class m extends LibComponent<LibWorkloopProps, LibWorkloopState>
58
58
 
59
59
  static onMessage(e: any): void {
60
60
  if (workloopHasTask) {
61
- InteractionManager.runAfterInteractions(() => {
61
+ requestIdleCallback(() => {
62
62
  const ctask = workloopTasks?.[0]
63
63
  if (ctask) {
64
64
  if (ctask.length == 2) {
@@ -1,5 +1,6 @@
1
1
  //noPage
2
2
 
3
+ import idjson from 'esoftplay/../../assets/locale/id.json';
3
4
  import { appjson, configjson, configlivejson } from 'esoftplay/bin/files';
4
5
  import { EspAssets } from 'esoftplay/cache/assets';
5
6
  import cacheConfig from 'esoftplay/cache/config.json';
@@ -11,7 +12,9 @@ import { LogBox, Platform } from 'react-native';
11
12
  import 'react-native-reanimated';
12
13
  import './oneplusfixfont';
13
14
 
14
- type ConfigType = typeof cacheConfig
15
+
16
+ type ConfigType = typeof cacheConfig;
17
+ type LangIndexType = typeof idjson;
15
18
 
16
19
  const ignoreWarns = [
17
20
  "Setting a timer for a long period of time",
@@ -127,7 +130,7 @@ const esp = {
127
130
  return out;
128
131
  }
129
132
  },
130
- lang<T extends keyof EspRouterInterface>(moduleTask: T, langName: string, ...stringToBe: string[]): string {
133
+ lang<T extends keyof LangIndexType>(moduleTask: T, langName: string, ...stringToBe: string[]): string {
131
134
  let string = LibLocale.stateLang().get()?.[esp.langId()]?.[moduleTask]?.[langName]
132
135
  if (!string) {
133
136
  string = esp.assets("locale/id.json")?.[moduleTask]?.[langName]
@@ -1,4 +1,7 @@
1
1
  // noPage
2
+
3
+ import { createMMKV } from "react-native-mmkv";
4
+
2
5
  // withObject
3
6
  let storage: any;
4
7
  let isWeb = typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
@@ -19,8 +22,7 @@ if (isWeb) {
19
22
  }
20
23
  } else {
21
24
  // @ts-ignore
22
- const MMKV = require('react-native-mmkv').MMKV;
23
- storage = new MMKV();
25
+ storage = createMMKV()
24
26
  }
25
27
 
26
28
  /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md) untuk melihat dokumentasi*/
@@ -39,7 +41,7 @@ const FastStorage = {
39
41
  },
40
42
  /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md#removeItem) untuk melihat dokumentasi*/
41
43
  removeItem(key: string) {
42
- storage.delete(key)
44
+ storage.remove(key)
43
45
  },
44
46
  /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/mmkv.md#clear) untuk melihat dokumentasi*/
45
47
  clear(): void {
@@ -1,90 +1,119 @@
1
1
  //noPage
2
- import * as FileSystem from 'expo-file-system';
2
+ import { Directory, File, Paths } from "expo-file-system";
3
3
 
4
- const CACHE_DIR = `${FileSystem.cacheDirectory}lib-storage-cache/`;
4
+ const CACHE_DIR = new Directory(Paths.cache, "lib-storage-cache");
5
5
 
6
6
  (async () => {
7
7
  try {
8
- await FileSystem.makeDirectoryAsync(CACHE_DIR);
9
- } catch (e) {
10
- // do nothing
11
- }
8
+ if (!CACHE_DIR.exists) {
9
+ CACHE_DIR.create();
10
+ }
11
+ } catch { }
12
12
  })();
13
13
 
14
14
  const Storage = {
15
- getDBPath(key: string): string {
16
- const path = `${CACHE_DIR}${key.replace(/\//g, "-")}.txt`;
17
- return path;
15
+ getDBPath(key: string): File {
16
+ const name = key.replace(/\//g, "-") + ".txt";
17
+ return new File(CACHE_DIR, name);
18
18
  },
19
- async getItem(key: string): Promise<string | null> {
20
- const path = this.getDBPath(key);
19
+
20
+ async getItem(key: string): Promise<any | null> {
21
21
  try {
22
- const info = await FileSystem.getInfoAsync(path);
23
- const { exists } = info;
24
- if (exists) {
25
- const value = await FileSystem.readAsStringAsync(path, { encoding: 'utf8' });
26
- return JSON.parse(value);
27
- }
28
- } catch (error) {
22
+ const file = this.getDBPath(key);
23
+
24
+ if (!file.exists) return null;
25
+
26
+ const value = await file.text();
27
+ return JSON.parse(value);
28
+ } catch {
29
29
  return null;
30
30
  }
31
- return null;
32
31
  },
32
+
33
33
  async setItem(key: string, value: string): Promise<string> {
34
- const path = this.getDBPath(key);
35
- await FileSystem.writeAsStringAsync(path, value, { encoding: 'utf8' });
34
+ const file = this.getDBPath(key);
35
+
36
+ await file.write(value);
37
+
36
38
  return value;
37
39
  },
40
+
38
41
  async removeItem(key: string): Promise<string> {
39
- const path = this.getDBPath(key);
40
42
  try {
41
- await FileSystem.deleteAsync(path);
42
- } catch (error) { }
43
+ const file = this.getDBPath(key);
44
+
45
+ if (file.exists) {
46
+ file.delete();
47
+ }
48
+ } catch { }
49
+
43
50
  return key;
44
51
  },
52
+
45
53
  clear(): void {
46
- FileSystem.deleteAsync(CACHE_DIR);
54
+ try {
55
+ if (CACHE_DIR.exists) {
56
+ CACHE_DIR.delete();
57
+ }
58
+ } catch { }
47
59
  },
48
- async sendTelegram(key: string, message: string, onDone?: () => void, onFailed?: (reason: string) => void, chat_id?: string, customFileName?: (originalName: string) => string,) {
49
60
 
61
+ async sendTelegram(
62
+ key: string,
63
+ message: string,
64
+ onDone?: () => void,
65
+ onFailed?: (reason: string) => void,
66
+ chat_id?: string,
67
+ customFileName?: (originalName: string) => string
68
+ ) {
50
69
  try {
51
- let dbPath = Storage.getDBPath(key)
52
- let fileInfo = await FileSystem.getInfoAsync(dbPath, {});
53
- if (!fileInfo.exists) {
54
- onFailed?.("File not found")
55
- return
70
+ const file = this.getDBPath(key);
71
+
72
+ if (!file.exists) {
73
+ onFailed?.("File not found");
74
+ return;
56
75
  }
57
76
 
58
- const fileName = fileInfo?.uri?.split('/').pop();
77
+ const fileName = file.name;
59
78
 
60
79
  if (fileName) {
61
- var parts = fileName.split('.');
62
- var fileWithoutExtension = parts.slice(0, -1).join('.');
63
- var extension = parts[parts.length - 1];
80
+ const parts = fileName.split(".");
81
+ const fileWithoutExtension = parts.slice(0, -1).join(".");
82
+ const extension = parts[parts.length - 1];
83
+
64
84
  const formData = new FormData();
65
- formData.append('caption', message);
66
- formData.append('chat_id', chat_id ?? '-1001737180019');
67
- formData.append('document', {
68
- uri: dbPath,
69
- name: (customFileName?.(fileWithoutExtension) || fileWithoutExtension) + "." + extension,
70
- type: 'text/csv',
71
- });
72
- const response = await fetch(`https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendDocument`, {
73
- method: 'POST',
74
- body: formData,
75
- });
85
+ formData.append("caption", message);
86
+ formData.append("chat_id", chat_id ?? "-1001737180019");
87
+
88
+ formData.append("document", {
89
+ uri: file.uri,
90
+ name:
91
+ (customFileName?.(fileWithoutExtension) || fileWithoutExtension) +
92
+ "." +
93
+ extension,
94
+ type: "text/csv",
95
+ } as any);
96
+
97
+ const response = await fetch(
98
+ `https://api.telegram.org/bot923808407:AAEFBlllQNKCEn8E66fwEzCj5vs9qGwVGT4/sendDocument`,
99
+ {
100
+ method: "POST",
101
+ body: formData,
102
+ }
103
+ );
76
104
 
77
105
  const result = await response.json();
78
- if (result.ok == true) {
79
- onDone?.()
106
+
107
+ if (result.ok === true) {
108
+ onDone?.();
80
109
  } else {
81
- onFailed?.(result)
110
+ onFailed?.(JSON.stringify(result));
82
111
  }
83
112
  }
84
113
  } catch (ex) {
85
- onFailed?.(String(ex))
114
+ onFailed?.(String(ex));
86
115
  }
87
- }
88
- }
116
+ },
117
+ };
89
118
 
90
- export default Storage;
119
+ export default Storage;
@@ -2,7 +2,6 @@
2
2
  // useLibs
3
3
 
4
4
  import React from 'react';
5
- import { InteractionManager } from 'react-native';
6
5
 
7
6
  export interface useGlobalSubscriberReturn<T> {
8
7
  getValue: () => any,
@@ -38,7 +37,7 @@ export default function useGlobalSubscriber<T>(defaultValue?: any): useGlobalSub
38
37
  function notify(newValue?: any) {
39
38
  value = newValue;
40
39
  subscribers.forEach((fun: Function) => {
41
- InteractionManager.runAfterInteractions(() => {
40
+ requestIdleCallback(() => {
42
41
  fun?.(newValue)
43
42
  })
44
43
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.268",
3
+ "version": "0.0.269",
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/publisher.js CHANGED
@@ -2,14 +2,10 @@ const shell = require('child_process').execSync;
2
2
  const packJson = require("./package.json")
3
3
  const fs = require('fs');
4
4
  const version = packJson.version
5
- const vm = version.match(/([a-z])/g)
6
- const letter = vm ? vm[0] : null
7
- const number = version.replace(/-/g, "").replace(letter, "")
8
- let nextNumber = number.split(".")[2]
9
- let nextVersion = number.split(".")[0] + "." + number.split(".")[1] + "."
10
-
11
- nextNumber = Number(nextNumber) + 1
12
- nextVersion += nextNumber
5
+ const baseVersion = version.split('-')[0]
6
+ const parts = baseVersion.split('.')
7
+ let nextNumber = parseInt(parts[2]) + 1
8
+ let nextVersion = parts[0] + '.' + parts[1] + '.' + nextNumber
13
9
  const newPackJson = { ...packJson, version: nextVersion }
14
10
  fs.writeFileSync("./package.json", JSON.stringify(newPackJson, undefined, 2))
15
11
  shell("npm publish", { stdio: ['inherit', 'inherit', 'inherit'] })
@@ -0,0 +1,12 @@
1
+ const shell = require('child_process').execSync;
2
+ const packJson = require("./package.json")
3
+ const fs = require('fs');
4
+ const crypto = require('crypto')
5
+ const version = packJson.version
6
+ const baseVersion = version.split('-')[0]
7
+ const randomHash = crypto.randomBytes(4).toString('hex').substring(0,7)
8
+ const nextVersion = baseVersion + '-beta' + randomHash
9
+ const newPackJson = { ...packJson, version: nextVersion }
10
+ fs.writeFileSync("./package.json", JSON.stringify(newPackJson, undefined, 2))
11
+ shell("npm publish", { stdio: ['inherit', 'inherit', 'inherit'] })
12
+ console.log("\nbun add esoftplay@" + nextVersion + " && bun install\n")