@m4l/core 2.0.20 → 2.0.21

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.
@@ -11,5 +11,5 @@ declare const FlagsContext: import('react').Context<(Omit<Omit<import('zustand')
11
11
  /**
12
12
  * Proveedor del contexto de banderas.
13
13
  */
14
- declare function FlagsProvider({ children }: FlagsProviderProps): import("react").JSX.Element;
14
+ declare function FlagsProvider({ children, storeId, storeDevtoolsEnabled }: FlagsProviderProps): import("react").JSX.Element;
15
15
  export { FlagsProvider, FlagsContext };
@@ -1,14 +1,15 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { createContext as o, useRef as s } from "react";
3
- import { c as a } from "./store.js";
4
- const n = o(null);
5
- function i({ children: e }) {
6
- const r = s();
7
- return r.current || (r.current = a({
8
- flags: []
9
- })), /* @__PURE__ */ t(n.Provider, { value: r.current, children: e });
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { createContext as a, useRef as n } from "react";
3
+ import { c } from "./store.js";
4
+ const f = a(null);
5
+ function m({ children: e, storeId: t, storeDevtoolsEnabled: o }) {
6
+ const r = n();
7
+ return r.current || (r.current = c({
8
+ flags: [],
9
+ storeId: t
10
+ }, o)), /* @__PURE__ */ s(f.Provider, { value: r.current, children: e });
10
11
  }
11
12
  export {
12
- n as F,
13
- i as a
13
+ f as F,
14
+ m as a
14
15
  };
@@ -2,7 +2,7 @@ import { FlagsStateWithActions, FlagsStoreState } from './types';
2
2
  /**
3
3
  * Crea el store de banderas.
4
4
  */
5
- export declare const createFlagsStore: (initialState: FlagsStoreState) => Omit<Omit<import('zustand').StoreApi<FlagsStateWithActions>, "setState"> & {
5
+ export declare const createFlagsStore: (initialState: FlagsStoreState, storeDevtoolsEnabled?: boolean) => Omit<Omit<import('zustand').StoreApi<FlagsStateWithActions>, "setState"> & {
6
6
  setState<A extends string | {
7
7
  type: unknown;
8
8
  }>(partial: FlagsStateWithActions | Partial<FlagsStateWithActions> | ((state: FlagsStateWithActions) => FlagsStateWithActions | Partial<FlagsStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
@@ -1,33 +1,36 @@
1
- import { createStore as t } from "zustand";
1
+ import { createStore as n } from "zustand";
2
2
  import { devtools as f } from "zustand/middleware";
3
- import { immer as m } from "zustand/middleware/immer";
4
- const d = (l) => t(
5
- f(
6
- m((r) => ({
7
- ...l,
3
+ import { immer as c } from "zustand/middleware/immer";
4
+ const d = (e, o) => {
5
+ const { enabled: r = !1 } = o;
6
+ return r && process.env.NODE_ENV === "development" ? f(e, o) : e;
7
+ }, v = (e, o = !1) => n(
8
+ d(
9
+ c((r) => ({
10
+ ...e,
8
11
  flagsActions: {
9
12
  /**
10
13
  * Limpia las banderas.
11
14
  */
12
15
  clearFlags: () => {
13
- r((o) => {
14
- o.flags = [];
16
+ r((s) => {
17
+ s.flags = [];
15
18
  });
16
19
  },
17
20
  /**
18
21
  * Agrega una bandera.
19
22
  */
20
- addFlag: (o) => {
23
+ addFlag: (s) => {
21
24
  r((a) => {
22
- const e = a.flags;
23
- e.findIndex((s) => s === o) < 0 && (a.flags = [...e, o]);
25
+ const t = a.flags;
26
+ t.findIndex((l) => l === s) < 0 && (a.flags = [...t, s]);
24
27
  });
25
28
  }
26
29
  }
27
30
  })),
28
- { name: "FlagsStore" }
31
+ { name: `FlagsStore: ${e.storeId}`, enabled: o }
29
32
  )
30
33
  );
31
34
  export {
32
- d as c
35
+ v as c
33
36
  };
@@ -1,14 +1,41 @@
1
1
  import { ReactNode } from 'react';
2
2
  export interface FlagsProviderProps {
3
+ /**
4
+ * "storeId" Id del store
5
+ */
6
+ storeId?: string;
7
+ /**
8
+ * "storeDevtoolsEnabled" Determina si se debe usar devtools para el store
9
+ */
10
+ storeDevtoolsEnabled?: boolean;
11
+ /**
12
+ * "children" Componentes hijos
13
+ */
3
14
  children: ReactNode;
4
15
  }
5
16
  export type Flag = string;
6
17
  export interface FlagsContextProps {
18
+ /**
19
+ * "flags" Banderas
20
+ */
7
21
  flags: Array<Flag>;
22
+ /**
23
+ * "clearFlags" Limpia las banderas
24
+ */
8
25
  clearFlags: () => void;
26
+ /**
27
+ * "addFlag" Agrega una bandera
28
+ */
9
29
  addFlag: (flag: Flag) => void;
10
30
  }
11
31
  export interface FlagsStoreState {
32
+ /**
33
+ * "storeId" Id del store
34
+ */
35
+ storeId?: string;
36
+ /**
37
+ * "flags" Banderas
38
+ */
12
39
  flags: Array<Flag>;
13
40
  }
14
41
  export interface FlagsStateWithActions extends FlagsStoreState {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "publishConfig": {