@m4l/core 0.0.7 → 0.0.10

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './contexts';
2
2
  export * from './hooks';
3
3
  export { EmitEvents } from './types';
4
- export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation } from './types';
4
+ export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventFunListener, } from './types';
5
5
  export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
6
6
  export * from './utils';
package/dist/index.js CHANGED
@@ -1,34 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source2, exclude) => {
21
- var target = {};
22
- for (var prop in source2)
23
- if (__hasOwnProp.call(source2, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source2[prop];
25
- if (source2 != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source2)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source2, prop))
28
- target[prop] = source2[prop];
29
- }
30
- return target;
31
- };
32
1
  import { createContext, useState, useContext, useCallback, useEffect, useLayoutEffect } from "react";
33
2
  import { jsx } from "react/jsx-runtime";
34
3
  const initialValue$2 = {
@@ -42,11 +11,10 @@ const initialValue$2 = {
42
11
  };
43
12
  const EnvironmentContext = createContext(initialValue$2);
44
13
  function EnvironmentProvider(props) {
45
- const _a = props, {
46
- children
47
- } = _a, other = __objRest(_a, [
48
- "children"
49
- ]);
14
+ const {
15
+ children,
16
+ ...other
17
+ } = props;
50
18
  const [finalEnvironment] = useState(other);
51
19
  return /* @__PURE__ */ jsx(EnvironmentContext.Provider, {
52
20
  value: finalEnvironment,
@@ -77,7 +45,7 @@ function setLocalStorage(key, value) {
77
45
  try {
78
46
  const item = window.localStorage.getItem(key);
79
47
  let newValue = item !== null ? JSON.parse(item) : {};
80
- newValue = __spreadValues(__spreadValues({}, newValue), value);
48
+ newValue = { ...newValue, ...value };
81
49
  window.localStorage.setItem(key, JSON.stringify(newValue));
82
50
  } catch (e) {
83
51
  console.error(e);
@@ -1322,10 +1290,11 @@ const isObject = (value) => typeof value === "object" && value !== null;
1322
1290
  const mapObjectSkip = Symbol("skip");
1323
1291
  const isObjectCustom = (value) => isObject(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
1324
1292
  const mapObject = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap()) => {
1325
- options = __spreadValues({
1293
+ options = {
1326
1294
  deep: false,
1327
- target: {}
1328
- }, options);
1295
+ target: {},
1296
+ ...options
1297
+ };
1329
1298
  if (isSeen.has(object)) {
1330
1299
  return isSeen.get(object);
1331
1300
  }
@@ -1437,11 +1406,10 @@ var EmitEvents = /* @__PURE__ */ ((EmitEvents2) => {
1437
1406
  })(EmitEvents || {});
1438
1407
  const axiosInstance = axios.create({});
1439
1408
  function getResponse(endPoint, response) {
1440
- var _a, _b;
1441
1409
  console.log("Axios response", response, typeof response.data);
1442
1410
  if (response && response.data && typeof response.data === "object") {
1443
- if (response.data.error && ((_a = response.data.error) == null ? void 0 : _a.code) && ((_b = response.data.error) == null ? void 0 : _b.msg) !== void 0) {
1444
- return Promise.reject(__spreadProps(__spreadValues({}, response.data.error), { status: response.status }));
1411
+ if (response.data.error && response.data.error?.code && response.data.error?.msg !== void 0) {
1412
+ return Promise.reject({ ...response.data.error, status: response.status });
1445
1413
  }
1446
1414
  return response.data;
1447
1415
  }
@@ -1452,7 +1420,6 @@ function getResponse(endPoint, response) {
1452
1420
  });
1453
1421
  }
1454
1422
  function getError(error, hostTools, checkUnAuthorized = true) {
1455
- var _a, _b;
1456
1423
  const { toast } = hostTools;
1457
1424
  let err = {
1458
1425
  message: "",
@@ -1460,11 +1427,11 @@ function getError(error, hostTools, checkUnAuthorized = true) {
1460
1427
  code: 0
1461
1428
  };
1462
1429
  console.log("getError", error);
1463
- if ((error == null ? void 0 : error.code) !== void 0 && err.status !== void 0 && error.message !== void 0) {
1464
- err = __spreadValues(__spreadValues({}, err), error);
1465
- } else if (error == null ? void 0 : error.response) {
1466
- if (error.response.data && typeof error.response.data === "object" && error.response.data.error && ((_a = error.response.data.error) == null ? void 0 : _a.code) && ((_b = error.response.data.error) == null ? void 0 : _b.message) !== void 0) {
1467
- err = __spreadProps(__spreadValues({}, error.response.data.error), { status: error.response.status });
1430
+ if (error?.code !== void 0 && err.status !== void 0 && error.message !== void 0) {
1431
+ err = { ...err, ...error };
1432
+ } else if (error?.response) {
1433
+ if (error.response.data && typeof error.response.data === "object" && error.response.data.error && error.response.data.error?.code && error.response.data.error?.message !== void 0) {
1434
+ err = { ...error.response.data.error, status: error.response.status };
1468
1435
  } else {
1469
1436
  err.message = error.message;
1470
1437
  err.status = error.response.status;
@@ -1473,11 +1440,11 @@ function getError(error, hostTools, checkUnAuthorized = true) {
1473
1440
  if (checkUnAuthorized && error.response.status === 401) {
1474
1441
  hostTools.events_emit(EmitEvents.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {});
1475
1442
  }
1476
- } else if (error == null ? void 0 : error.request) {
1477
- err.message = `${error == null ? void 0 : error.code} ${error.message}`;
1443
+ } else if (error?.request) {
1444
+ err.message = `${error?.code} ${error.message}`;
1478
1445
  err.code = -1;
1479
1446
  } else {
1480
- err.message = `${error == null ? void 0 : error.code} ${error.message}`;
1447
+ err.message = `${error?.code} ${error.message}`;
1481
1448
  err.status = 0;
1482
1449
  err.code = -2;
1483
1450
  }
@@ -1525,11 +1492,10 @@ const initialValue$1 = {
1525
1492
  };
1526
1493
  const HostToolsContext = createContext(initialValue$1);
1527
1494
  function HostToolsProvider(props) {
1528
- const _a = props, {
1529
- children
1530
- } = _a, hostTools = __objRest(_a, [
1531
- "children"
1532
- ]);
1495
+ const {
1496
+ children,
1497
+ ...hostTools
1498
+ } = props;
1533
1499
  const [finalTools] = useState(hostTools);
1534
1500
  return /* @__PURE__ */ jsx(HostToolsContext.Provider, {
1535
1501
  value: finalTools,
@@ -1684,14 +1650,17 @@ function ModuleDictionaryProvider(props) {
1684
1650
  networkOperation({
1685
1651
  method: "GET",
1686
1652
  endPoint: isAuth ? `dictionaries/${moduleId}` : `na/dictionaries/${moduleId}`,
1687
- parms: __spreadValues({
1688
- comps: componentsDictionary
1689
- }, isAuth ? {} : {
1690
- domain_token
1691
- })
1653
+ parms: {
1654
+ comps: componentsDictionary,
1655
+ ...isAuth ? {} : {
1656
+ domain_token
1657
+ }
1658
+ }
1692
1659
  }).then((response) => {
1693
1660
  if (mounted) {
1694
- setModuleDictionary(__spreadValues({}, response));
1661
+ setModuleDictionary({
1662
+ ...response
1663
+ });
1695
1664
  addFlag("dictionary_loaded");
1696
1665
  }
1697
1666
  }).finally(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.10",
5
5
  "license": "UNLICENSED",
6
6
  "author": "M4L Team",
7
7
  "scripts": {