@isograph/react-disposable-state 0.5.0 → 0.5.1

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 (69) hide show
  1. package/.turbo/turbo-compile-libs.log +9 -2
  2. package/dist/CacheItem.d.mts +63 -0
  3. package/dist/CacheItem.d.mts.map +1 -0
  4. package/dist/CacheItem.d.ts +33 -29
  5. package/dist/CacheItem.d.ts.map +1 -1
  6. package/dist/CacheItem.js +191 -266
  7. package/dist/CacheItem.mjs +193 -0
  8. package/dist/CacheItem.mjs.map +1 -0
  9. package/dist/ParentCache.d.mts +45 -0
  10. package/dist/ParentCache.d.mts.map +1 -0
  11. package/dist/ParentCache.d.ts +27 -22
  12. package/dist/ParentCache.d.ts.map +1 -1
  13. package/dist/ParentCache.js +69 -85
  14. package/dist/ParentCache.mjs +73 -0
  15. package/dist/ParentCache.mjs.map +1 -0
  16. package/dist/_virtual/rolldown_runtime.js +25 -0
  17. package/dist/index.d.mts +9 -0
  18. package/dist/index.d.ts +9 -9
  19. package/dist/index.js +24 -24
  20. package/dist/index.mjs +11 -0
  21. package/dist/useCachedResponsivePrecommitValue.d.mts +43 -0
  22. package/dist/useCachedResponsivePrecommitValue.d.mts.map +1 -0
  23. package/dist/useCachedResponsivePrecommitValue.d.ts +9 -4
  24. package/dist/useCachedResponsivePrecommitValue.d.ts.map +1 -1
  25. package/dist/useCachedResponsivePrecommitValue.js +55 -90
  26. package/dist/useCachedResponsivePrecommitValue.mjs +57 -0
  27. package/dist/useCachedResponsivePrecommitValue.mjs.map +1 -0
  28. package/dist/useDisposableState.d.mts +13 -0
  29. package/dist/useDisposableState.d.mts.map +1 -0
  30. package/dist/useDisposableState.d.ts +10 -7
  31. package/dist/useDisposableState.d.ts.map +1 -1
  32. package/dist/useDisposableState.js +36 -69
  33. package/dist/useDisposableState.mjs +37 -0
  34. package/dist/useDisposableState.mjs.map +1 -0
  35. package/dist/useHasCommittedRef.d.mts +11 -0
  36. package/dist/useHasCommittedRef.d.mts.map +1 -0
  37. package/dist/useHasCommittedRef.d.ts +7 -2
  38. package/dist/useHasCommittedRef.d.ts.map +1 -1
  39. package/dist/useHasCommittedRef.js +15 -11
  40. package/dist/useHasCommittedRef.mjs +17 -0
  41. package/dist/useHasCommittedRef.mjs.map +1 -0
  42. package/dist/useLazyDisposableState.d.mts +20 -0
  43. package/dist/useLazyDisposableState.d.mts.map +1 -0
  44. package/dist/useLazyDisposableState.d.ts +9 -4
  45. package/dist/useLazyDisposableState.d.ts.map +1 -1
  46. package/dist/useLazyDisposableState.js +32 -39
  47. package/dist/useLazyDisposableState.mjs +34 -0
  48. package/dist/useLazyDisposableState.mjs.map +1 -0
  49. package/dist/useUpdatableDisposableState.d.mts +43 -0
  50. package/dist/useUpdatableDisposableState.d.mts.map +1 -0
  51. package/dist/useUpdatableDisposableState.d.ts +10 -7
  52. package/dist/useUpdatableDisposableState.d.ts.map +1 -1
  53. package/dist/useUpdatableDisposableState.js +73 -89
  54. package/dist/useUpdatableDisposableState.mjs +74 -0
  55. package/dist/useUpdatableDisposableState.mjs.map +1 -0
  56. package/package.json +14 -6
  57. package/src/CacheItem.test.ts +4 -7
  58. package/src/CacheItem.ts +16 -11
  59. package/src/ParentCache.test.ts +5 -5
  60. package/src/ParentCache.ts +5 -4
  61. package/src/useCachedResponsivePrecommitValue.test.tsx +15 -14
  62. package/src/useCachedResponsivePrecommitValue.ts +4 -4
  63. package/src/useDisposableState.ts +21 -16
  64. package/src/useHasCommittedRef.ts +1 -1
  65. package/src/useLazyDisposableState.test.tsx +2 -2
  66. package/src/useLazyDisposableState.ts +1 -1
  67. package/src/useUpdatableDisposableState.test.tsx +19 -5
  68. package/src/useUpdatableDisposableState.ts +1 -1
  69. package/dist/index.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * from '@isograph/disposable-types';
