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