@cripty2001/utils 0.0.82 → 0.0.84

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.
@@ -76,6 +76,8 @@ class Client {
76
76
  const decoded = (0, msgpack_1.decode)(await res.arrayBuffer());
77
77
  let responseData;
78
78
  switch (res.status) {
79
+ case 404:
80
+ throw new ClientError("Not found");
79
81
  case 401:
80
82
  case 403:
81
83
  if (testedToken === this.authToken.value) {
@@ -108,19 +108,29 @@ function useSynced(def, value, setValue) {
108
108
  (0, react_1.useEffect)(() => {
109
109
  setValueRef.current = setValue;
110
110
  }, [setValue]);
111
- if (value !== undefined && setValue !== undefined) {
112
- (0, react_1.useEffect)(() => {
113
- if ((0, lodash_1.isEqual)(v, value))
114
- return;
115
- setV(value);
116
- }, [value, v, setV]);
117
- (0, react_1.useEffect)(() => {
118
- if ((0, lodash_1.isEqual)(v, value))
119
- return;
120
- setValueRef.current?.(v);
121
- }, [v, value]);
122
- }
123
- return [v, setV];
111
+ // Only sync downstream (external -> local)
112
+ (0, react_1.useEffect)(() => {
113
+ if (value === undefined)
114
+ return;
115
+ if ((0, lodash_1.isEqual)(v, value))
116
+ return;
117
+ console.log('SYNC DOWNSTREAM', value);
118
+ setV(value);
119
+ }, [value]);
120
+ // Return a setter that updates both
121
+ const syncedSetter = (0, react_1.useCallback)((newValue) => {
122
+ setV(prev => {
123
+ const resolved = typeof newValue === 'function'
124
+ ? newValue(prev)
125
+ : newValue;
126
+ // Update external immediately if available
127
+ if (setValueRef.current) {
128
+ setValueRef.current(resolved);
129
+ }
130
+ return resolved;
131
+ });
132
+ }, []);
133
+ return [v, syncedSetter];
124
134
  }
125
135
  /**
126
136
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.82",
3
+ "version": "0.0.84",
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": {