@webority-technologies/mobile-core 0.0.1

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 (102) hide show
  1. package/README.md +15 -0
  2. package/lib/commonjs/api/publicClient.js +80 -0
  3. package/lib/commonjs/api/userClient.js +368 -0
  4. package/lib/commonjs/auth/authStore.js +155 -0
  5. package/lib/commonjs/auth/index.js +44 -0
  6. package/lib/commonjs/auth/jwt.js +88 -0
  7. package/lib/commonjs/config/index.js +65 -0
  8. package/lib/commonjs/formatters/currency.js +69 -0
  9. package/lib/commonjs/formatters/date.js +168 -0
  10. package/lib/commonjs/formatters/index.js +77 -0
  11. package/lib/commonjs/formatters/initials.js +32 -0
  12. package/lib/commonjs/formatters/number.js +88 -0
  13. package/lib/commonjs/formatters/phone.js +67 -0
  14. package/lib/commonjs/index.js +383 -0
  15. package/lib/commonjs/initSDK.js +45 -0
  16. package/lib/commonjs/initUserAuth.js +38 -0
  17. package/lib/commonjs/logger/index.js +137 -0
  18. package/lib/commonjs/network/index.js +25 -0
  19. package/lib/commonjs/network/networkStatus.js +98 -0
  20. package/lib/commonjs/package.json +1 -0
  21. package/lib/commonjs/permissions/index.js +200 -0
  22. package/lib/commonjs/storage/index.js +193 -0
  23. package/lib/commonjs/utils/imageCompression.js +75 -0
  24. package/lib/commonjs/utils/index.js +13 -0
  25. package/lib/commonjs/validators/index.js +193 -0
  26. package/lib/commonjs/versionCheck/index.js +395 -0
  27. package/lib/module/api/publicClient.js +76 -0
  28. package/lib/module/api/userClient.js +360 -0
  29. package/lib/module/auth/authStore.js +148 -0
  30. package/lib/module/auth/index.js +5 -0
  31. package/lib/module/auth/jwt.js +82 -0
  32. package/lib/module/config/index.js +57 -0
  33. package/lib/module/formatters/currency.js +64 -0
  34. package/lib/module/formatters/date.js +160 -0
  35. package/lib/module/formatters/index.js +8 -0
  36. package/lib/module/formatters/initials.js +27 -0
  37. package/lib/module/formatters/number.js +81 -0
  38. package/lib/module/formatters/phone.js +61 -0
  39. package/lib/module/index.js +30 -0
  40. package/lib/module/initSDK.js +40 -0
  41. package/lib/module/initUserAuth.js +34 -0
  42. package/lib/module/logger/index.js +133 -0
  43. package/lib/module/network/index.js +4 -0
  44. package/lib/module/network/networkStatus.js +91 -0
  45. package/lib/module/package.json +1 -0
  46. package/lib/module/permissions/index.js +197 -0
  47. package/lib/module/storage/index.js +189 -0
  48. package/lib/module/utils/imageCompression.js +69 -0
  49. package/lib/module/utils/index.js +4 -0
  50. package/lib/module/validators/index.js +171 -0
  51. package/lib/module/versionCheck/index.js +390 -0
  52. package/lib/typescript/commonjs/api/publicClient.d.ts +11 -0
  53. package/lib/typescript/commonjs/api/userClient.d.ts +49 -0
  54. package/lib/typescript/commonjs/auth/authStore.d.ts +43 -0
  55. package/lib/typescript/commonjs/auth/index.d.ts +5 -0
  56. package/lib/typescript/commonjs/auth/jwt.d.ts +31 -0
  57. package/lib/typescript/commonjs/config/index.d.ts +49 -0
  58. package/lib/typescript/commonjs/formatters/currency.d.ts +24 -0
  59. package/lib/typescript/commonjs/formatters/date.d.ts +22 -0
  60. package/lib/typescript/commonjs/formatters/index.d.ts +8 -0
  61. package/lib/typescript/commonjs/formatters/initials.d.ts +11 -0
  62. package/lib/typescript/commonjs/formatters/number.d.ts +15 -0
  63. package/lib/typescript/commonjs/formatters/phone.d.ts +13 -0
  64. package/lib/typescript/commonjs/index.d.ts +30 -0
  65. package/lib/typescript/commonjs/initSDK.d.ts +40 -0
  66. package/lib/typescript/commonjs/initUserAuth.d.ts +22 -0
  67. package/lib/typescript/commonjs/logger/index.d.ts +42 -0
  68. package/lib/typescript/commonjs/network/index.d.ts +3 -0
  69. package/lib/typescript/commonjs/network/networkStatus.d.ts +27 -0
  70. package/lib/typescript/commonjs/package.json +1 -0
  71. package/lib/typescript/commonjs/permissions/index.d.ts +20 -0
  72. package/lib/typescript/commonjs/storage/index.d.ts +42 -0
  73. package/lib/typescript/commonjs/utils/imageCompression.d.ts +31 -0
  74. package/lib/typescript/commonjs/utils/index.d.ts +3 -0
  75. package/lib/typescript/commonjs/validators/index.d.ts +46 -0
  76. package/lib/typescript/commonjs/versionCheck/index.d.ts +80 -0
  77. package/lib/typescript/module/api/publicClient.d.ts +11 -0
  78. package/lib/typescript/module/api/userClient.d.ts +49 -0
  79. package/lib/typescript/module/auth/authStore.d.ts +43 -0
  80. package/lib/typescript/module/auth/index.d.ts +5 -0
  81. package/lib/typescript/module/auth/jwt.d.ts +31 -0
  82. package/lib/typescript/module/config/index.d.ts +49 -0
  83. package/lib/typescript/module/formatters/currency.d.ts +24 -0
  84. package/lib/typescript/module/formatters/date.d.ts +22 -0
  85. package/lib/typescript/module/formatters/index.d.ts +8 -0
  86. package/lib/typescript/module/formatters/initials.d.ts +11 -0
  87. package/lib/typescript/module/formatters/number.d.ts +15 -0
  88. package/lib/typescript/module/formatters/phone.d.ts +13 -0
  89. package/lib/typescript/module/index.d.ts +30 -0
  90. package/lib/typescript/module/initSDK.d.ts +40 -0
  91. package/lib/typescript/module/initUserAuth.d.ts +22 -0
  92. package/lib/typescript/module/logger/index.d.ts +42 -0
  93. package/lib/typescript/module/network/index.d.ts +3 -0
  94. package/lib/typescript/module/network/networkStatus.d.ts +27 -0
  95. package/lib/typescript/module/package.json +1 -0
  96. package/lib/typescript/module/permissions/index.d.ts +20 -0
  97. package/lib/typescript/module/storage/index.d.ts +42 -0
  98. package/lib/typescript/module/utils/imageCompression.d.ts +31 -0
  99. package/lib/typescript/module/utils/index.d.ts +3 -0
  100. package/lib/typescript/module/validators/index.d.ts +46 -0
  101. package/lib/typescript/module/versionCheck/index.d.ts +80 -0
  102. package/package.json +112 -0
