@cripty2001/utils 0.0.227 → 0.0.229

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.
@@ -8,6 +8,7 @@ const AUTO_DISMISS_MS = {
8
8
  warning: 6000,
9
9
  error: 8000,
10
10
  };
11
+ const LOGGER_GLOBAL_KEY = "__cripty2001_utils_logger__";
11
12
  class Logger {
12
13
  static instance;
13
14
  lines;
@@ -30,9 +31,15 @@ class Logger {
30
31
  return new Error("Unknown error");
31
32
  }
32
33
  static getInstance() {
34
+ const g = globalThis;
35
+ if (g[LOGGER_GLOBAL_KEY]) {
36
+ Logger.instance = g[LOGGER_GLOBAL_KEY];
37
+ return g[LOGGER_GLOBAL_KEY];
38
+ }
33
39
  if (!Logger.instance) {
34
40
  Logger.instance = new Logger();
35
41
  }
42
+ g[LOGGER_GLOBAL_KEY] = Logger.instance;
36
43
  return Logger.instance;
37
44
  }
38
45
  removeItem(id) {
@@ -2,9 +2,9 @@ import type React from "react";
2
2
  import type { Dispatcher } from "../Dispatcher";
3
3
  export type LoaderProps<T> = {
4
4
  data: Dispatcher<unknown, T>;
5
- children: React.ComponentType<{
5
+ children: (props: {
6
6
  data: T;
7
- }>;
7
+ }) => React.ReactNode;
8
8
  loader?: React.ReactNode;
9
9
  };
10
10
  export default function Loader<T>(props: LoaderProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -22,7 +22,6 @@ function Loader(props) {
22
22
  return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Content, { data: data, children: props.children, loader: props.loader }) }));
23
23
  }
24
24
  function Content({ data, children, loader }) {
25
- const ChildComponent = children;
26
25
  if (data.loading)
27
26
  return loader ?? ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100vh' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
28
27
  animation: 'spin 1s linear infinite',
@@ -34,5 +33,5 @@ function Content({ data, children, loader }) {
34
33
  } }) }));
35
34
  if (!data.ok)
36
35
  return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444' }, children: data.error.message });
37
- return (0, jsx_runtime_1.jsx)(ChildComponent, { data: data.data });
36
+ return children({ data: data.data });
38
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.227",
3
+ "version": "0.0.229",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {