esoftplay 0.0.140-u → 0.0.140-w

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
@@ -227,6 +227,7 @@ if (fs.existsSync(packjson)) {
227
227
  "compilerOptions": {\n\
228
228
  "allowSyntheticDefaultImports": true,\n\
229
229
  "experimentalDecorators": true,\n\
230
+ "resolveJsonModule": true, \n\
230
231
  "forceConsistentCasingInFileNames": true,\n\
231
232
  "importHelpers": true,\n\
232
233
  "jsx": "react-native",\n\
package/bin/router.js CHANGED
@@ -437,4 +437,39 @@ export interface EspArgsInterface {
437
437
  return console.log(err);
438
438
  }
439
439
  });
440
+
441
+ function readToJSON(path) {
442
+ var txt = fs.readFileSync(path, 'utf8');
443
+ let isJSON = txt.startsWith('{') || txt.startsWith('[')
444
+ return isJSON ? JSON.parse(txt) : txt
445
+ }
446
+ const espConfig = readToJSON("./config.json")
447
+ const presets = {
448
+ timezone: "",
449
+ protocol: "",
450
+ uri: "",
451
+ url: "",
452
+ content: "",
453
+ webviewOpen: "",
454
+ webviewClose: "",
455
+ api: "",
456
+ data: "",
457
+ home: {
458
+ member: "",
459
+ public: ""
460
+ },
461
+ group_id: 0,
462
+ langIds: [],
463
+ theme: [],
464
+ comment_login: 1,
465
+ notification: 0,
466
+ ...espConfig.config
467
+ }
468
+ if (isChange(tmpDir + "config.json", JSON.stringify(presets))) {
469
+ fs.writeFile(tmpDir + "config.json", JSON.stringify(presets), { flag: 'w' }, function (err) {
470
+ if (err) {
471
+ return console.log(err);
472
+ }
473
+ });
474
+ }
440
475
  }
package/esp.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { EspAssets } from 'esoftplay/cache/assets';
2
+ import cacheConfig from 'esoftplay/cache/config.json';
2
3
  import { LibLocale } from 'esoftplay/cache/lib/locale/import';
3
4
  import { EspRouterPropertyInterface } from 'esoftplay/cache/properties';
4
5
  import { EspRouterInterface } from 'esoftplay/cache/routers';
@@ -7,6 +8,8 @@ import { LogBox, Platform } from 'react-native';
7
8
  import 'react-native-reanimated';
8
9
  import './oneplusfixfont';
9
10
 
11
+ type ConfigType = typeof cacheConfig
12
+
10
13
  const ignoreWarns = [
11
14
  "Setting a timer for a long period of time",
12
15
  "VirtualizedLists should never be nested inside plain ScrollViews with the same orientation",
@@ -79,21 +82,21 @@ const esp = {
79
82
  versionName(): string {
80
83
  return (Platform.OS == 'android' ? Constants?.expoConfig?.android?.versionCode : Constants?.expoConfig?.ios?.buildNumber) + '-' + esp.config('publish_id')
81
84
  },
82
- config(param?: string, ...params: string[]): any {
83
- let out: any = esp._config();
85
+ config<T = ConfigType>(param?: keyof ConfigType, ...params: string[]): T {
86
+ let out: any = this._config();
84
87
  if (param) {
85
- var _params = [param, ...params]
86
- if (_params.length > 0)
87
- for (let i = 0; i < _params.length; i++) {
88
- const key = _params[i];
89
- if (out?.hasOwnProperty?.(key)) {
90
- out = out[key];
91
- } else {
92
- out = {};
93
- }
88
+ const _params = [param, ...params];
89
+ for (let i = 0; i < _params.length; i++) {
90
+ const key = _params[i];
91
+ if (out && typeof out === 'object' && out.hasOwnProperty(key)) {
92
+ out = out[key];
93
+ } else {
94
+ return {} as T; // Return empty object if key doesn't exist
94
95
  }
96
+ }
95
97
  }
96
- return out;
98
+
99
+ return out as T;
97
100
  },
98
101
  isDebug(message: string): boolean {
99
102
  if (!lconf) {
@@ -117,7 +120,7 @@ const esp = {
117
120
  return out;
118
121
  }
119
122
  },
120
- lang(moduleTask: string, langName: string, ...stringToBe: string[]): string {
123
+ lang<T extends keyof EspRouterInterface>(moduleTask: T, langName: string, ...stringToBe: string[]): string {
121
124
  let string = LibLocale.stateLang().get()?.[esp.langId()]?.[moduleTask]?.[langName]
122
125
  if (!string) {
123
126
  string = esp.assets("locale/id.json")?.[moduleTask]?.[langName]
@@ -156,7 +159,7 @@ const esp = {
156
159
  const properties = require('./cache/properties')
157
160
  return properties(modtast.join("/"));
158
161
  },
159
- _config() {
162
+ _config(): typeof cacheConfig {
160
163
  app = esp.mergeDeep(app, conf)
161
164
  var msg = ''
162
165
  if (!app.hasOwnProperty('config')) {
@@ -173,7 +176,7 @@ const esp = {
173
176
  throw error;
174
177
  }
175
178
 
176
- var config = {
179
+ const config = {
177
180
  // default config
178
181
  timezone: "Asia/Jakarta",
179
182
  protocol: "http",
@@ -55,9 +55,10 @@ export default class m {
55
55
  spec = { [pathToUpdate]: [command, ...allValues] }
56
56
  else
57
57
  spec = [command, ...allValues]
58
- if (hasError)
58
+ if (hasError) {
59
+ console.warn("LibObject: Please check your cursor!")
59
60
  this.#value = array
60
- else
61
+ } else
61
62
  this.#value = update(array, spec)
62
63
  return this
63
64
  }
@@ -169,9 +170,10 @@ function cursorBuilder(command: string, array: any, value: any, ...values: any[]
169
170
  else
170
171
  spec = [command, ...allValues]
171
172
 
172
- if (hasError)
173
+ if (hasError) {
174
+ console.warn("LibObject: Please check your cursor!")
173
175
  return array
174
- else
176
+ } else
175
177
  return update(array, spec)
176
178
  }
177
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.140-u",
3
+ "version": "0.0.140-w",
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",