@@ -0,0 +1,383 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Logger", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _index3.Logger;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Permissions", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _index5.Permissions;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "RequestOfflineError", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _userClient.RequestOfflineError;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "SESSION_TERMINATION_CODES", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _userClient.SESSION_TERMINATION_CODES;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "Storage", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _index6.Storage;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "VersionCheck", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _index9.VersionCheck;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "addNetworkStatusListener", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _index4.addNetworkStatusListener;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "compressImage", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _index7.compressImage;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "decodeJWT", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _jwt.decodeJWT;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "formatCompactNumber", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _index2.formatCompactNumber;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "formatCurrency", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _index2.formatCurrency;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "formatDate", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _index2.formatDate;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "formatDateTime", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _index2.formatDateTime;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "formatNumber", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _index2.formatNumber;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "formatPercent", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _index2.formatPercent;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "formatPhone", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _index2.formatPhone;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "formatRelativeTime", {
103
+ enumerable: true,
104
+ get: function () {
105
+ return _index2.formatRelativeTime;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "formatTime", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _index2.formatTime;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "getConfig", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _index.getConfig;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "getConfigValue", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _index.getConfigValue;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "getInitials", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _index2.getInitials;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "getJWTExpiry", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _jwt.getJWTExpiry;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "getNetworkStatus", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _index4.getNetworkStatus;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "getToken", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _authStore.getToken;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "initUserAuth", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _initUserAuth.initUserAuth;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "initWebority", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _initSDK.initWebority;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "injectAuthActions", {
163
+ enumerable: true,
164
+ get: function () {
165
+ return _userClient.injectAuthActions;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "injectStore", {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _userClient.injectStore;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "isAadhaar", {
175
+ enumerable: true,
176
+ get: function () {
177
+ return _index8.isAadhaar;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "isAlphanumeric", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _index8.isAlphanumeric;
184
+ }
185
+ });
186
+ Object.defineProperty(exports, "isBetween", {
187
+ enumerable: true,
188
+ get: function () {
189
+ return _index8.isBetween;
190
+ }
191
+ });
192
+ Object.defineProperty(exports, "isEmail", {
193
+ enumerable: true,
194
+ get: function () {
195
+ return _index8.isEmail;
196
+ }
197
+ });
198
+ Object.defineProperty(exports, "isGstin", {
199
+ enumerable: true,
200
+ get: function () {
201
+ return _index8.isGstin;
202
+ }
203
+ });
204
+ Object.defineProperty(exports, "isHexColor", {
205
+ enumerable: true,
206
+ get: function () {
207
+ return _index8.isHexColor;
208
+ }
209
+ });
210
+ Object.defineProperty(exports, "isIfsc", {
211
+ enumerable: true,
212
+ get: function () {
213
+ return _index8.isIfsc;
214
+ }
215
+ });
216
+ Object.defineProperty(exports, "isIndianMobile", {
217
+ enumerable: true,
218
+ get: function () {
219
+ return _index8.isIndianMobile;
220
+ }
221
+ });
222
+ Object.defineProperty(exports, "isIndianPincode", {
223
+ enumerable: true,
224
+ get: function () {
225
+ return _index8.isIndianPincode;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "isInteger", {
229
+ enumerable: true,
230
+ get: function () {
231
+ return _index8.isInteger;
232
+ }
233
+ });
234
+ Object.defineProperty(exports, "isJWTExpired", {
235
+ enumerable: true,
236
+ get: function () {
237
+ return _jwt.isJWTExpired;
238
+ }
239
+ });
240
+ Object.defineProperty(exports, "isNonEmpty", {
241
+ enumerable: true,
242
+ get: function () {
243
+ return _index8.isNonEmpty;
244
+ }
245
+ });
246
+ Object.defineProperty(exports, "isNumeric", {
247
+ enumerable: true,
248
+ get: function () {
249
+ return _index8.isNumeric;
250
+ }
251
+ });
252
+ Object.defineProperty(exports, "isPan", {
253
+ enumerable: true,
254
+ get: function () {
255
+ return _index8.isPan;
256
+ }
257
+ });
258
+ Object.defineProperty(exports, "isPhone", {
259
+ enumerable: true,
260
+ get: function () {
261
+ return _index8.isPhone;
262
+ }
263
+ });
264
+ Object.defineProperty(exports, "isStrongPassword", {
265
+ enumerable: true,
266
+ get: function () {
267
+ return _index8.isStrongPassword;
268
+ }
269
+ });
270
+ Object.defineProperty(exports, "isUrl", {
271
+ enumerable: true,
272
+ get: function () {
273
+ return _index8.isUrl;
274
+ }
275
+ });
276
+ Object.defineProperty(exports, "maxLength", {
277
+ enumerable: true,
278
+ get: function () {
279
+ return _index8.maxLength;
280
+ }
281
+ });
282
+ Object.defineProperty(exports, "minLength", {
283
+ enumerable: true,
284
+ get: function () {
285
+ return _index8.minLength;
286
+ }
287
+ });
288
+ Object.defineProperty(exports, "normalizePhone", {
289
+ enumerable: true,
290
+ get: function () {
291
+ return _index2.normalizePhone;
292
+ }
293
+ });
294
+ Object.defineProperty(exports, "publicClient", {
295
+ enumerable: true,
296
+ get: function () {
297
+ return _publicClient.default;
298
+ }
299
+ });
300
+ Object.defineProperty(exports, "removeToken", {
301
+ enumerable: true,
302
+ get: function () {
303
+ return _authStore.removeToken;
304
+ }
305
+ });
306
+ Object.defineProperty(exports, "resetConfig", {
307
+ enumerable: true,
308
+ get: function () {
309
+ return _index.resetConfig;
310
+ }
311
+ });
312
+ Object.defineProperty(exports, "setConfig", {
313
+ enumerable: true,
314
+ get: function () {
315
+ return _index.setConfig;
316
+ }
317
+ });
318
+ Object.defineProperty(exports, "setDeviceInfoImplementation", {
319
+ enumerable: true,
320
+ get: function () {
321
+ return _index9.setDeviceInfoImplementation;
322
+ }
323
+ });
324
+ Object.defineProperty(exports, "setKeychainImplementation", {
325
+ enumerable: true,
326
+ get: function () {
327
+ return _authStore.setKeychainImplementation;
328
+ }
329
+ });
330
+ Object.defineProperty(exports, "setRemoteLogger", {
331
+ enumerable: true,
332
+ get: function () {
333
+ return _index3.setRemoteLogger;
334
+ }
335
+ });
336
+ Object.defineProperty(exports, "setStorageImplementation", {
337
+ enumerable: true,
338
+ get: function () {
339
+ return _index6.setStorageImplementation;
340
+ }
341
+ });
342
+ Object.defineProperty(exports, "storeToken", {
343
+ enumerable: true,
344
+ get: function () {
345
+ return _authStore.storeToken;
346
+ }
347
+ });
348
+ Object.defineProperty(exports, "useNetworkStatus", {
349
+ enumerable: true,
350
+ get: function () {
351
+ return _index4.useNetworkStatus;
352
+ }
353
+ });
354
+ Object.defineProperty(exports, "useVersionCheck", {
355
+ enumerable: true,
356
+ get: function () {
357
+ return _index9.useVersionCheck;
358
+ }
359
+ });
360
+ Object.defineProperty(exports, "userClient", {
361
+ enumerable: true,
362
+ get: function () {
363
+ return _userClient.default;
364
+ }
365
+ });
366
+ var _publicClient = _interopRequireDefault(require("./api/publicClient.js"));
367
+ var _userClient = _interopRequireWildcard(require("./api/userClient.js"));
368
+ var _authStore = require("./auth/authStore.js");
369
+ var _jwt = require("./auth/jwt.js");
370
+ var _index = require("./config/index.js");
371
+ var _index2 = require("./formatters/index.js");
372
+ var _initSDK = require("./initSDK.js");
373
+ var _initUserAuth = require("./initUserAuth.js");
374
+ var _index3 = require("./logger/index.js");
375
+ var _index4 = require("./network/index.js");
376
+ var _index5 = require("./permissions/index.js");
377
+ var _index6 = require("./storage/index.js");
378
+ var _index7 = require("./utils/index.js");
379
+ var _index8 = require("./validators/index.js");
380
+ var _index9 = require("./versionCheck/index.js");
381
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
382
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
383
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initWebority = void 0;
7
+ var _index = require("./config/index.js");
8
+ /**
9
+ * Simple initialization API for Webority packages
10
+ * One function to configure everything needed
11
+ */
12
+
13
+ /**
14
+ * Initialize Webority packages with your project configuration.
15
+ *
16
+ * @example
17
+ * // Basic setup
18
+ * initWebority({
19
+ * baseUrl: 'https://api.myapp.com'
20
+ * });
21
+ *
22
+ * @example
23
+ * // Full configuration
24
+ * initWebority({
25
+ * baseUrl: 'https://api.myapp.com',
26
+ * loggingEnabled: __DEV__,
27
+ * logLevel: 'warn',
28
+ * environment: __DEV__ ? 'Development' : 'Production'
29
+ * });
30
+ */
31
+ const initWebority = config => {
32
+ if (!config.baseUrl) {
33
+ throw new Error('baseUrl is required for Webority packages initialization');
34
+ }
35
+ (0, _index.setConfig)({
36
+ baseUrl: config.baseUrl,
37
+ loggingEnabled: config.loggingEnabled ?? true,
38
+ logLevel: config.logLevel || 'info',
39
+ environment: config.environment || 'Development',
40
+ country: (config.country || 'in').toLowerCase()
41
+ });
42
+ console.log('✅ Webority packages initialized successfully');
43
+ };
44
+ exports.initWebority = initWebority;
45
+ //# sourceMappingURL=initSDK.js.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initUserAuth = void 0;
7
+ var _userClient = require("./api/userClient.js");
8
+ /**
9
+ * Simple initialization API for Webority User package
10
+ * Easy setup for Redux integration
11
+ */
12
+
13
+ /**
14
+ * Auth action creators required by the user package.
15
+ */
16
+
17
+ /**
18
+ * Initialize user package with Redux store and auth actions.
19
+ *
20
+ * @example
21
+ * import store from './store';
22
+ * import { logout, refreshToken } from './actions/authActions';
23
+ *
24
+ * initUserAuth(store, { logout, refreshToken });
25
+ */
26
+ const initUserAuth = (store, authActions) => {
27
+ if (!store) {
28
+ throw new Error('Redux store is required for user package initialization');
29
+ }
30
+ if (!authActions.logout || !authActions.refreshToken) {
31
+ throw new Error('Both logout and refreshToken actions are required');
32
+ }
33
+ (0, _userClient.injectStore)(store);
34
+ (0, _userClient.injectAuthActions)(authActions);
35
+ console.log('✅ Webority User package initialized with Redux');
36
+ };
37
+ exports.initUserAuth = initUserAuth;
38
+ //# sourceMappingURL=initUserAuth.js.map
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setRemoteLogger = exports.Logger = void 0;
7
+ var _index = require("../config/index.js");
8
+ // ANSI color codes
9
+ const Colors = {
10
+ RESET: '\x1b[0m',
11
+ BLUE: '\x1b[34m',
12
+ YELLOW: '\x1b[33m',
13
+ RED_BOLD: '\x1b[31;1m'
14
+ };
15
+ const LogLevels = {
16
+ INFO: {
17
+ level: 'info',
18
+ color: Colors.BLUE
19
+ },
20
+ WARN: {
21
+ level: 'warn',
22
+ color: Colors.YELLOW
23
+ },
24
+ ERROR: {
25
+ level: 'error',
26
+ color: Colors.RED_BOLD
27
+ }
28
+ };
29
+
30
+ // Check if a specific log level is allowed
31
+ const isLogLevelAllowed = level => {
32
+ const levels = ['info', 'warn', 'error'];
33
+ const current = (0, _index.getConfigValue)('logLevel', 'info');
34
+ return levels.indexOf(level) >= levels.indexOf(current);
35
+ };
36
+ const isEnabled = () => (0, _index.getConfigValue)('loggingEnabled', true);
37
+
38
+ /**
39
+ * Optional remote sink. Apps wire this via `setRemoteLogger()` to forward errors
40
+ * and breadcrumbs to Crashlytics, Sentry, Bugsnag, etc. — without making the
41
+ * library depend on any of them.
42
+ *
43
+ * Every method is optional; the library calls only what the adapter implements.
44
+ */
45
+
46
+ let remote = null;
47
+
48
+ /**
49
+ * Inject a remote logger adapter (e.g. Firebase Crashlytics, Sentry).
50
+ * Pass `null` to detach. Safe to call before or after `initWebority`.
51
+ */
52
+ const setRemoteLogger = impl => {
53
+ remote = impl;
54
+ };
55
+ exports.setRemoteLogger = setRemoteLogger;
56
+ const safe = fn => {
57
+ if (!fn) {
58
+ return;
59
+ }
60
+ try {
61
+ fn();
62
+ } catch {
63
+ /* never let the remote sink break the caller */
64
+ }
65
+ };
66
+ const toErrorObject = input => {
67
+ if (input instanceof Error) {
68
+ return input;
69
+ }
70
+ if (typeof input === 'string') {
71
+ return new Error(input);
72
+ }
73
+ try {
74
+ return new Error(JSON.stringify(input));
75
+ } catch {
76
+ return new Error(String(input));
77
+ }
78
+ };
79
+ const logInfo = (message, ...optionalParams) => {
80
+ if (!isEnabled() || !isLogLevelAllowed(LogLevels.INFO.level)) {
81
+ return;
82
+ }
83
+ console.info(`${LogLevels.INFO.color}[INFO]: ${message}${Colors.RESET}`, ...optionalParams);
84
+ safe(() => remote?.log?.('info', message, optionalParams));
85
+ };
86
+ const logWarning = (message, ...optionalParams) => {
87
+ if (!isEnabled() || !isLogLevelAllowed(LogLevels.WARN.level)) {
88
+ return;
89
+ }
90
+ console.warn(`${LogLevels.WARN.color}[WARNING]: ${message}${Colors.RESET}`, ...optionalParams);
91
+ safe(() => remote?.log?.('warn', message, optionalParams));
92
+ };
93
+ const logError = (message, ...optionalParams) => {
94
+ if (isEnabled() && isLogLevelAllowed(LogLevels.ERROR.level)) {
95
+ console.error(`${LogLevels.ERROR.color}[ERROR]: ${message}${Colors.RESET}`, ...optionalParams);
96
+ }
97
+ // Always forward errors to the remote sink — even when console logging is muted —
98
+ // so production crash reporting still works with `loggingEnabled: false`.
99
+ safe(() => remote?.log?.('error', message, optionalParams));
100
+ // First optional param is treated as the underlying error if it looks like one.
101
+ const candidate = optionalParams[0];
102
+ if (candidate !== undefined) {
103
+ safe(() => remote?.recordError?.(toErrorObject(candidate), {
104
+ source: 'Logger.error',
105
+ message
106
+ }));
107
+ }
108
+ };
109
+ const breadcrumb = (message, data) => {
110
+ if (isEnabled() && isLogLevelAllowed('info')) {
111
+ console.info(`${Colors.BLUE}[BREADCRUMB]: ${message}${Colors.RESET}`, data ?? '');
112
+ }
113
+ safe(() => remote?.breadcrumb?.(message, data));
114
+ };
115
+ const recordError = (error, context) => {
116
+ const err = toErrorObject(error);
117
+ if (isEnabled() && isLogLevelAllowed('error')) {
118
+ console.error(`${Colors.RED_BOLD}[RECORDED]: ${err.message}${Colors.RESET}`, context ?? '');
119
+ }
120
+ safe(() => remote?.recordError?.(err, context));
121
+ };
122
+ const setUser = (id, attrs) => {
123
+ safe(() => remote?.setUser?.(id, attrs));
124
+ };
125
+ const setAttribute = (key, value) => {
126
+ safe(() => remote?.setAttribute?.(key, value));
127
+ };
128
+ const Logger = exports.Logger = {
129
+ info: logInfo,
130
+ warn: logWarning,
131
+ error: logError,
132
+ breadcrumb,
133
+ recordError,
134
+ setUser,
135
+ setAttribute
136
+ };
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "addNetworkStatusListener", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _networkStatus.addNetworkStatusListener;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "getNetworkStatus", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _networkStatus.getNetworkStatus;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "useNetworkStatus", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _networkStatus.useNetworkStatus;
22
+ }
23
+ });
24
+ var _networkStatus = require("./networkStatus.js");
25
+ //# sourceMappingURL=index.js.map