@cripty2001/utils 0.0.148 → 0.0.150

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.
@@ -3,6 +3,8 @@ import type { AppserverData } from "../Appserver/client";
3
3
  import type { Dispatcher } from "../Dispatcher";
4
4
  export type LoaderProps<T extends AppserverData> = {
5
5
  data: Dispatcher<unknown, T>;
6
- children: (data: T) => React.ReactNode;
6
+ children: React.ComponentType<{
7
+ data: T;
8
+ }>;
7
9
  };
8
10
  export default function Loader<T extends AppserverData>(props: LoaderProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -19,9 +19,10 @@ if (typeof document !== 'undefined') {
19
19
  }
20
20
  function Loader(props) {
21
21
  const data = (0, react_whispr_1.useWhisprValue)(props.data.data);
22
- return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Content, { data: data, children: (data) => props.children(data) }) }));
22
+ return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Content, { data: data, children: props.children }) }));
23
23
  }
24
24
  function Content({ data, children }) {
25
+ const ChildComponent = children;
25
26
  if (data.loading)
26
27
  return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100vh' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
27
28
  animation: 'spin 1s linear infinite',
@@ -33,5 +34,5 @@ function Content({ data, children }) {
33
34
  } }) }));
34
35
  if (!data.ok)
35
36
  return (0, jsx_runtime_1.jsx)("div", { style: { color: '#ef4444' }, children: data.error.message });
36
- return children(data.data);
37
+ return (0, jsx_runtime_1.jsx)(ChildComponent, { data: data.data });
37
38
  }
@@ -170,11 +170,11 @@ function useSynced(def, value, setValue) {
170
170
  function useAsync(f, data, debouce = 200) {
171
171
  // Initing reactive input
172
172
  const [input, setInput] = useSafeRef(() => whispr_1.Whispr.create(data ?? (0, _1.getRandomId)()));
173
- if (data !== null) {
174
- (0, react_1.useEffect)(() => {
173
+ (0, react_1.useEffect)(() => {
174
+ if (data !== null) {
175
175
  setInput(data); // Debouncing already handled by dispatcher
176
- }, [data, setInput]);
177
- }
176
+ }
177
+ }, [data, setInput]);
178
178
  // Initing dispatcher
179
179
  const dispatcher = useSafeRef(() => new Dispatcher_1.Dispatcher(input, f, debouce));
180
180
  // Returning dispatcher
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.148",
3
+ "version": "0.0.150",
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": {