@m4l/core 2.0.28 → 2.0.29

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/contexts/AuthContext/AuthContext.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAG,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAMtE,QAAA,MAAM,WAAW,oDAAiD,CAAC;AAEnE;;GAEG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,oDA8H7C;AACD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/contexts/AuthContext/AuthContext.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAG,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAMtE,QAAA,MAAM,WAAW,oDAAiD,CAAC;AAEnE;;GAEG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,oDAoI7C;AACD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
@@ -1,46 +1,46 @@
1
1
  import { jsx as U } from "@emotion/react/jsx-runtime";
2
- import { createContext as _, useReducer as w, useEffect as p, useCallback as m } from "react";
3
- import { useEnvironment as A } from "../../hooks/useEnvironment/index.js";
4
- import { useHostTools as I } from "../../hooks/useHostTools/index.js";
5
- import { useLocalStorageWithListener as L } from "../../hooks/useLocalStorageWithListener/index.js";
6
- import { useNetwork as P } from "../../hooks/useNetwork/index.js";
2
+ import { createContext as _, useReducer as w, useEffect as p, useCallback as l } from "react";
3
+ import { useEnvironment as z } from "../../hooks/useEnvironment/index.js";
4
+ import { useHostTools as A } from "../../hooks/useHostTools/index.js";
5
+ import { useLocalStorageWithListener as I } from "../../hooks/useLocalStorageWithListener/index.js";
6
+ import { useNetwork as L } from "../../hooks/useNetwork/index.js";
7
7
  import { initialState as f, EnumTypes as s } from "./constants.js";
8
- import { getLocalStorage as x } from "../../utils/getLocalStorage/index.js";
9
- import { setLocalStorage as l } from "../../utils/setLocalStorage/index.js";
8
+ import { getLocalStorage as P } from "../../utils/getLocalStorage/index.js";
9
+ import { setLocalStorage as c } from "../../utils/setLocalStorage/index.js";
10
10
  import "axios";
11
11
  import "qs";
12
12
  import "camelcase-keys";
13
13
  import "snakecase-keys";
14
- import { EmmitEvents as N } from "../../types/index.js";
15
- import { JWTReducer as k } from "./helpers.js";
16
- const z = _(null);
17
- function Q(h) {
18
- const { children: g, isMicroFrontEnd: r = !1, loggedUser: c } = h, [T, i] = w(k, r ? { ...f, user: c, isAuthenticated: !0, isInitialized: !0 } : f), { events_add_listener: E } = I(), { networkOperation: e } = P(), { domain_token: d } = A(), [y, a] = L(
14
+ import { EmmitEvents as x } from "../../types/index.js";
15
+ import { JWTReducer as N } from "./helpers.js";
16
+ const k = _(null);
17
+ function Q(g) {
18
+ const { children: h, isMicroFrontEnd: i = !1, loggedUser: m } = g, [T, r] = w(N, i ? { ...f, user: m, isAuthenticated: !0, isInitialized: !0 } : f), { events_add_listener: E } = A(), { networkOperation: t } = L(), { domain_token: d } = z(), [y, a] = I(
19
19
  // Variable para saber si ha cambiado la session en otro navegador
20
20
  "vSession",
21
21
  (/* @__PURE__ */ new Date()).getTime() + ""
22
22
  );
23
23
  p(() => {
24
- const t = async () => {
25
- e({
24
+ const e = async () => {
25
+ console.log("*******+initialize"), t({
26
26
  method: "GET",
27
27
  endPoint: "auth/login",
28
28
  parms: { user_data: !0 },
29
29
  checkUnAuthorized: !1,
30
30
  responseToCamelCase: !0
31
31
  }).then((o) => {
32
- i({
32
+ console.log("*******+initialize success"), r({
33
33
  type: s.Initial,
34
34
  payload: {
35
35
  isAuthenticated: !0,
36
36
  user: o.user
37
37
  }
38
- }), x("userData", {
38
+ }), P("userData", {
39
39
  email: o.user.email,
40
40
  remember: !0
41
- })?.email !== o.user.email && l("userData", { email: o.user.email }, !0);
41
+ })?.email !== o.user.email && c("userData", { email: o.user.email }, !0);
42
42
  }).catch(() => {
43
- i({
43
+ console.log("initialize error"), r({
44
44
  type: s.Initial,
45
45
  payload: {
46
46
  isAuthenticated: !1,
@@ -49,50 +49,50 @@ function Q(h) {
49
49
  });
50
50
  });
51
51
  };
52
- r || t();
53
- }, [e, y, r, c]);
54
- const D = m(async (t, o, n) => {
55
- await e({
52
+ i || e();
53
+ }, [t, y, i, m]);
54
+ const D = l(async (e, o, n) => {
55
+ await t({
56
56
  endPoint: "auth/login",
57
57
  method: "POST",
58
58
  data: {
59
- email: t,
59
+ email: e,
60
60
  password: o,
61
61
  domain_token: d
62
62
  },
63
63
  responseToCamelCase: !0
64
64
  }).then((v) => {
65
65
  const C = v.data;
66
- n ? l("userData", { email: t, remember: n }) : l("userData", { email: "", remember: n }), i({
66
+ n ? c("userData", { email: e, remember: n }) : c("userData", { email: "", remember: n }), r({
67
67
  type: s.Login,
68
68
  payload: {
69
69
  user: C
70
70
  }
71
71
  }), a((/* @__PURE__ */ new Date()).getTime() + "");
72
72
  });
73
- }, [e, a, d]), u = m(async (t) => {
74
- t && await e({
73
+ }, [t, a, d]), u = l(async (e) => {
74
+ e && await t({
75
75
  endPoint: "auth/logout",
76
76
  method: "POST"
77
- }), i({ type: s.Logout }), a((/* @__PURE__ */ new Date()).getTime() + "");
78
- }, [e, a]), S = m(() => {
77
+ }), r({ type: s.Logout }), a((/* @__PURE__ */ new Date()).getTime() + "");
78
+ }, [t, a]), S = l(() => {
79
79
  u(!1);
80
80
  }, [u]);
81
81
  return p(function() {
82
- r || E(N.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, S);
83
- }, [r]), /* @__PURE__ */ U(
84
- z.Provider,
82
+ i || E(x.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, S);
83
+ }, [i]), /* @__PURE__ */ U(
84
+ k.Provider,
85
85
  {
86
86
  value: {
87
87
  ...T,
88
88
  login: D,
89
89
  logout: u
90
90
  },
91
- children: g
91
+ children: h
92
92
  }
93
93
  );
94
94
  }
95
95
  export {
96
- z as AuthContext,
96
+ k as AuthContext,
97
97
  Q as AuthProvider
98
98
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,11 +1,11 @@
1
- function a(e, t) {
1
+ function u(e, t) {
2
2
  try {
3
3
  const n = new Function(...Object.keys(e), `return \`${t}\``)(...Object.values(e));
4
4
  return String(n).replace(/`/g, "");
5
- } catch (r) {
6
- return console.error(`Error evaluating expression: ${r}`), "";
5
+ } catch {
6
+ return "";
7
7
  }
8
8
  }
9
9
  export {
10
- a as evaluateWithContext
10
+ u as evaluateWithContext
11
11
  };