2
- export * from './CacheItem';
3
- export * from './ParentCache';
4
- export * from './useCachedResponsivePrecommitValue';
5
- export * from './useDisposableState';
6
- export * from './useHasCommittedRef';
7
- export * from './useLazyDisposableState';
8
- export * from './useUpdatableDisposableState';
9
- //# sourceMappingURL=index.d.ts.map
1
+ import { CacheItem, CacheItemOptions, CacheItemState, InParentCacheAndNotDisposed, NotInParentCacheAndDisposed, NotInParentCacheAndNotDisposed, createTemporarilyRetainedCacheItem } from "./CacheItem.js";
2
+ import { ParentCache } from "./ParentCache.js";
3
+ import { useCachedResponsivePrecommitValue } from "./useCachedResponsivePrecommitValue.js";
4
+ import { UNASSIGNED_STATE, UnassignedState, useUpdatableDisposableState } from "./useUpdatableDisposableState.js";
5
+ import { useDisposableState } from "./useDisposableState.js";
6
+ import { useHasCommittedRef } from "./useHasCommittedRef.js";
7
+ import { useLazyDisposableState } from "./useLazyDisposableState.js";
8
+ export * from "@isograph/disposable-types";
9
+ export { CacheItem, CacheItemOptions, CacheItemState, InParentCacheAndNotDisposed, NotInParentCacheAndDisposed, NotInParentCacheAndNotDisposed, ParentCache, UNASSIGNED_STATE, UnassignedState, createTemporarilyRetainedCacheItem, useCachedResponsivePrecommitValue, useDisposableState, useHasCommittedRef, useLazyDisposableState, useUpdatableDisposableState };
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@isograph/disposable-types"), exports);
18
- __exportStar(require("./CacheItem"), exports);
19
- __exportStar(require("./ParentCache"), exports);
20
- __exportStar(require("./useCachedResponsivePrecommitValue"), exports);
21
- __exportStar(require("./useDisposableState"), exports);
22
- __exportStar(require("./useHasCommittedRef"), exports);
23
- __exportStar(require("./useLazyDisposableState"), exports);
24
- __exportStar(require("./useUpdatableDisposableState"), exports);
1
+ const require_CacheItem = require('./CacheItem.js');
2
+ const require_ParentCache = require('./ParentCache.js');
3
+ const require_useCachedResponsivePrecommitValue = require('./useCachedResponsivePrecommitValue.js');
4
+ const require_useHasCommittedRef = require('./useHasCommittedRef.js');
5
+ const require_useUpdatableDisposableState = require('./useUpdatableDisposableState.js');
6
+ const require_useDisposableState = require('./useDisposableState.js');
7
+ const require_useLazyDisposableState = require('./useLazyDisposableState.js');
8
+
9
+ exports.CacheItem = require_CacheItem.CacheItem;
10
+ exports.ParentCache = require_ParentCache.ParentCache;
11
+ exports.UNASSIGNED_STATE = require_useUpdatableDisposableState.UNASSIGNED_STATE;
12
+ exports.createTemporarilyRetainedCacheItem = require_CacheItem.createTemporarilyRetainedCacheItem;
13
+ exports.useCachedResponsivePrecommitValue = require_useCachedResponsivePrecommitValue.useCachedResponsivePrecommitValue;
14
+ exports.useDisposableState = require_useDisposableState.useDisposableState;
15
+ exports.useHasCommittedRef = require_useHasCommittedRef.useHasCommittedRef;
16
+ exports.useLazyDisposableState = require_useLazyDisposableState.useLazyDisposableState;
17
+ exports.useUpdatableDisposableState = require_useUpdatableDisposableState.useUpdatableDisposableState;
18
+ var __isograph_disposable_types = require("@isograph/disposable-types");
19
+ Object.keys(__isograph_disposable_types).forEach(function (k) {
20
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
21
+ enumerable: true,
22
+ get: function () { return __isograph_disposable_types[k]; }
23
+ });
24
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import { CacheItem, createTemporarilyRetainedCacheItem } from "./CacheItem.mjs";
2
+ import { ParentCache } from "./ParentCache.mjs";
3
+ import { useCachedResponsivePrecommitValue } from "./useCachedResponsivePrecommitValue.mjs";
4
+ import { useHasCommittedRef } from "./useHasCommittedRef.mjs";
5
+ import { UNASSIGNED_STATE, useUpdatableDisposableState } from "./useUpdatableDisposableState.mjs";
6
+ import { useDisposableState } from "./useDisposableState.mjs";
7
+ import { useLazyDisposableState } from "./useLazyDisposableState.mjs";
8
+
9
+ export * from "@isograph/disposable-types"
10
+
11
+ export { CacheItem, ParentCache, UNASSIGNED_STATE, createTemporarilyRetainedCacheItem, useCachedResponsivePrecommitValue, useDisposableState, useHasCommittedRef, useLazyDisposableState, useUpdatableDisposableState };
@@ -0,0 +1,43 @@
1
+ import { ParentCache } from "./ParentCache.mjs";
2
+ import { ItemCleanupPair } from "@isograph/disposable-types";
3
+
4
+ //#region src/useCachedResponsivePrecommitValue.d.ts
5
+
6
+ /**
7
+ * useCachedResponsivePrecommitValue<T>
8
+ * - Takes a mutable parent cache, a factory function, and an onCommit callback.
9
+ * - Returns T before commit after every parent cache change, and null afterward.
10
+ * - Calls onCommit with the ItemCleanupPair during commit after every parent cache change.
11
+ * - The T from the render phase is only temporarily retained. It may have been
12
+ * disposed by the time of the commit. If so, this hook checks the parent cache
13
+ * for another T or creates one, and passes this T to onCommit.
14
+ * - If the T returned during the last render is not the same as the one that
15
+ * is passed to onCommit, during the commit phase, it will schedule another render.
16
+ *
17
+ * Invariant: the returned T has not been disposed during the tick of the render.
18
+ * The T passed to the onCommit callback has not been disposed when the onCommit
19
+ * callback is called.
20
+ *
21
+ * Passing a different parentCache:
22
+ * - Pre-commit, passing a different parentCache has the effect of "resetting" this
23
+ * hook's state to the new cache's state. For example, if you have a cache associated
24
+ * with a set of variables (e.g. {name: "Matthew"}), and pass in another cache
25
+ * (e.g. associated with {name: "James"}), which is empty, the hook will fill that
26
+ * new cache with the factory function.
27
+ * - Post-commit, passing a different parentCache will reset hook to the pre-commit
28
+ * state. The cache will return T before commit, then fill the new cache with the
29
+ * factory function and return null afterwards.
30
+ *
31
+ * Passing a different factory:
32
+ * - Passing a different factory has no effect, except when factory is called,
33
+ * which is when the parent cache is being filled, or during commit.
34
+ *
35
+ * Passing a different onCommit:
36
+ * - Passing a different onCommit has no effect, except for during commit.
37
+ */
38
+ declare function useCachedResponsivePrecommitValue<T>(parentCache: ParentCache<T>, onCommit: (pair: ItemCleanupPair<T>) => void): {
39
+ state: T;
40
+ } | null;
41
+ //#endregion
42
+ export { useCachedResponsivePrecommitValue };
43
+ //# sourceMappingURL=useCachedResponsivePrecommitValue.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCachedResponsivePrecommitValue.d.mts","names":[],"sources":["../src/useCachedResponsivePrecommitValue.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,kDACD,YAAY,qBACR,gBAAgB;SACvB"}
@@ -1,5 +1,8 @@
1
- import { ItemCleanupPair } from '@isograph/disposable-types';
2
- import { ParentCache } from './ParentCache';
1
+ import { ParentCache } from "./ParentCache.js";
2
+ import { ItemCleanupPair } from "@isograph/disposable-types";
3
+
4
+ //#region src/useCachedResponsivePrecommitValue.d.ts
5
+
3
6
  /**
4
7
  * useCachedResponsivePrecommitValue<T>
5
8
  * - Takes a mutable parent cache, a factory function, and an onCommit callback.
@@ -32,7 +35,9 @@ import { ParentCache } from './ParentCache';
32
35
  * Passing a different onCommit:
33
36
  * - Passing a different onCommit has no effect, except for during commit.
34
37
  */
