esoftplay 0.0.131-e → 0.0.131-g

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/cli.js CHANGED
@@ -833,7 +833,11 @@ function build() {
833
833
  const fs = require('fs');
834
834
  const path = require('path');
835
835
  const directoryPath = './'; // Replace with the path to your directory
836
-
836
+ function getTime() {
837
+ const adjustedDate = new Date().getTime() + 7 * 60 * 60000; // Add offset in milliseconds
838
+ const isoStringWithGMTPlus7 = new Date(adjustedDate).toISOString();
839
+ return isoStringWithGMTPlus7.replace('T', ' ').replace(/\.[0-9]+Z/g, "")
840
+ }
837
841
  fs.readdir(directoryPath, (err, files) => {
838
842
  if (err) {
839
843
  console.error('Error reading directory:', err);
@@ -853,7 +857,7 @@ function build() {
853
857
  // const oldFileName = fileName.replace(regexPattern, '$1');
854
858
  let ext = fileName.split(".")
855
859
  ext.shift()
856
- fs.renameSync('./' + fileName, './' + ajson.expo.name + "-" + new Date().toISOString() + "." + ext.join("."))
860
+ fs.renameSync('./' + fileName, './' + ajson.expo.name + "-" + getTime() + "." + ext.join("."))
857
861
  });
858
862
  });
859
863
  let tmId = "-1001429450501"
package/bin/router.js CHANGED
@@ -151,14 +151,14 @@ checks.forEach(modules => {
151
151
  tmpTask[clsName]['function'] = {}
152
152
  UseLibs.push(module + "/" + name) /* get export default */
153
153
  if (m = (/\n?export\sdefault(( )){/).exec(data)) {
154
- tmpTask[clsName]['uselibs'] = 'function _' + m[1].replace(m[2], clsName).trim() + "(): void;"
155
- tmpTask[clsName]['namespaces'] = "namespace " + clsName.trim()
154
+ tmpTask[clsName]['object'] = 'function _' + m[1].replace(m[2], clsName).trim() + "(): void;"
155
+ tmpTask[clsName]['namespaces'] = clsName.trim() + ":"
156
156
  }
157
157
  /* get exported funtion */
158
158
  if (f = data.match(/\n\s{2}(([A-Za-z0-9]+).*){/g)) {
159
159
  for (let i = 0; i < f.length; i++) {
160
160
  const _f = (/\n\s{2}(([A-Za-z0-9]+).*){/g).exec(f[i]);
161
- tmpTask[clsName]['function'][_f[2]] = 'function ' + _f[1] + ';'
161
+ tmpTask[clsName]['function'][_f[2]] = _f[1] + ';'
162
162
  }
163
163
  }
164
164
  }
@@ -565,6 +565,27 @@ declare module "esoftplay" {
565
565
  ItemText += "\n ";
566
566
  }
567
567
  ItemText += "}";
568
+ } else if (tmpTask[clsName]["object"]) {
569
+ for (var i = 0; i < tmpTask[clsName]["interface"].length; i++) {
570
+ ItemText += "\n export " + tmpTask[clsName]["interface"][i].replace(/\n/g, "\n ");
571
+ }
572
+ ItemText += "\n export " + tmpTask[clsName]["object"];
573
+ for (var i = 0; i < tmpTask[clsName]["type"].length; i++) {
574
+ ItemText += "\n export " + tmpTask[clsName]["type"][i].replace(/\n/g, "\n ");
575
+ }
576
+ var isFilled = false;
577
+ ItemText += "\n declare const " + tmpTask[clsName]["namespaces"] + " {";
578
+ for (fun in tmpTask[clsName]["var"]) {
579
+ ItemText += "\n export " + tmpTask[clsName]["var"][fun];
580
+ }
581
+ for (fun in tmpTask[clsName]["function"]) {
582
+ ItemText += "\n " + tmpTask[clsName]["function"][fun];
583
+ isFilled = true;
584
+ }
585
+ if (isFilled) {
586
+ ItemText += "\n ";
587
+ }
588
+ ItemText += "}";
568
589
  }
569
590
  const [module, task] = clsName.split(/(?=[A-Z])/)
570
591
  const nav = module?.toLowerCase() + '/' + task?.toLowerCase()
package/error.ts CHANGED
@@ -9,7 +9,11 @@ let pack = require('../../package.json');
9
9
  let app = require('../../app.json');
10
10
  const { manifest } = Constants;
11
11
 
12
-
12
+ function getTime() {
13
+ const adjustedDate = new Date().getTime() + 7 * 60 * 60000; // Add offset in milliseconds
14
+ const isoStringWithGMTPlus7 = new Date(adjustedDate).toISOString();
15
+ return isoStringWithGMTPlus7.replace('T', ' ').replace(/\.[0-9]+Z/g, "")
16
+ }
13
17
  // const defaultErrorHandler = ErrorUtils?.getGlobalHandler?.()
14
18
 
15
19
  const myErrorHandler = (e: any, isFatal: any) => {
@@ -28,7 +32,7 @@ export function setError(error?: any) {
28
32
  user,
29
33
  error: String(error),
30
34
  routes: routesName,
31
- time: new Date().toISOString()
35
+ time: getTime()
32
36
  };
33
37
  try {
34
38
  AsyncStorage.setItem(`${config?.domain}error`, JSON.stringify(_e));
@@ -47,7 +51,7 @@ export function reportApiError(fetch: any, error: any) {
47
51
  'slug: ' + "#" + manifest?.slug,
48
52
  'error: ' + error,
49
53
  '\n\n\ndev: ' + Platform.OS + ' - ' + Constants.deviceName,
50
- 'time: ' + new Date().toISOString(),
54
+ 'time: ' + getTime(),
51
55
  'app/pub_id: ' + Constants.appOwnership + '/' + (config?.publish_id || '-'),
52
56
  'user_id: ' + user?.id || user?.user_id || '-',
53
57
  'username: ' + user?.username || '-',
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ // noPage
40
+ // withObject
41
+ var async_storage_1 = require("@react-native-async-storage/async-storage");
42
+ var esoftplay_1 = require("esoftplay");
43
+ var import_1 = require("esoftplay/cache/lib/crypt/import");
44
+ var import_2 = require("esoftplay/cache/lib/curl/import");
45
+ var import_3 = require("esoftplay/cache/lib/notification/import");
46
+ var import_4 = require("esoftplay/cache/user/class/import");
47
+ var import_5 = require("esoftplay/cache/user/data/import");
48
+ var global_1 = require("esoftplay/global");
49
+ var moment_1 = require("esoftplay/moment");
50
+ var expo_constants_1 = require("expo-constants");
51
+ var Notifications = require("expo-notifications");
52
+ var react_native_1 = require("react-native");
53
+ var state = (0, global_1.default)(null, { persistKey: "user", loadOnInit: true });
54
+ exports.default = {
55
+ state: function () {
56
+ return state;
57
+ },
58
+ create: function (user) {
59
+ return new Promise(function (r, j) {
60
+ var _a;
61
+ (_a = state === null || state === void 0 ? void 0 : state.set) === null || _a === void 0 ? void 0 : _a.call(state, user);
62
+ if (esoftplay_1.esp.config('notification') == 1) {
63
+ import_4.UserClass.pushToken();
64
+ }
65
+ r(user);
66
+ });
67
+ },
68
+ load: function (callback) {
69
+ var _this = this;
70
+ return new Promise(function (r, j) { return __awaiter(_this, void 0, void 0, function () {
71
+ return __generator(this, function (_a) {
72
+ async_storage_1.default.getItem('user').then(function (user) {
73
+ var _a, _b;
74
+ if (user) {
75
+ var juser = JSON.parse(user);
76
+ if (callback)
77
+ callback(((_a = state === null || state === void 0 ? void 0 : state.get) === null || _a === void 0 ? void 0 : _a.call(state)) || juser);
78
+ r((((_b = state === null || state === void 0 ? void 0 : state.get) === null || _b === void 0 ? void 0 : _b.call(state)) || juser));
79
+ }
80
+ else {
81
+ if (callback)
82
+ callback(null);
83
+ r(null);
84
+ }
85
+ });
86
+ return [2 /*return*/];
87
+ });
88
+ }); });
89
+ },
90
+ isLogin: function (callback) {
91
+ var _this = this;
92
+ return new Promise(function (r, j) {
93
+ _this.load().then(function (user) {
94
+ r(user);
95
+ if (callback)
96
+ callback(user);
97
+ }).catch(function (nouser) {
98
+ r(null);
99
+ if (callback)
100
+ callback(null);
101
+ });
102
+ });
103
+ },
104
+ delete: function () {
105
+ var _this = this;
106
+ return new Promise(function (r) { return __awaiter(_this, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ Notifications.setBadgeCountAsync(0);
111
+ state.reset();
112
+ return [4 /*yield*/, async_storage_1.default.removeItem("user_notification")];
113
+ case 1:
114
+ _a.sent();
115
+ import_5.UserData.deleteAll();
116
+ if (esoftplay_1.esp.config('notification') == 1) {
117
+ import_4.UserClass.pushToken();
118
+ }
119
+ r();
120
+ return [2 /*return*/];
121
+ }
122
+ });
123
+ }); });
124
+ },
125
+ pushToken: function () {
126
+ var _this = this;
127
+ return new Promise(function (resolve, reject) {
128
+ if (expo_constants_1.default.appOwnership == 'expo' && !esoftplay_1.esp.isDebug('')) {
129
+ resolve(undefined);
130
+ return;
131
+ }
132
+ import_3.LibNotification.requestPermission(function (token) { return __awaiter(_this, void 0, void 0, function () {
133
+ var config_1, post;
134
+ var _this = this;
135
+ return __generator(this, function (_a) {
136
+ if (token && token.includes("ExponentPushToken")) {
137
+ config_1 = esoftplay_1.esp.config();
138
+ post = {
139
+ user_id: 0,
140
+ group_id: esoftplay_1.esp.config('group_id'),
141
+ username: "",
142
+ token: token,
143
+ push_id: "",
144
+ is_app: expo_constants_1.default.appOwnership == 'expo' ? 0 : 1,
145
+ os: react_native_1.Platform.OS,
146
+ device: expo_constants_1.default.deviceName,
147
+ secretkey: new import_1.LibCrypt().encode(config_1.salt + "|" + (0, moment_1.default)().format("YYYY-MM-DD hh:mm:ss"))
148
+ };
149
+ import_4.UserClass.load(function (user) { return __awaiter(_this, void 0, void 0, function () {
150
+ var push_id;
151
+ return __generator(this, function (_a) {
152
+ switch (_a.label) {
153
+ case 0:
154
+ if (user) {
155
+ user["user_id"] = user.id;
156
+ Object.keys(user).forEach(function (userfield) {
157
+ Object.keys(post).forEach(function (postfield) {
158
+ if (postfield == userfield && postfield != "os" && postfield != "token" && postfield != "secretkey" && postfield != "push_id" && postfield != "device") {
159
+ post[postfield] = user[userfield];
160
+ }
161
+ });
162
+ });
163
+ }
164
+ return [4 /*yield*/, async_storage_1.default.getItem("push_id")];
165
+ case 1:
166
+ push_id = _a.sent();
167
+ if (push_id)
168
+ post["push_id"] = push_id;
169
+ new import_2.LibCurl(config_1.protocol + "://" + config_1.domain + config_1.uri + "user/push-token", post, function (res, msg) {
170
+ async_storage_1.default.setItem("push_id", String(Number.isInteger(parseInt(res)) ? res : push_id));
171
+ async_storage_1.default.setItem("token", String(token));
172
+ resolve(res);
173
+ }, function (msg) {
174
+ resolve(msg.message);
175
+ });
176
+ return [2 /*return*/];
177
+ }
178
+ });
179
+ }); });
180
+ }
181
+ return [2 /*return*/];
182
+ });
183
+ }); });
184
+ });
185
+ }
186
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.131-e",
3
+ "version": "0.0.131-g",
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",