frosty 0.0.13 → 0.0.14
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.
- package/dist/_native.js +3 -4
- package/dist/_native.js.map +1 -1
- package/dist/_native.mjs +2 -3
- package/dist/_native.mjs.map +1 -1
- package/dist/dom.js +3 -4
- package/dist/dom.js.map +1 -1
- package/dist/dom.mjs +3 -4
- package/dist/dom.mjs.map +1 -1
- package/dist/index.d.ts +307 -6
- package/dist/index.js +668 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +639 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{common-CEjwzc0j.js → common-FG7T3c2f.js} +2 -2
- package/dist/internals/{common-CEjwzc0j.js.map → common-FG7T3c2f.js.map} +1 -1
- package/dist/internals/{common-CQOkvSXp.mjs → common-KSKXTzR8.mjs} +2 -2
- package/dist/internals/{common-CQOkvSXp.mjs.map → common-KSKXTzR8.mjs.map} +1 -1
- package/dist/internals/{renderer-CTxeL82F.mjs → renderer-GTnF-hYa.mjs} +2 -3
- package/dist/internals/{renderer-CTxeL82F.mjs.map → renderer-GTnF-hYa.mjs.map} +1 -1
- package/dist/internals/{renderer-BL3b1IbL.js → renderer-jjw2FwKT.js} +8 -9
- package/dist/internals/{renderer-BL3b1IbL.js.map → renderer-jjw2FwKT.js.map} +1 -1
- package/dist/internals/{sync-Cq3pCYO3.mjs → sync-B9zfuWYQ.mjs} +60 -60
- package/dist/internals/sync-B9zfuWYQ.mjs.map +1 -0
- package/dist/internals/{sync-CSxmMfGm.js → sync-BIbWmXEq.js} +74 -74
- package/dist/internals/sync-BIbWmXEq.js.map +1 -0
- package/dist/internals/{state-BiYNImPF.mjs → utils-BJL3yvTI.mjs} +61 -48
- package/dist/internals/utils-BJL3yvTI.mjs.map +1 -0
- package/dist/internals/{state-DH_D-jro.js → utils-Bipfwp1R.js} +61 -47
- package/dist/internals/utils-Bipfwp1R.js.map +1 -0
- package/dist/jsx-runtime.js +29 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx-runtime.mjs +29 -2
- package/dist/jsx-runtime.mjs.map +1 -1
- package/dist/server-dom.js +3 -4
- package/dist/server-dom.js.map +1 -1
- package/dist/server-dom.mjs +3 -4
- package/dist/server-dom.mjs.map +1 -1
- package/dist/web.d.ts +2 -2
- package/dist/web.js +30 -15
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +26 -11
- package/dist/web.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/hooks.d.ts +0 -301
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -456
- package/dist/hooks.js.map +0 -1
- package/dist/hooks.mjs +0 -447
- package/dist/hooks.mjs.map +0 -1
- package/dist/internals/fragment-B0rB4qEp.js +0 -32
- package/dist/internals/fragment-B0rB4qEp.js.map +0 -1
- package/dist/internals/fragment-DPs1AriN.mjs +0 -30
- package/dist/internals/fragment-DPs1AriN.mjs.map +0 -1
- package/dist/internals/state-0jEjYdYV.js +0 -203
- package/dist/internals/state-0jEjYdYV.js.map +0 -1
- package/dist/internals/state-BiYNImPF.mjs.map +0 -1
- package/dist/internals/state-DH_D-jro.js.map +0 -1
- package/dist/internals/state-zydBhS8M.mjs +0 -197
- package/dist/internals/state-zydBhS8M.mjs.map +0 -1
- package/dist/internals/sync-CSxmMfGm.js.map +0 -1
- package/dist/internals/sync-Cq3pCYO3.mjs.map +0 -1
- package/dist/internals/utils-DAEKakog.mjs +0 -42
- package/dist/internals/utils-DAEKakog.mjs.map +0 -1
- package/dist/internals/utils-Dc66ARNS.js +0 -44
- package/dist/internals/utils-Dc66ARNS.js.map +0 -1
package/dist/hooks.mjs
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import { d as useState, b as useRef, u as useAsyncDebounce } from './internals/state-zydBhS8M.mjs';
|
|
3
|
-
import { u as useCallback, b as useMemo, a as useEffect, c as useSyncExternalStore } from './internals/sync-Cq3pCYO3.mjs';
|
|
4
|
-
import { c as createContext, u as useContext } from './internals/state-BiYNImPF.mjs';
|
|
5
|
-
import { jsx } from './jsx-runtime.mjs';
|
|
6
|
-
import './internals/component-tyF62qKh.mjs';
|
|
7
|
-
import 'myers.js';
|
|
8
|
-
import './internals/runtime-BN27rc51.mjs';
|
|
9
|
-
import './internals/fragment-DPs1AriN.mjs';
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
// animate.ts
|
|
13
|
-
//
|
|
14
|
-
// The MIT License
|
|
15
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
16
|
-
//
|
|
17
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
19
|
-
// in the Software without restriction, including without limitation the rights
|
|
20
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
22
|
-
// furnished to do so, subject to the following conditions:
|
|
23
|
-
//
|
|
24
|
-
// The above copyright notice and this permission notice shall be included in
|
|
25
|
-
// all copies or substantial portions of the Software.
|
|
26
|
-
//
|
|
27
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
33
|
-
// THE SOFTWARE.
|
|
34
|
-
//
|
|
35
|
-
const interpolate = (value) => ({ inputRange, outputRange }) => {
|
|
36
|
-
const [inputMin, inputMax] = inputRange;
|
|
37
|
-
const [outputMin, outputMax] = outputRange;
|
|
38
|
-
// Safeguard against division by zero
|
|
39
|
-
if (inputMax === inputMin) {
|
|
40
|
-
throw new Error('Input range must have distinct values.');
|
|
41
|
-
}
|
|
42
|
-
const t = (value - inputMin) / (inputMax - inputMin);
|
|
43
|
-
const interpolatedValue = outputMin + t * (outputMax - outputMin);
|
|
44
|
-
return {
|
|
45
|
-
value: interpolatedValue,
|
|
46
|
-
interpolate: interpolate(interpolatedValue),
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* A hook to manage animations with support for starting, stopping, and interpolating values.
|
|
51
|
-
*
|
|
52
|
-
* @param initialValue - The initial value of the animation.
|
|
53
|
-
*
|
|
54
|
-
* @returns An object containing:
|
|
55
|
-
* - `value`: The current animated value.
|
|
56
|
-
* - `stop`: A function to stop the animation.
|
|
57
|
-
* - `start`: A function to start the animation with specified options.
|
|
58
|
-
* - `interpolate`: A function to interpolate the current value based on input and output ranges.
|
|
59
|
-
*/
|
|
60
|
-
const useAnimate = (initialValue) => {
|
|
61
|
-
const [value, setValue] = useState(initialValue);
|
|
62
|
-
const ref = useRef();
|
|
63
|
-
const _stop = () => {
|
|
64
|
-
const { interval, callback } = ref.current ?? {};
|
|
65
|
-
ref.current = undefined;
|
|
66
|
-
if (interval)
|
|
67
|
-
clearInterval(interval);
|
|
68
|
-
return callback;
|
|
69
|
-
};
|
|
70
|
-
const stop = useCallback(() => {
|
|
71
|
-
const callback = _stop();
|
|
72
|
-
if (_.isFunction(callback))
|
|
73
|
-
callback({ value, finished: false });
|
|
74
|
-
});
|
|
75
|
-
const start = useCallback(({ fromValue = value, toValue, duration, easing = (x) => x, delay = 0, onCompleted, }) => {
|
|
76
|
-
_stop();
|
|
77
|
-
const start = Date.now();
|
|
78
|
-
if (duration > 0) {
|
|
79
|
-
ref.current = {
|
|
80
|
-
interval: setInterval(() => {
|
|
81
|
-
const t = (Date.now() - start) / duration - delay;
|
|
82
|
-
if (t >= 1) {
|
|
83
|
-
clearInterval(ref.current?.interval);
|
|
84
|
-
ref.current = undefined;
|
|
85
|
-
setValue(toValue);
|
|
86
|
-
if (_.isFunction(onCompleted))
|
|
87
|
-
onCompleted({ value: toValue, finished: true });
|
|
88
|
-
}
|
|
89
|
-
else if (t >= 0) {
|
|
90
|
-
setValue((toValue - fromValue) * easing(_.clamp(t, 0, 1)) + fromValue);
|
|
91
|
-
}
|
|
92
|
-
}, 16),
|
|
93
|
-
callback: onCompleted,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
return {
|
|
98
|
-
value,
|
|
99
|
-
stop,
|
|
100
|
-
start,
|
|
101
|
-
interpolate: interpolate(value),
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const Context = createContext({
|
|
106
|
-
errors: [],
|
|
107
|
-
setErrors: () => { },
|
|
108
|
-
});
|
|
109
|
-
/**
|
|
110
|
-
* A context provider component for managing asynchronous resource errors.
|
|
111
|
-
*
|
|
112
|
-
* This component provides a shared context for tracking errors encountered during
|
|
113
|
-
* asynchronous operations. It allows child components to access and manage these errors
|
|
114
|
-
* using the `useResourceErrors` hook.
|
|
115
|
-
*
|
|
116
|
-
* ### Usage:
|
|
117
|
-
* Wrap your application or specific parts of it with this component to enable error tracking:
|
|
118
|
-
*
|
|
119
|
-
* ```tsx
|
|
120
|
-
* <ResourceErrors>
|
|
121
|
-
* <YourComponent />
|
|
122
|
-
* </ResourceErrors>
|
|
123
|
-
* ```
|
|
124
|
-
*
|
|
125
|
-
* @param children - The child components that will have access to the error context.
|
|
126
|
-
*
|
|
127
|
-
* @returns A context provider that wraps the provided children.
|
|
128
|
-
*/
|
|
129
|
-
const ResourceErrors = ({ children }) => {
|
|
130
|
-
const [errors, setErrors] = useState([]);
|
|
131
|
-
const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);
|
|
132
|
-
return (jsx(Context, { value: value, children: children }));
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* A hook to access the list of asynchronous resource errors.
|
|
136
|
-
*
|
|
137
|
-
* This hook allows components to retrieve the current list of errors being tracked
|
|
138
|
-
* in the `ResourceErrors` context. It must be used within a component that is
|
|
139
|
-
* a descendant of the `ResourceErrors` provider.
|
|
140
|
-
*
|
|
141
|
-
* ### Usage:
|
|
142
|
-
* ```tsx
|
|
143
|
-
* const errors = useResourceErrors();
|
|
144
|
-
*
|
|
145
|
-
* errors.forEach(({ token, error, refresh }) => {
|
|
146
|
-
* console.error(`Error [${token}]:`, error);
|
|
147
|
-
* // Optionally call refresh() to retry the operation
|
|
148
|
-
* });
|
|
149
|
-
* ```
|
|
150
|
-
*
|
|
151
|
-
* @returns The list of errors currently being tracked in the context. Each error includes:
|
|
152
|
-
* - `token`: A unique identifier for the error.
|
|
153
|
-
* - `error`: The error object or message.
|
|
154
|
-
* - `refresh`: A function to retry the operation that caused the error.
|
|
155
|
-
*/
|
|
156
|
-
const useResourceErrors = () => useContext(Context).errors;
|
|
157
|
-
|
|
158
|
-
//
|
|
159
|
-
// index.ts
|
|
160
|
-
//
|
|
161
|
-
// The MIT License
|
|
162
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
163
|
-
//
|
|
164
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
165
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
166
|
-
// in the Software without restriction, including without limitation the rights
|
|
167
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
168
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
169
|
-
// furnished to do so, subject to the following conditions:
|
|
170
|
-
//
|
|
171
|
-
// The above copyright notice and this permission notice shall be included in
|
|
172
|
-
// all copies or substantial portions of the Software.
|
|
173
|
-
//
|
|
174
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
175
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
176
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
177
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
178
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
179
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
180
|
-
// THE SOFTWARE.
|
|
181
|
-
//
|
|
182
|
-
/**
|
|
183
|
-
* A hook to manage asynchronous resources with support for debouncing, error handling, and state management.
|
|
184
|
-
*
|
|
185
|
-
* @template T - The type of the resource being fetched.
|
|
186
|
-
* @template P - The type of the parameters passed to the fetch function.
|
|
187
|
-
*
|
|
188
|
-
* @param config - The fetch function or a configuration object containing the fetch function and optional debounce settings.
|
|
189
|
-
* @param deps - An optional dependency array to control when the resource is refreshed.
|
|
190
|
-
*
|
|
191
|
-
* @returns An object containing:
|
|
192
|
-
* - `count`: The number of times the resource has been fetched.
|
|
193
|
-
* - `refreshing`: A boolean indicating if the resource is currently being refreshed.
|
|
194
|
-
* - `loading`: A boolean indicating if the resource is currently being loaded.
|
|
195
|
-
* - `resource`: The fetched resource.
|
|
196
|
-
* - `error`: Any error encountered during the fetch.
|
|
197
|
-
* - `cancel`: A function to cancel the current fetch operation.
|
|
198
|
-
* - `refresh`: A function to refresh the resource.
|
|
199
|
-
* - `next`: A function to fetch the next set of data (for paginated resources).
|
|
200
|
-
* - `setResource`: A function to manually update the resource state.
|
|
201
|
-
*/
|
|
202
|
-
const useResource = (config, deps) => {
|
|
203
|
-
const fetch = _.isFunction(config) ? config : config.fetch;
|
|
204
|
-
const debounce = _.isFunction(config) ? {} : config.debounce;
|
|
205
|
-
const [state, setState] = useState({});
|
|
206
|
-
const _dispatch = (token, next) => setState(state => state.token === token ? ({
|
|
207
|
-
...(_.isFunction(next) ? next(state.flag ? state : _.omit(state, 'resource', 'error')) : next),
|
|
208
|
-
count: state.flag ? state.count : (state.count ?? 0) + 1,
|
|
209
|
-
flag: true,
|
|
210
|
-
}) : state);
|
|
211
|
-
const _fetch = useAsyncDebounce(async (type, abort, reset, param, prevState) => {
|
|
212
|
-
const token = _.uniqueId();
|
|
213
|
-
setState(state => ({ ...state, type, token, abort, flag: !reset }));
|
|
214
|
-
try {
|
|
215
|
-
const resource = await fetch({
|
|
216
|
-
param,
|
|
217
|
-
prevState,
|
|
218
|
-
abortSignal: abort.signal,
|
|
219
|
-
dispatch: (next) => {
|
|
220
|
-
_dispatch(token, state => ({
|
|
221
|
-
...state,
|
|
222
|
-
resource: _.isFunction(next) ? next(state.resource) : next,
|
|
223
|
-
}));
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
_dispatch(token, state => ({ resource: resource ?? state.resource }));
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
_dispatch(token, state => ({
|
|
230
|
-
resource: state.resource,
|
|
231
|
-
error,
|
|
232
|
-
}));
|
|
233
|
-
}
|
|
234
|
-
}, debounce ?? {});
|
|
235
|
-
useEffect(() => {
|
|
236
|
-
const controller = new AbortController();
|
|
237
|
-
void _fetch('refresh', controller, true);
|
|
238
|
-
return () => controller.abort();
|
|
239
|
-
}, deps ?? []);
|
|
240
|
-
const _cancelRef = useCallback((reason) => { state.abort?.abort(reason); });
|
|
241
|
-
const _refreshRef = useCallback((param) => _fetch('refresh', new AbortController(), true, param));
|
|
242
|
-
const _nextRef = useCallback((param) => _fetch('next', new AbortController(), false, param, state.resource));
|
|
243
|
-
const _setResRef = useCallback((resource) => setState(state => ({
|
|
244
|
-
..._.omit(state, 'resource', 'error'),
|
|
245
|
-
resource: _.isFunction(resource) ? resource(state.resource) : resource,
|
|
246
|
-
})));
|
|
247
|
-
const { setErrors } = useContext(Context);
|
|
248
|
-
useEffect(() => {
|
|
249
|
-
const { type, abort, token = _.uniqueId(), error } = state;
|
|
250
|
-
if (!error)
|
|
251
|
-
return;
|
|
252
|
-
setErrors(v => [...v, {
|
|
253
|
-
token,
|
|
254
|
-
error,
|
|
255
|
-
refresh: _refreshRef,
|
|
256
|
-
refreshing: !_.isNil(abort) && type === 'refresh',
|
|
257
|
-
loading: !_.isNil(abort),
|
|
258
|
-
}]);
|
|
259
|
-
return () => setErrors(v => _.filter(v, x => x.token !== token));
|
|
260
|
-
}, [state]);
|
|
261
|
-
return {
|
|
262
|
-
count: state.count ?? 0,
|
|
263
|
-
refreshing: !_.isNil(state.abort) && state.type === 'refresh',
|
|
264
|
-
loading: !_.isNil(state.abort),
|
|
265
|
-
resource: state.resource,
|
|
266
|
-
error: state.error,
|
|
267
|
-
cancel: _cancelRef,
|
|
268
|
-
refresh: _refreshRef,
|
|
269
|
-
next: _nextRef,
|
|
270
|
-
setResource: _setResRef,
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* A hook to manage asynchronous iterable resources, such as streams or paginated data.
|
|
275
|
-
*
|
|
276
|
-
* @template T - The type of the resource items being fetched.
|
|
277
|
-
* @template P - The type of the parameters passed to the fetch function.
|
|
278
|
-
*
|
|
279
|
-
* @param config - The fetch function or a configuration object containing the fetch function and optional debounce settings.
|
|
280
|
-
* @param deps - An optional dependency array to control when the resource is refreshed.
|
|
281
|
-
*
|
|
282
|
-
* @returns An object containing the same properties as `useResource`, but optimized for iterable resources.
|
|
283
|
-
*/
|
|
284
|
-
const useIterableResource = (config, deps) => {
|
|
285
|
-
const fetch = _.isFunction(config) ? config : config.fetch;
|
|
286
|
-
const debounce = _.isFunction(config) ? {} : config.debounce;
|
|
287
|
-
const { next, ...result } = useResource({
|
|
288
|
-
fetch: async ({ dispatch, abortSignal, param }) => {
|
|
289
|
-
const resource = await fetch({ abortSignal, param });
|
|
290
|
-
for await (const item of resource) {
|
|
291
|
-
dispatch(items => items ? [...items, item] : [item]);
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
debounce,
|
|
295
|
-
}, deps);
|
|
296
|
-
return result;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
//
|
|
300
|
-
// interval.ts
|
|
301
|
-
//
|
|
302
|
-
// The MIT License
|
|
303
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
304
|
-
//
|
|
305
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
306
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
307
|
-
// in the Software without restriction, including without limitation the rights
|
|
308
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
309
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
310
|
-
// furnished to do so, subject to the following conditions:
|
|
311
|
-
//
|
|
312
|
-
// The above copyright notice and this permission notice shall be included in
|
|
313
|
-
// all copies or substantial portions of the Software.
|
|
314
|
-
//
|
|
315
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
316
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
317
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
318
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
319
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
320
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
321
|
-
// THE SOFTWARE.
|
|
322
|
-
//
|
|
323
|
-
/**
|
|
324
|
-
* A hook that repeatedly calls the provided callback function at the specified interval.
|
|
325
|
-
*
|
|
326
|
-
* @param callback - The function to be executed at each interval.
|
|
327
|
-
* @param ms - The delay in milliseconds between each call to the callback. If not provided, the interval will not be set.
|
|
328
|
-
* @returns void
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* useInterval(() => {
|
|
332
|
-
* // Code to run every 1000ms
|
|
333
|
-
* }, 1000);
|
|
334
|
-
*/
|
|
335
|
-
const useInterval = (callback, ms) => useEffect(() => {
|
|
336
|
-
const interval = setInterval(() => {
|
|
337
|
-
callback();
|
|
338
|
-
}, ms);
|
|
339
|
-
return () => clearInterval(interval);
|
|
340
|
-
}, []);
|
|
341
|
-
|
|
342
|
-
//
|
|
343
|
-
// store.ts
|
|
344
|
-
//
|
|
345
|
-
// The MIT License
|
|
346
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
347
|
-
//
|
|
348
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
349
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
350
|
-
// in the Software without restriction, including without limitation the rights
|
|
351
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
352
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
353
|
-
// furnished to do so, subject to the following conditions:
|
|
354
|
-
//
|
|
355
|
-
// The above copyright notice and this permission notice shall be included in
|
|
356
|
-
// all copies or substantial portions of the Software.
|
|
357
|
-
//
|
|
358
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
359
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
360
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
361
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
362
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
363
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
364
|
-
// THE SOFTWARE.
|
|
365
|
-
//
|
|
366
|
-
/**
|
|
367
|
-
* A class representing a store that holds a value and allows for subscription
|
|
368
|
-
* to changes in that value.
|
|
369
|
-
*
|
|
370
|
-
* @template T - The type of the value stored in the store.
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* const store = createStore(0);
|
|
374
|
-
* store.setValue(1);
|
|
375
|
-
* store.subscribe((oldVal, newVal) => {
|
|
376
|
-
* console.log(`Value changed from ${oldVal} to ${newVal}`);
|
|
377
|
-
* });
|
|
378
|
-
*/
|
|
379
|
-
class Store {
|
|
380
|
-
#listeners = new Set();
|
|
381
|
-
#value;
|
|
382
|
-
/** @internal */
|
|
383
|
-
constructor(initialValue) {
|
|
384
|
-
this.#value = initialValue;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Gets the current value of the store.
|
|
388
|
-
*
|
|
389
|
-
* @returns The current value of the store.
|
|
390
|
-
*/
|
|
391
|
-
get value() {
|
|
392
|
-
return this.#value;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Sets the value of the store and notifies all subscribers.
|
|
396
|
-
*
|
|
397
|
-
* @param dispatch - The new value or a function that returns the new value.
|
|
398
|
-
*/
|
|
399
|
-
setValue(dispatch) {
|
|
400
|
-
const oldVal = this.#value;
|
|
401
|
-
dispatch = _.isFunction(dispatch) ? dispatch(this.#value) : this.#value;
|
|
402
|
-
this.#listeners.forEach(listener => void listener(oldVal, this.#value));
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Subscribes to changes in the store's value.
|
|
406
|
-
*
|
|
407
|
-
* @param callback - The function to call when the value changes.
|
|
408
|
-
* @returns A function to unsubscribe from the store.
|
|
409
|
-
*/
|
|
410
|
-
subscribe(callback) {
|
|
411
|
-
this.#listeners.add(callback);
|
|
412
|
-
return () => { this.#listeners.delete(callback); };
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Creates a new store with the given initial value.
|
|
417
|
-
*
|
|
418
|
-
* @param initialValue - The initial value to be stored.
|
|
419
|
-
* @returns {Store<T>} A new store instance.
|
|
420
|
-
*
|
|
421
|
-
* @example
|
|
422
|
-
* const counterStore = createStore(0);
|
|
423
|
-
*/
|
|
424
|
-
const createStore = (initialValue) => new Store(initialValue);
|
|
425
|
-
/**
|
|
426
|
-
* A hook to subscribe to a store and select a slice of its state.
|
|
427
|
-
* The component will re-render when the selected state changes.
|
|
428
|
-
*
|
|
429
|
-
* @param store - The store instance to subscribe to.
|
|
430
|
-
* @param selector - A function to select a part of the store's state. Defaults to the entire state.
|
|
431
|
-
* @param equal - A function to compare selected values for equality. Defaults to deep equality.
|
|
432
|
-
* @returns The selected slice of the store's state.
|
|
433
|
-
*
|
|
434
|
-
* @example
|
|
435
|
-
* const count = useStore(counterStore);
|
|
436
|
-
*
|
|
437
|
-
* @example
|
|
438
|
-
* // Using a selector
|
|
439
|
-
* const userName = useStore(userStore, user => user.name);
|
|
440
|
-
*/
|
|
441
|
-
const useStore = (store, selector = v => v, equal = _.isEqual) => useSyncExternalStore((onStoreChange) => store.subscribe((oldVal, newVal) => {
|
|
442
|
-
if (equal(selector(oldVal), selector(newVal)))
|
|
443
|
-
onStoreChange();
|
|
444
|
-
}), () => selector(store.value));
|
|
445
|
-
|
|
446
|
-
export { ResourceErrors, createStore, useAnimate, useInterval, useIterableResource, useResource, useResourceErrors, useStore };
|
|
447
|
-
//# sourceMappingURL=hooks.mjs.map
|
package/dist/hooks.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.mjs","sources":["../../src/hooks/animate.ts","../../src/hooks/resource/error.tsx","../../src/hooks/resource/index.ts","../../src/hooks/interval.ts","../../src/hooks/store.ts"],"sourcesContent":["//\n// animate.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { useRef } from '../core/hooks/ref';\nimport { useState } from '../core/hooks/state';\nimport { useCallback } from '../core/hooks/callback';\n\n/**\n * Options for configuring the animation.\n * \n * @property fromValue - The starting value of the animation. Defaults to the current value.\n * @property toValue - The target value of the animation.\n * @property duration - The duration of the animation in milliseconds.\n * @property easing - An optional easing function to control the animation's progress. Defaults to a linear function.\n * @property delay - An optional delay (in milliseconds) before the animation starts. Defaults to `0`.\n * @property onCompleted - An optional callback function invoked when the animation completes or is stopped.\n */\ntype AnimateOptions = {\n fromValue?: number;\n toValue: number;\n duration: number;\n easing?: (value: number) => number;\n delay?: number;\n onCompleted?: (result: {\n value: number;\n finished: boolean;\n }) => void;\n};\n\n/**\n * Options for interpolating a value.\n * \n * @property inputRange - A tuple specifying the input range for interpolation.\n * @property outputRange - A tuple specifying the output range for interpolation.\n */\ntype InterpolateOptions = {\n inputRange: [number, number];\n outputRange: [number, number];\n};\n\n/**\n * Represents an interpolated value and provides a method to further interpolate it.\n * \n * @property value - The interpolated value.\n * @property interpolate - A function to interpolate the current value based on new input and output ranges.\n */\ntype AnimatedInterpolation = {\n value: number;\n interpolate: ({ inputRange, outputRange }: InterpolateOptions) => AnimatedInterpolation;\n};\n\nconst interpolate = (value: number) => ({ inputRange, outputRange }: InterpolateOptions): AnimatedInterpolation => {\n const [inputMin, inputMax] = inputRange;\n const [outputMin, outputMax] = outputRange;\n\n // Safeguard against division by zero\n if (inputMax === inputMin) {\n throw new Error('Input range must have distinct values.');\n }\n\n const t = (value - inputMin) / (inputMax - inputMin);\n const interpolatedValue = outputMin + t * (outputMax - outputMin);\n return {\n value: interpolatedValue,\n interpolate: interpolate(interpolatedValue),\n };\n};\n\n/**\n * A hook to manage animations with support for starting, stopping, and interpolating values.\n * \n * @param initialValue - The initial value of the animation.\n * \n * @returns An object containing:\n * - `value`: The current animated value.\n * - `stop`: A function to stop the animation.\n * - `start`: A function to start the animation with specified options.\n * - `interpolate`: A function to interpolate the current value based on input and output ranges.\n */\nexport const useAnimate = (initialValue: number) => {\n const [value, setValue] = useState(initialValue);\n const ref = useRef<{\n interval: ReturnType<typeof setInterval>;\n callback?: AnimateOptions['onCompleted'];\n }>();\n const _stop = () => {\n const { interval, callback } = ref.current ?? {};\n ref.current = undefined;\n if (interval) clearInterval(interval);\n return callback;\n };\n const stop = useCallback(() => {\n const callback = _stop();\n if (_.isFunction(callback)) callback({ value, finished: false });\n });\n const start = useCallback(({\n fromValue = value,\n toValue,\n duration,\n easing = (x) => x,\n delay = 0,\n onCompleted,\n }: AnimateOptions) => {\n _stop();\n const start = Date.now();\n if (duration > 0) {\n ref.current = {\n interval: setInterval(() => {\n const t = (Date.now() - start) / duration - delay;\n if (t >= 1) {\n clearInterval(ref.current?.interval);\n ref.current = undefined;\n setValue(toValue);\n if (_.isFunction(onCompleted)) onCompleted({ value: toValue, finished: true });\n } else if (t >= 0) {\n setValue((toValue - fromValue) * easing(_.clamp(t, 0, 1)) + fromValue);\n }\n }, 16),\n callback: onCompleted,\n }\n }\n });\n return {\n value,\n stop,\n start,\n interpolate: interpolate(value),\n };\n}","//\n// error.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Awaitable } from '@o2ter/utils-js';\nimport { ComponentType, PropsWithChildren, SetStateAction } from '../../core/types/common';\nimport { createContext } from '../../core/types/context';\nimport { useContext } from '../../core/hooks/context';\nimport { useState } from '../../core/hooks/state';\nimport { useMemo } from '../../core/hooks/memo';\n\ntype Errors = {\n token: string;\n error: any;\n refresh: () => Awaitable<void>;\n refreshing: boolean;\n loading: boolean;\n}[];\n\nexport const Context = createContext<{\n errors: Errors;\n setErrors: (values: SetStateAction<Errors>) => void;\n}>({\n errors: [],\n setErrors: () => { },\n});\n\n/**\n * A context provider component for managing asynchronous resource errors.\n * \n * This component provides a shared context for tracking errors encountered during\n * asynchronous operations. It allows child components to access and manage these errors\n * using the `useResourceErrors` hook.\n * \n * ### Usage:\n * Wrap your application or specific parts of it with this component to enable error tracking:\n * \n * ```tsx\n * <ResourceErrors>\n * <YourComponent />\n * </ResourceErrors>\n * ```\n * \n * @param children - The child components that will have access to the error context.\n * \n * @returns A context provider that wraps the provided children.\n */\nexport const ResourceErrors: ComponentType<PropsWithChildren<{}>> = ({\n children\n}) => {\n const [errors, setErrors] = useState<Errors>([]);\n const value = useMemo(() => ({ errors, setErrors }), [errors, setErrors]);\n return (\n <Context value={value}>{children}</Context>\n );\n}\n\n/**\n * A hook to access the list of asynchronous resource errors.\n * \n * This hook allows components to retrieve the current list of errors being tracked\n * in the `ResourceErrors` context. It must be used within a component that is\n * a descendant of the `ResourceErrors` provider.\n * \n * ### Usage:\n * ```tsx\n * const errors = useResourceErrors();\n * \n * errors.forEach(({ token, error, refresh }) => {\n * console.error(`Error [${token}]:`, error);\n * // Optionally call refresh() to retry the operation\n * });\n * ```\n * \n * @returns The list of errors currently being tracked in the context. Each error includes:\n * - `token`: A unique identifier for the error.\n * - `error`: The error object or message.\n * - `refresh`: A function to retry the operation that caused the error.\n */\nexport const useResourceErrors = () => useContext(Context).errors;\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { SetStateAction } from '../../core/types/common';\nimport { Config, Fetch, FetchWithIterable } from './types';\nimport { useState } from '../../core/hooks/state';\nimport { useEffect } from '../../core/hooks/effect';\nimport { useContext } from '../../core/hooks/context';\nimport { useCallback } from '../../core/hooks/callback';\nimport { useAsyncDebounce } from '../../core/hooks/debounce';\nimport { Context as ErrorContext } from './error';\nexport { ResourceErrors, useResourceErrors } from './error';\n\n/**\n * A hook to manage asynchronous resources with support for debouncing, error handling, and state management.\n * \n * @template T - The type of the resource being fetched.\n * @template P - The type of the parameters passed to the fetch function.\n * \n * @param config - The fetch function or a configuration object containing the fetch function and optional debounce settings.\n * @param deps - An optional dependency array to control when the resource is refreshed.\n * \n * @returns An object containing:\n * - `count`: The number of times the resource has been fetched.\n * - `refreshing`: A boolean indicating if the resource is currently being refreshed.\n * - `loading`: A boolean indicating if the resource is currently being loaded.\n * - `resource`: The fetched resource.\n * - `error`: Any error encountered during the fetch.\n * - `cancel`: A function to cancel the current fetch operation.\n * - `refresh`: A function to refresh the resource.\n * - `next`: A function to fetch the next set of data (for paginated resources).\n * - `setResource`: A function to manually update the resource state.\n */\nexport const useResource = <T, P = any>(\n config: Fetch<T, P> | Config<Fetch<T, P>>,\n deps?: any,\n) => {\n\n const fetch = _.isFunction(config) ? config : config.fetch;\n const debounce = _.isFunction(config) ? {} : config.debounce;\n\n const [state, setState] = useState<{\n type?: 'refresh' | 'next';\n count?: number;\n flag?: boolean;\n resource?: T;\n error?: any;\n token?: string;\n abort?: AbortController;\n }>({});\n\n const _dispatch = (\n token: string,\n next: SetStateAction<typeof state>,\n ) => setState(state => state.token === token ? ({\n ...(_.isFunction(next) ? next(state.flag ? state : _.omit(state, 'resource', 'error')) : next),\n count: state.flag ? state.count : (state.count ?? 0) + 1,\n flag: true,\n }) : state);\n\n const _fetch = useAsyncDebounce(async (\n type: 'refresh' | 'next',\n abort: AbortController,\n reset: boolean,\n param?: P,\n prevState?: T,\n ) => {\n\n const token = _.uniqueId();\n setState(state => ({ ...state, type, token, abort, flag: !reset }));\n\n try {\n\n const resource = await fetch({\n param,\n prevState,\n abortSignal: abort.signal,\n dispatch: (next) => {\n _dispatch(token, state => ({\n ...state,\n resource: _.isFunction(next) ? next(state.resource) : next,\n }));\n },\n });\n\n _dispatch(token, state => ({ resource: resource ?? state.resource }));\n\n } catch (error) {\n\n _dispatch(token, state => ({\n resource: state.resource,\n error,\n }));\n }\n\n }, debounce ?? {});\n\n useEffect(() => {\n const controller = new AbortController();\n void _fetch('refresh', controller, true);\n return () => controller.abort();\n }, deps ?? []);\n\n const _cancelRef = useCallback((reason?: any) => { state.abort?.abort(reason) });\n const _refreshRef = useCallback((param?: P) => _fetch('refresh', new AbortController(), true, param));\n const _nextRef = useCallback((param?: P) => _fetch('next', new AbortController(), false, param, state.resource));\n const _setResRef = useCallback((resource: T | ((prevState?: T) => T)) => setState(state => ({\n ..._.omit(state, 'resource', 'error'),\n resource: _.isFunction(resource) ? resource(state.resource) : resource,\n })));\n\n const { setErrors } = useContext(ErrorContext);\n useEffect(() => {\n const { type, abort, token = _.uniqueId(), error } = state;\n if (!error) return;\n setErrors(v => [...v, {\n token,\n error,\n refresh: _refreshRef,\n refreshing: !_.isNil(abort) && type === 'refresh',\n loading: !_.isNil(abort),\n }]);\n return () => setErrors(v => _.filter(v, x => x.token !== token));\n }, [state]);\n\n return {\n count: state.count ?? 0,\n refreshing: !_.isNil(state.abort) && state.type === 'refresh',\n loading: !_.isNil(state.abort),\n resource: state.resource,\n error: state.error,\n cancel: _cancelRef,\n refresh: _refreshRef,\n next: _nextRef,\n setResource: _setResRef,\n };\n}\n\n/**\n * A hook to manage asynchronous iterable resources, such as streams or paginated data.\n * \n * @template T - The type of the resource items being fetched.\n * @template P - The type of the parameters passed to the fetch function.\n * \n * @param config - The fetch function or a configuration object containing the fetch function and optional debounce settings.\n * @param deps - An optional dependency array to control when the resource is refreshed.\n * \n * @returns An object containing the same properties as `useResource`, but optimized for iterable resources.\n */\nexport const useIterableResource = <T, P = any>(\n config: FetchWithIterable<T, P> | Config<FetchWithIterable<T, P>>,\n deps?: any,\n) => {\n const fetch = _.isFunction(config) ? config : config.fetch;\n const debounce = _.isFunction(config) ? {} : config.debounce;\n const { next, ...result } = useResource<T[]>({\n fetch: async ({ dispatch, abortSignal, param }) => {\n const resource = await fetch({ abortSignal, param });\n for await (const item of resource) {\n dispatch(items => items ? [...items, item] : [item]);\n }\n },\n debounce,\n }, deps);\n return result;\n}\n","//\n// interval.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { useEffect } from '../core/hooks/effect';\n\n/**\n * A hook that repeatedly calls the provided callback function at the specified interval.\n * \n * @param callback - The function to be executed at each interval.\n * @param ms - The delay in milliseconds between each call to the callback. If not provided, the interval will not be set.\n * @returns void\n * \n * @example\n * useInterval(() => {\n * // Code to run every 1000ms\n * }, 1000);\n */\nexport const useInterval = (\n callback: () => void,\n ms?: number,\n) => useEffect(() => {\n const interval = setInterval(() => {\n callback();\n }, ms);\n return () => clearInterval(interval);\n}, []);\n","//\n// store.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { SetStateAction } from '../core/types/common';\nimport { useSyncExternalStore } from '../core/hooks/sync';\n\n/**\n * A class representing a store that holds a value and allows for subscription\n * to changes in that value.\n *\n * @template T - The type of the value stored in the store.\n *\n * @example\n * const store = createStore(0);\n * store.setValue(1);\n * store.subscribe((oldVal, newVal) => {\n * console.log(`Value changed from ${oldVal} to ${newVal}`);\n * });\n */\nclass Store<T> {\n\n #listeners = new Set<(oldVal: T, newVal: T) => void>();\n #value: T;\n\n /** @internal */\n constructor(initialValue: T) {\n this.#value = initialValue;\n }\n\n /**\n * Gets the current value of the store.\n * \n * @returns The current value of the store.\n */\n get value() {\n return this.#value;\n }\n\n /**\n * Sets the value of the store and notifies all subscribers.\n * \n * @param dispatch - The new value or a function that returns the new value.\n */\n setValue(dispatch: SetStateAction<T>) {\n const oldVal = this.#value;\n dispatch = _.isFunction(dispatch) ? dispatch(this.#value) : this.#value;\n this.#listeners.forEach(listener => void listener(oldVal, this.#value));\n }\n\n /**\n * Subscribes to changes in the store's value.\n * \n * @param callback - The function to call when the value changes.\n * @returns A function to unsubscribe from the store.\n */\n subscribe(callback: (oldVal: T, newVal: T) => void) {\n this.#listeners.add(callback);\n return () => { this.#listeners.delete(callback); };\n }\n}\n\n/**\n * Creates a new store with the given initial value.\n * \n * @param initialValue - The initial value to be stored.\n * @returns {Store<T>} A new store instance.\n *\n * @example\n * const counterStore = createStore(0);\n */\nexport const createStore = <T extends unknown = any>(initialValue: T) => new Store(initialValue);\n\n/**\n * A hook to subscribe to a store and select a slice of its state.\n * The component will re-render when the selected state changes.\n * \n * @param store - The store instance to subscribe to.\n * @param selector - A function to select a part of the store's state. Defaults to the entire state.\n * @param equal - A function to compare selected values for equality. Defaults to deep equality.\n * @returns The selected slice of the store's state.\n *\n * @example\n * const count = useStore(counterStore);\n *\n * @example\n * // Using a selector\n * const userName = useStore(userStore, user => user.name);\n */\nexport const useStore = <T extends unknown = any, S = T>(\n store: Store<T>,\n selector: (state: T) => S = v => v as any,\n equal: (value: S, other: S) => boolean = _.isEqual,\n): S => useSyncExternalStore(\n (onStoreChange) => store.subscribe((oldVal, newVal) => {\n if (equal(selector(oldVal), selector(newVal))) onStoreChange();\n }),\n () => selector(store.value)\n);\n"],"names":["_jsx","ErrorContext"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
8
|
-
//
|
|
9
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
// in the Software without restriction, including without limitation the rights
|
|
12
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
// furnished to do so, subject to the following conditions:
|
|
15
|
-
//
|
|
16
|
-
// The above copyright notice and this permission notice shall be included in
|
|
17
|
-
// all copies or substantial portions of the Software.
|
|
18
|
-
//
|
|
19
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
-
// THE SOFTWARE.
|
|
26
|
-
//
|
|
27
|
-
const Fragment = ({ children }) => {
|
|
28
|
-
return children;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
exports.Fragment = Fragment;
|
|
32
|
-
//# sourceMappingURL=fragment-B0rB4qEp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-B0rB4qEp.js","sources":["../../../src/core/types/fragment.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAIa,QAAQ,GAAyC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC7E,IAAA,OAAO,QAAQ;AACjB;;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// index.ts
|
|
3
|
-
//
|
|
4
|
-
// The MIT License
|
|
5
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
6
|
-
//
|
|
7
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
// in the Software without restriction, including without limitation the rights
|
|
10
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
// furnished to do so, subject to the following conditions:
|
|
13
|
-
//
|
|
14
|
-
// The above copyright notice and this permission notice shall be included in
|
|
15
|
-
// all copies or substantial portions of the Software.
|
|
16
|
-
//
|
|
17
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
// THE SOFTWARE.
|
|
24
|
-
//
|
|
25
|
-
const Fragment = ({ children }) => {
|
|
26
|
-
return children;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export { Fragment as F };
|
|
30
|
-
//# sourceMappingURL=fragment-DPs1AriN.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-DPs1AriN.mjs","sources":["../../../src/core/types/fragment.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ComponentType, PropsWithChildren } from './common';\n\nexport const Fragment: ComponentType<PropsWithChildren<{}>> = ({ children }) => {\n return children;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAIa,QAAQ,GAAyC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC7E,IAAA,OAAO,QAAQ;AACjB;;;;"}
|