35
- export declare function useCachedResponsivePrecommitValue<T>(parentCache: ParentCache<T>, onCommit: (pair: ItemCleanupPair<T>) => void): {
36
- state: T;
38
+ declare function useCachedResponsivePrecommitValue<T>(parentCache: ParentCache<T>, onCommit: (pair: ItemCleanupPair<T>) => void): {
39
+ state: T;
37
40
  } | null;
41
+ //#endregion
42
+ export { useCachedResponsivePrecommitValue };
38
43
  //# sourceMappingURL=useCachedResponsivePrecommitValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCachedResponsivePrecommitValue.d.ts","sourceRoot":"","sources":["../src/useCachedResponsivePrecommitValue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,iCAAiC,CAAC,CAAC,EACjD,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,EAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,GAC3C;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG,IAAI,CA8DrB"}
1
+ {"version":3,"file":"useCachedResponsivePrecommitValue.d.ts","names":[],"sources":["../src/useCachedResponsivePrecommitValue.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,kDACD,YAAY,qBACR,gBAAgB;SACvB"}
@@ -1,93 +1,58 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCachedResponsivePrecommitValue = useCachedResponsivePrecommitValue;
4
- const react_1 = require("react");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
2
+ let react = require("react");
3
+ react = require_rolldown_runtime.__toESM(react);
4
+
5
+ //#region src/useCachedResponsivePrecommitValue.ts
5
6
  /**
6
- * useCachedResponsivePrecommitValue<T>
7
- * - Takes a mutable parent cache, a factory function, and an onCommit callback.
8
- * - Returns T before commit after every parent cache change, and null afterward.
9
- * - Calls onCommit with the ItemCleanupPair during commit after every parent cache change.
10
- * - The T from the render phase is only temporarily retained. It may have been
11
- * disposed by the time of the commit. If so, this hook checks the parent cache
12
- * for another T or creates one, and passes this T to onCommit.
13
- * - If the T returned during the last render is not the same as the one that
14
- * is passed to onCommit, during the commit phase, it will schedule another render.
15
- *
16
- * Invariant: the returned T has not been disposed during the tick of the render.
17
- * The T passed to the onCommit callback has not been disposed when the onCommit
18
- * callback is called.
19
- *
20
- * Passing a different parentCache:
21
- * - Pre-commit, passing a different parentCache has the effect of "resetting" this
22
- * hook's state to the new cache's state. For example, if you have a cache associated
23
- * with a set of variables (e.g. {name: "Matthew"}), and pass in another cache
24
- * (e.g. associated with {name: "James"}), which is empty, the hook will fill that
25
- * new cache with the factory function.
26
- * - Post-commit, passing a different parentCache will reset hook to the pre-commit
27
- * state. The cache will return T before commit, then fill the new cache with the
28
- * factory function and return null afterwards.
29
- *
30
- * Passing a different factory:
31
- * - Passing a different factory has no effect, except when factory is called,
32
- * which is when the parent cache is being filled, or during commit.
33
- *
34
- * Passing a different onCommit:
35
- * - Passing a different onCommit has no effect, except for during commit.
36
- */
7
+ * useCachedResponsivePrecommitValue<T>
8
+ * - Takes a mutable parent cache, a factory function, and an onCommit callback.
9
+ * - Returns T before commit after every parent cache change, and null afterward.
10
+ * - Calls onCommit with the ItemCleanupPair during commit after every parent cache change.
11
+ * - The T from the render phase is only temporarily retained. It may have been
12
+ * disposed by the time of the commit. If so, this hook checks the parent cache
13
+ * for another T or creates one, and passes this T to onCommit.
14
+ * - If the T returned during the last render is not the same as the one that
15
+ * is passed to onCommit, during the commit phase, it will schedule another render.
16
+ *
17
+ * Invariant: the returned T has not been disposed during the tick of the render.
18
+ * The T passed to the onCommit callback has not been disposed when the onCommit
19
+ * callback is called.
20
+ *
21
+ * Passing a different parentCache:
22
+ * - Pre-commit, passing a different parentCache has the effect of "resetting" this
23
+ * hook's state to the new cache's state. For example, if you have a cache associated
24
+ * with a set of variables (e.g. {name: "Matthew"}), and pass in another cache
25
+ * (e.g. associated with {name: "James"}), which is empty, the hook will fill that
26
+ * new cache with the factory function.
27
+ * - Post-commit, passing a different parentCache will reset hook to the pre-commit
28
+ * state. The cache will return T before commit, then fill the new cache with the
29
+ * factory function and return null afterwards.
30
+ *
31
+ * Passing a different factory:
32
+ * - Passing a different factory has no effect, except when factory is called,
33
+ * which is when the parent cache is being filled, or during commit.
34
+ *
35
+ * Passing a different onCommit:
36
+ * - Passing a different onCommit has no effect, except for during commit.
37
+ */
37
38
  function useCachedResponsivePrecommitValue(parentCache, onCommit) {
38
- // TODO: there should be two APIs. One in which we always re-render if the
39
- // committed item was not returned during the last render, and one in which
40
- // we do not. The latter is useful for cases where every disposable item
41
- // behaves identically, but must be loaded.
42
- //
43
- // This hook is the former, i.e. re-renders if the committed item has changed.
44
- const [, rerender] = (0, react_1.useState)(null);
45
- const lastCommittedParentCache = (0, react_1.useRef)(null);
46
- (0, react_1.useEffect)(() => {
47
- lastCommittedParentCache.current = parentCache;
48
- // On commit, cacheItem may be disposed, because during the render phase,
49
- // we only temporarily retained the item, and the temporary retain could have
50
- // expired by the time of the commit.
51
- //
52
- // So, we can be in one of two states:
53
- // - the item is not disposed. In that case, permanently retain and use that item.
54
- // - the item is disposed. In that case, we can be in two states:
55
- // - the parent cache is not empty (due to another component rendering, or
56
- // another render of the same component.) In that case, permanently retain and
57
- // use the item from the parent cache. (Note: any item present in the parent
58
- // cache is not disposed.)
59
- // - the parent cache is empty. In that case, call factory, getting a new item
60
- // and a cleanup function.
61
- //
62
- // After the above, we have a non-disposed item and a cleanup function, which we
63
- // can pass to onCommit.
64
- const undisposedPair = cacheItem.permanentRetainIfNotDisposed(disposeOfTemporaryRetain);
65
- if (undisposedPair !== null) {
66
- onCommit(undisposedPair);
67
- }
68
- else {
69
- // The cache item we created during render has been disposed. Check if the parent
70
- // cache is populated.
71
- const existingCacheItemCleanupPair = parentCache.getAndPermanentRetainIfPresent();
72
- if (existingCacheItemCleanupPair !== null) {
73
- onCommit(existingCacheItemCleanupPair);
74
- }
75
- else {
76
- // We did not find an item in the parent cache, create a new one.
77
- onCommit(parentCache.factory());
78
- }
79
- // TODO: Consider whether we always want to rerender if the committed item
80
- // was not returned during the last render, or whether some callers will
81
- // prefer opting out of this behavior (e.g. if every disposable item behaves
82
- // identically, but must be loaded.)
83
- rerender({});
84
- }
85
- }, [parentCache]);
86
- if (lastCommittedParentCache.current === parentCache) {
87
- return null;
88
- }
89
- // Safety: item is only safe to use (i.e. guaranteed not to have been disposed)
90
- // during this tick.
91
- const [cacheItem, item, disposeOfTemporaryRetain] = parentCache.getOrPopulateAndTemporaryRetain();
92
- return { state: item };
39
+ const [, rerender] = (0, react.useState)(null);
40
+ const lastCommittedParentCache = (0, react.useRef)(null);
41
+ (0, react.useEffect)(() => {
42
+ lastCommittedParentCache.current = parentCache;
43
+ const undisposedPair = cacheItem.permanentRetainIfNotDisposed(disposeOfTemporaryRetain);
44
+ if (undisposedPair != null) onCommit(undisposedPair);
45
+ else {
46
+ const existingCacheItemCleanupPair = parentCache.getAndPermanentRetainIfPresent();
47
+ if (existingCacheItemCleanupPair != null) onCommit(existingCacheItemCleanupPair);
48
+ else onCommit(parentCache.factory());
49
+ rerender({});
50
+ }
51
+ }, [parentCache]);
52
+ if (lastCommittedParentCache.current === parentCache) return null;
53
+ const [cacheItem, item, disposeOfTemporaryRetain] = parentCache.getOrPopulateAndTemporaryRetain();
54
+ return { state: item };
93
55
  }
56
+
57
+ //#endregion
58
+ exports.useCachedResponsivePrecommitValue = useCachedResponsivePrecommitValue;
@@ -0,0 +1,57 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ //#region src/useCachedResponsivePrecommitValue.ts
4
+ /**
5
+ * useCachedResponsivePrecommitValue<T>
6
+ * - Takes a mutable parent cache, a factory function, and an onCommit callback.
7
+ * - Returns T before commit after every parent cache change, and null afterward.
8
+ * - Calls onCommit with the ItemCleanupPair during commit after every parent cache change.
9
+ * - The T from the render phase is only temporarily retained. It may have been
10
+ * disposed by the time of the commit. If so, this hook checks the parent cache
11
+ * for another T or creates one, and passes this T to onCommit.
12
+ * - If the T returned during the last render is not the same as the one that
13
+ * is passed to onCommit, during the commit phase, it will schedule another render.
14
+ *
15
+ * Invariant: the returned T has not been disposed during the tick of the render.
16
+ * The T passed to the onCommit callback has not been disposed when the onCommit
17
+ * callback is called.
18
+ *
19
+ * Passing a different parentCache:
20
+ * - Pre-commit, passing a different parentCache has the effect of "resetting" this
21
+ * hook's state to the new cache's state. For example, if you have a cache associated
22
+ * with a set of variables (e.g. {name: "Matthew"}), and pass in another cache
23
+ * (e.g. associated with {name: "James"}), which is empty, the hook will fill that
24
+ * new cache with the factory function.
25
+ * - Post-commit, passing a different parentCache will reset hook to the pre-commit
26
+ * state. The cache will return T before commit, then fill the new cache with the
27
+ * factory function and return null afterwards.
28
+ *
29
+ * Passing a different factory:
30
+ * - Passing a different factory has no effect, except when factory is called,
31
+ * which is when the parent cache is being filled, or during commit.
32
+ *
33
+ * Passing a different onCommit:
34
+ * - Passing a different onCommit has no effect, except for during commit.
35
+ */
36
+ function useCachedResponsivePrecommitValue(parentCache, onCommit) {
37
+ const [, rerender] = useState(null);
38
+ const lastCommittedParentCache = useRef(null);
39
+ useEffect(() => {
40
+ lastCommittedParentCache.current = parentCache;
41
+ const undisposedPair = cacheItem.permanentRetainIfNotDisposed(disposeOfTemporaryRetain);
42
+ if (undisposedPair != null) onCommit(undisposedPair);
43
+ else {
44
+ const existingCacheItemCleanupPair = parentCache.getAndPermanentRetainIfPresent();
45
+ if (existingCacheItemCleanupPair != null) onCommit(existingCacheItemCleanupPair);
46
+ else onCommit(parentCache.factory());
47
+ rerender({});
48
+ }
49
+ }, [parentCache]);
50
+ if (lastCommittedParentCache.current === parentCache) return null;
51
+ const [cacheItem, item, disposeOfTemporaryRetain] = parentCache.getOrPopulateAndTemporaryRetain();
52
+ return { state: item };
53
+ }
54
+
55
+ //#endregion
56
+ export { useCachedResponsivePrecommitValue };
57
+ //# sourceMappingURL=useCachedResponsivePrecommitValue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCachedResponsivePrecommitValue.mjs","names":[],"sources":["../src/useCachedResponsivePrecommitValue.ts"],"sourcesContent":["'use strict';\n\nimport type { ItemCleanupPair } from '@isograph/disposable-types';\nimport { useEffect, useRef, useState } from 'react';\nimport type { ParentCache } from './ParentCache';\n\n/**\n * useCachedResponsivePrecommitValue<T>\n * - Takes a mutable parent cache, a factory function, and an onCommit callback.\n * - Returns T before commit after every parent cache change, and null afterward.\n * - Calls onCommit with the ItemCleanupPair during commit after every parent cache change.\n * - The T from the render phase is only temporarily retained. It may have been\n * disposed by the time of the commit. If so, this hook checks the parent cache\n * for another T or creates one, and passes this T to onCommit.\n * - If the T returned during the last render is not the same as the one that\n * is passed to onCommit, during the commit phase, it will schedule another render.\n *\n * Invariant: the returned T has not been disposed during the tick of the render.\n * The T passed to the onCommit callback has not been disposed when the onCommit\n * callback is called.\n *\n * Passing a different parentCache:\n * - Pre-commit, passing a different parentCache has the effect of \"resetting\" this\n * hook's state to the new cache's state. For example, if you have a cache associated\n * with a set of variables (e.g. {name: \"Matthew\"}), and pass in another cache\n * (e.g. associated with {name: \"James\"}), which is empty, the hook will fill that\n * new cache with the factory function.\n * - Post-commit, passing a different parentCache will reset hook to the pre-commit\n * state. The cache will return T before commit, then fill the new cache with the\n * factory function and return null afterwards.\n *\n * Passing a different factory:\n * - Passing a different factory has no effect, except when factory is called,\n * which is when the parent cache is being filled, or during commit.\n *\n * Passing a different onCommit:\n * - Passing a different onCommit has no effect, except for during commit.\n */\nexport function useCachedResponsivePrecommitValue<T>(\n parentCache: ParentCache<T>,\n onCommit: (pair: ItemCleanupPair<T>) => void,\n): { state: T } | null {\n // TODO: there should be two APIs. One in which we always re-render if the\n // committed item was not returned during the last render, and one in which\n // we do not. The latter is useful for cases where every disposable item\n // behaves identically, but must be loaded.\n //\n // This hook is the former, i.e. re-renders if the committed item has changed.\n const [, rerender] = useState<{} | null>(null);\n const lastCommittedParentCache = useRef<ParentCache<T> | null>(null);\n\n useEffect(() => {\n lastCommittedParentCache.current = parentCache;\n // On commit, cacheItem may be disposed, because during the render phase,\n // we only temporarily retained the item, and the temporary retain could have\n // expired by the time of the commit.\n //\n // So, we can be in one of two states:\n // - the item is not disposed. In that case, permanently retain and use that item.\n // - the item is disposed. In that case, we can be in two states:\n // - the parent cache is not empty (due to another component rendering, or\n // another render of the same component.) In that case, permanently retain and\n // use the item from the parent cache. (Note: any item present in the parent\n // cache is not disposed.)\n // - the parent cache is empty. In that case, call factory, getting a new item\n // and a cleanup function.\n //\n // After the above, we have a non-disposed item and a cleanup function, which we\n // can pass to onCommit.\n const undisposedPair = cacheItem.permanentRetainIfNotDisposed(\n disposeOfTemporaryRetain,\n );\n if (undisposedPair != null) {\n onCommit(undisposedPair);\n } else {\n // The cache item we created during render has been disposed. Check if the parent\n // cache is populated.\n const existingCacheItemCleanupPair =\n parentCache.getAndPermanentRetainIfPresent();\n if (existingCacheItemCleanupPair != null) {\n onCommit(existingCacheItemCleanupPair);\n } else {\n // We did not find an item in the parent cache, create a new one.\n onCommit(parentCache.factory());\n }\n // TODO: Consider whether we always want to rerender if the committed item\n // was not returned during the last render, or whether some callers will\n // prefer opting out of this behavior (e.g. if every disposable item behaves\n // identically, but must be loaded.)\n rerender({});\n }\n }, [parentCache]);\n\n if (lastCommittedParentCache.current === parentCache) {\n return null;\n }\n\n // Safety: item is only safe to use (i.e. guaranteed not to have been disposed)\n // during this tick.\n const [cacheItem, item, disposeOfTemporaryRetain] =\n parentCache.getOrPopulateAndTemporaryRetain();\n\n return { state: item };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,kCACd,aACA,UACqB;CAOrB,MAAM,GAAG,YAAY,SAAoB,KAAK;CAC9C,MAAM,2BAA2B,OAA8B,KAAK;AAEpE,iBAAgB;AACd,2BAAyB,UAAU;EAiBnC,MAAM,iBAAiB,UAAU,6BAC/B,yBACD;AACD,MAAI,kBAAkB,KACpB,UAAS,eAAe;OACnB;GAGL,MAAM,+BACJ,YAAY,gCAAgC;AAC9C,OAAI,gCAAgC,KAClC,UAAS,6BAA6B;OAGtC,UAAS,YAAY,SAAS,CAAC;AAMjC,YAAS,EAAE,CAAC;;IAEb,CAAC,YAAY,CAAC;AAEjB,KAAI,yBAAyB,YAAY,YACvC,QAAO;CAKT,MAAM,CAAC,WAAW,MAAM,4BACtB,YAAY,iCAAiC;AAE/C,QAAO,EAAE,OAAO,MAAM"}
@@ -0,0 +1,13 @@
1
+ import { ParentCache } from "./ParentCache.mjs";
2
+ import { UnassignedState } from "./useUpdatableDisposableState.mjs";
3
+ import { ItemCleanupPair } from "@isograph/disposable-types";
4
+
5
+ //#region src/useDisposableState.d.ts
6
+ type UseUpdatableDisposableStateReturnValue<T> = {
7
+ state: T;
8
+ setState: (pair: ItemCleanupPair<Exclude<T, UnassignedState>>) => void;
9
+ };
10
+ declare function useDisposableState<T = never>(parentCache: ParentCache<T>): UseUpdatableDisposableStateReturnValue<T>;
11
+ //#endregion
12
+ export { useDisposableState };
13
+ //# sourceMappingURL=useDisposableState.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDisposableState.d.mts","names":[],"sources":["../src/useDisposableState.ts"],"sourcesContent":[],"mappings":";;;;;KAUK;SACI;EADJ,QAAA,EAAA,CAAA,IAAA,EAEc,eAFd,CAE8B,OAF9B,CAEsC,CAFA,EAEG,eAFH,CAAA,CAAA,EAAA,GAAA,IAAA;CAClC;AACkC,iBAG3B,kBAH2B,CAAA,IAAA,KAAA,CAAA,CAAA,WAAA,EAI5B,WAJ4B,CAIhB,CAJgB,CAAA,CAAA,EAKxC,sCALwC,CAKD,CALC,CAAA"}
@@ -1,10 +1,13 @@
1
- import { ItemCleanupPair } from '@isograph/disposable-types';
2
- import { ParentCache } from './ParentCache';
3
- import { UnassignedState } from './useUpdatableDisposableState';
1
+ import { ParentCache } from "./ParentCache.js";
2
+ import { UnassignedState } from "./useUpdatableDisposableState.js";
3
+ import { ItemCleanupPair } from "@isograph/disposable-types";
4
+
5
+ //#region src/useDisposableState.d.ts
4
6
  type UseUpdatableDisposableStateReturnValue<T> = {
5
- state: T;
6
- setState: (pair: ItemCleanupPair<Exclude<T, UnassignedState>>) => void;
7
+ state: T;
8
+ setState: (pair: ItemCleanupPair<Exclude<T, UnassignedState>>) => void;
7
9
  };
8
- export declare function useDisposableState<T = never>(parentCache: ParentCache<T>): UseUpdatableDisposableStateReturnValue<T>;
9
- export {};
10
+ declare function useDisposableState<T = never>(parentCache: ParentCache<T>): UseUpdatableDisposableStateReturnValue<T>;
11
+ //#endregion
12
+ export { useDisposableState };
10
13
  //# sourceMappingURL=useDisposableState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDisposableState.d.ts","sourceRoot":"","sources":["../src/useDisposableState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAEL,eAAe,EAEhB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,sCAAsC,CAAC,CAAC,IAAI;IAC/C,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,IAAI,CAAC;CACxE,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,KAAK,EAC1C,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAC1B,sCAAsC,CAAC,CAAC,CAAC,CAgE3C"}
1
+ {"version":3,"file":"useDisposableState.d.ts","names":[],"sources":["../src/useDisposableState.ts"],"sourcesContent":[],"mappings":";;;;;KAUK;SACI;EADJ,QAAA,EAAA,CAAA,IAAA,EAEc,eAFd,CAE8B,OAF9B,CAEsC,CAFA,EAEG,eAFH,CAAA,CAAA,EAAA,GAAA,IAAA;CAClC;AACkC,iBAG3B,kBAH2B,CAAA,IAAA,KAAA,CAAA,CAAA,WAAA,EAI5B,WAJ4B,CAIhB,CAJgB,CAAA,CAAA,EAKxC,sCALwC,CAKD,CALC,CAAA"}
@@ -1,71 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDisposableState = useDisposableState;
4
- const react_1 = require("react");
5
- const useCachedResponsivePrecommitValue_1 = require("./useCachedResponsivePrecommitValue");
6
- const useUpdatableDisposableState_1 = require("./useUpdatableDisposableState");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
2
+ const require_useCachedResponsivePrecommitValue = require('./useCachedResponsivePrecommitValue.js');
3
+ const require_useUpdatableDisposableState = require('./useUpdatableDisposableState.js');
4
+ let react = require("react");
5
+ react = require_rolldown_runtime.__toESM(react);
6
+
7
+ //#region src/useDisposableState.ts
7
8
  function useDisposableState(parentCache) {
8
- var _a, _b, _c;
9
- const itemCleanupPairRef = (0, react_1.useRef)(null);
10
- const preCommitItem = (0, useCachedResponsivePrecommitValue_1.useCachedResponsivePrecommitValue)(parentCache, (pair) => {
11
- var _a;
12
- (_a = itemCleanupPairRef.current) === null || _a === void 0 ? void 0 : _a[1]();
13
- itemCleanupPairRef.current = pair;
14
- });
15
- const { state: stateFromDisposableStateHook, setState } = (0, useUpdatableDisposableState_1.useUpdatableDisposableState)();
16
- (0, react_1.useEffect)(function cleanupItemCleanupPairRefAfterSetState() {
17
- if (stateFromDisposableStateHook !== useUpdatableDisposableState_1.UNASSIGNED_STATE) {
18
- if (itemCleanupPairRef.current !== null) {
19
- itemCleanupPairRef.current[1]();
20
- itemCleanupPairRef.current = null;
21
- }
22
- else {
23
- throw new Error('itemCleanupPairRef.current is unexpectedly null. ' +
24
- 'This indicates a bug in react-disposable-state.');
25
- }
26
- }
27
- }, [stateFromDisposableStateHook]);
28
- (0, react_1.useEffect)(function cleanupItemCleanupPairRefIfSetStateNotCalled() {
29
- return () => {
30
- if (itemCleanupPairRef.current !== null) {
31
- itemCleanupPairRef.current[1]();
32
- itemCleanupPairRef.current = null;
33
- }
34
- };
35
- }, []);
36
- // Safety: we can be in one of three states. Pre-commit, in which case
37
- // preCommitItem is assigned, post-commit but before setState has been
38
- // called, in which case itemCleanupPairRef.current is assigned, or
39
- // after setState has been called, in which case
40
- // stateFromDisposableStateHook is assigned.
41
- //
42
- // Therefore, the type of state is T, not T | undefined. But the fact
43
- // that we are in one of the three states is not reflected in the types.
44
- // So we have to cast to T.
45
- //
46
- // Note that in the post-commit post-setState state, itemCleanupPairRef
47
- // can still be assigned, during the render before the
48
- // cleanupItemCleanupPairRefAfterSetState effect is called.
49
- const state = (_b = (_a = (stateFromDisposableStateHook != useUpdatableDisposableState_1.UNASSIGNED_STATE
50
- ? stateFromDisposableStateHook
51
- : null)) !== null && _a !== void 0 ? _a : preCommitItem === null || preCommitItem === void 0 ? void 0 : preCommitItem.state) !== null && _b !== void 0 ? _b : (_c = itemCleanupPairRef.current) === null || _c === void 0 ? void 0 : _c[0];
52
- return {
53
- state: state,
54
- setState,
55
- };
56
- }
57
- // @ts-ignore
58
- function tsTests() {
59
- let x;
60
- const a = useDisposableState(x);
61
- // This should be a compiler error, because the generic is inferred to be of
62
- // type never. TODO determine why this doesn't break the build!
63
- // @ts-expect-error
64
- a.setState(['asdf', () => { }]);
65
- // @ts-expect-error
66
- a.setState([useUpdatableDisposableState_1.UNASSIGNED_STATE, () => { }]);
67
- const b = useDisposableState(x);
68
- // @ts-expect-error
69
- b.setState([useUpdatableDisposableState_1.UNASSIGNED_STATE, () => { }]);
70
- b.setState(['asdf', () => { }]);
9
+ const itemCleanupPairRef = (0, react.useRef)(null);
10
+ const preCommitItem = require_useCachedResponsivePrecommitValue.useCachedResponsivePrecommitValue(parentCache, (pair) => {
11
+ itemCleanupPairRef.current?.[1]();
12
+ itemCleanupPairRef.current = pair;
13
+ });
14
+ const { state: stateFromDisposableStateHook, setState } = require_useUpdatableDisposableState.useUpdatableDisposableState();
15
+ (0, react.useEffect)(function cleanupItemCleanupPairRefAfterSetState() {
16
+ if (stateFromDisposableStateHook !== require_useUpdatableDisposableState.UNASSIGNED_STATE) if (itemCleanupPairRef.current != null) {
17
+ itemCleanupPairRef.current[1]();
18
+ itemCleanupPairRef.current = null;
19
+ } else throw new Error("itemCleanupPairRef.current is unexpectedly null. This indicates a bug in react-disposable-state.");
20
+ }, [stateFromDisposableStateHook]);
21
+ (0, react.useEffect)(function cleanupItemCleanupPairRefIfSetStateNotCalled() {
22
+ return () => {
23
+ if (itemCleanupPairRef.current != null) {
24
+ itemCleanupPairRef.current[1]();
25
+ itemCleanupPairRef.current = null;
26
+ }
27
+ };
28
+ }, []);
29
+ const state = (stateFromDisposableStateHook !== require_useUpdatableDisposableState.UNASSIGNED_STATE ? stateFromDisposableStateHook : null) ?? preCommitItem?.state ?? itemCleanupPairRef.current?.[0];
30
+ if (state != null) return {
31
+ state,
32
+ setState
33
+ };
34
+ throw new Error("state was unexpectedly null. This indicates a bug in react-disposable-state.");
71
35
  }
36
+
37
+ //#endregion
38
+ exports.useDisposableState = useDisposableState;
@@ -0,0 +1,37 @@
1
+ import { useCachedResponsivePrecommitValue } from "./useCachedResponsivePrecommitValue.mjs";
2
+ import { UNASSIGNED_STATE, useUpdatableDisposableState } from "./useUpdatableDisposableState.mjs";
3
+ import { useEffect, useRef } from "react";
4
+
5
+ //#region src/useDisposableState.ts
6
+ function useDisposableState(parentCache) {
7
+ const itemCleanupPairRef = useRef(null);
8
+ const preCommitItem = useCachedResponsivePrecommitValue(parentCache, (pair) => {
9
+ itemCleanupPairRef.current?.[1]();
10
+ itemCleanupPairRef.current = pair;
11
+ });
12
+ const { state: stateFromDisposableStateHook, setState } = useUpdatableDisposableState();
13
+ useEffect(function cleanupItemCleanupPairRefAfterSetState() {
14
+ if (stateFromDisposableStateHook !== UNASSIGNED_STATE) if (itemCleanupPairRef.current != null) {
15
+ itemCleanupPairRef.current[1]();
16
+ itemCleanupPairRef.current = null;
17
+ } else throw new Error("itemCleanupPairRef.current is unexpectedly null. This indicates a bug in react-disposable-state.");
18
+ }, [stateFromDisposableStateHook]);
19
+ useEffect(function cleanupItemCleanupPairRefIfSetStateNotCalled() {
20
+ return () => {
21
+ if (itemCleanupPairRef.current != null) {
22
+ itemCleanupPairRef.current[1]();
23
+ itemCleanupPairRef.current = null;
24
+ }
25
+ };
26
+ }, []);
27
+ const state = (stateFromDisposableStateHook !== UNASSIGNED_STATE ? stateFromDisposableStateHook : null) ?? preCommitItem?.state ?? itemCleanupPairRef.current?.[0];
28
+ if (state != null) return {
29
+ state,
30
+ setState
31
+ };
32
+ throw new Error("state was unexpectedly null. This indicates a bug in react-disposable-state.");
33
+ }
34
+
35
+ //#endregion
36
+ export { useDisposableState };
37
+ //# sourceMappingURL=useDisposableState.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDisposableState.mjs","names":["state: T | undefined"],"sources":["../src/useDisposableState.ts"],"sourcesContent":["import type { ItemCleanupPair } from '@isograph/disposable-types';\nimport { useEffect, useRef } from 'react';\nimport type { ParentCache } from './ParentCache';\nimport { useCachedResponsivePrecommitValue } from './useCachedResponsivePrecommitValue';\nimport {\n UNASSIGNED_STATE,\n type UnassignedState,\n useUpdatableDisposableState,\n} from './useUpdatableDisposableState';\n\ntype UseUpdatableDisposableStateReturnValue<T> = {\n state: T;\n setState: (pair: ItemCleanupPair<Exclude<T, UnassignedState>>) => void;\n};\n\nexport function useDisposableState<T = never>(\n parentCache: ParentCache<T>,\n): UseUpdatableDisposableStateReturnValue<T> {\n const itemCleanupPairRef = useRef<ItemCleanupPair<T> | null>(null);\n\n const preCommitItem = useCachedResponsivePrecommitValue(\n parentCache,\n (pair) => {\n itemCleanupPairRef.current?.[1]();\n itemCleanupPairRef.current = pair;\n },\n );\n\n const { state: stateFromDisposableStateHook, setState } =\n useUpdatableDisposableState<T>();\n\n useEffect(\n function cleanupItemCleanupPairRefAfterSetState() {\n if (stateFromDisposableStateHook !== UNASSIGNED_STATE) {\n if (itemCleanupPairRef.current != null) {\n itemCleanupPairRef.current[1]();\n itemCleanupPairRef.current = null;\n } else {\n throw new Error(\n 'itemCleanupPairRef.current is unexpectedly null. ' +\n 'This indicates a bug in react-disposable-state.',\n );\n }\n }\n },\n [stateFromDisposableStateHook],\n );\n\n useEffect(function cleanupItemCleanupPairRefIfSetStateNotCalled() {\n return () => {\n if (itemCleanupPairRef.current != null) {\n itemCleanupPairRef.current[1]();\n itemCleanupPairRef.current = null;\n }\n };\n }, []);\n const state: T | undefined =\n (stateFromDisposableStateHook !== UNASSIGNED_STATE\n ? stateFromDisposableStateHook\n : null) ??\n preCommitItem?.state ??\n itemCleanupPairRef.current?.[0];\n\n if (state != null) {\n return {\n state: state,\n setState,\n };\n }\n\n // Safety: we can be in one of three states. Pre-commit, in which case\n // preCommitItem is assigned, post-commit but before setState has been\n // called, in which case itemCleanupPairRef.current is assigned, or\n // after setState has been called, in which case\n // stateFromDisposableStateHook is assigned.\n //\n // Therefore, the type of state is T, not T | undefined. But the fact\n // that we are in one of the three states is not reflected in the types.\n // So we have to cast to T.\n //\n // Note that in the post-commit post-setState state, itemCleanupPairRef\n // can still be assigned, during the render before the\n // cleanupItemCleanupPairRefAfterSetState effect is called.\n throw new Error(\n 'state was unexpectedly null. This indicates a bug in react-disposable-state.',\n );\n}\n\n// @ts-ignore\nfunction tsTests() {\n let x: any;\n const a = useDisposableState(x);\n // This should be a compiler error, because the generic is inferred to be of\n // type never. TODO determine why this doesn't break the build!\n // @ts-expect-error\n a.setState(['asdf', () => {}]);\n // @ts-expect-error\n a.setState([UNASSIGNED_STATE, () => {}]);\n const b = useDisposableState<string | UnassignedState>(x);\n // @ts-expect-error\n b.setState([UNASSIGNED_STATE, () => {}]);\n b.setState(['asdf', () => {}]);\n}\n"],"mappings":";;;;;AAeA,SAAgB,mBACd,aAC2C;CAC3C,MAAM,qBAAqB,OAAkC,KAAK;CAElE,MAAM,gBAAgB,kCACpB,cACC,SAAS;AACR,qBAAmB,UAAU,IAAI;AACjC,qBAAmB,UAAU;GAEhC;CAED,MAAM,EAAE,OAAO,8BAA8B,aAC3C,6BAAgC;AAElC,WACE,SAAS,yCAAyC;AAChD,MAAI,iCAAiC,iBACnC,KAAI,mBAAmB,WAAW,MAAM;AACtC,sBAAmB,QAAQ,IAAI;AAC/B,sBAAmB,UAAU;QAE7B,OAAM,IAAI,MACR,mGAED;IAIP,CAAC,6BAA6B,CAC/B;AAED,WAAU,SAAS,+CAA+C;AAChE,eAAa;AACX,OAAI,mBAAmB,WAAW,MAAM;AACtC,uBAAmB,QAAQ,IAAI;AAC/B,uBAAmB,UAAU;;;IAGhC,EAAE,CAAC;CACN,MAAMA,SACH,iCAAiC,mBAC9B,+BACA,SACJ,eAAe,SACf,mBAAmB,UAAU;AAE/B,KAAI,SAAS,KACX,QAAO;EACE;EACP;EACD;AAgBH,OAAM,IAAI,MACR,+EACD"}
@@ -0,0 +1,11 @@
1
+ import { MutableRefObject } from "react";
2
+
3
+ //#region src/useHasCommittedRef.d.ts
4
+
5
+ /**
6
+ * Returns true if the component has committed, false otherwise.
7
+ */
8
+ declare function useHasCommittedRef(): MutableRefObject<boolean>;
9
+ //#endregion
10
+ export { useHasCommittedRef };
11
+ //# sourceMappingURL=useHasCommittedRef.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHasCommittedRef.d.mts","names":[],"sources":["../src/useHasCommittedRef.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;iBAAgB,kBAAA,CAAA,GAAsB"}