@dxos/react-async 2.28.2

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 (61) hide show
  1. package/README.md +29 -0
  2. package/dist/src/index.d.ts +8 -0
  3. package/dist/src/index.d.ts.map +1 -0
  4. package/dist/src/index.js +23 -0
  5. package/dist/src/index.js.map +1 -0
  6. package/dist/src/useAsyncEffect.d.ts +28 -0
  7. package/dist/src/useAsyncEffect.d.ts.map +1 -0
  8. package/dist/src/useAsyncEffect.js +53 -0
  9. package/dist/src/useAsyncEffect.js.map +1 -0
  10. package/dist/src/useAsyncEffect.test.d.ts +2 -0
  11. package/dist/src/useAsyncEffect.test.d.ts.map +1 -0
  12. package/dist/src/useAsyncEffect.test.js +70 -0
  13. package/dist/src/useAsyncEffect.test.js.map +1 -0
  14. package/dist/src/useControlledState.d.ts +17 -0
  15. package/dist/src/useControlledState.d.ts.map +1 -0
  16. package/dist/src/useControlledState.js +37 -0
  17. package/dist/src/useControlledState.js.map +1 -0
  18. package/dist/src/useDynamicRef.d.ts +17 -0
  19. package/dist/src/useDynamicRef.d.ts.map +1 -0
  20. package/dist/src/useDynamicRef.js +33 -0
  21. package/dist/src/useDynamicRef.js.map +1 -0
  22. package/dist/src/useMounted.d.ts +25 -0
  23. package/dist/src/useMounted.d.ts.map +1 -0
  24. package/dist/src/useMounted.js +42 -0
  25. package/dist/src/useMounted.js.map +1 -0
  26. package/dist/src/useStateUpdater.d.ts +20 -0
  27. package/dist/src/useStateUpdater.d.ts.map +1 -0
  28. package/dist/src/useStateUpdater.js +43 -0
  29. package/dist/src/useStateUpdater.js.map +1 -0
  30. package/dist/src/useStateUpdater.test.d.ts +2 -0
  31. package/dist/src/useStateUpdater.test.d.ts.map +1 -0
  32. package/dist/src/useStateUpdater.test.js +69 -0
  33. package/dist/src/useStateUpdater.test.js.map +1 -0
  34. package/dist/src/useStateWithRef.d.ts +17 -0
  35. package/dist/src/useStateWithRef.d.ts.map +1 -0
  36. package/dist/src/useStateWithRef.js +31 -0
  37. package/dist/src/useStateWithRef.js.map +1 -0
  38. package/dist/src/useTimestamp.d.ts +12 -0
  39. package/dist/src/useTimestamp.d.ts.map +1 -0
  40. package/dist/src/useTimestamp.js +28 -0
  41. package/dist/src/useTimestamp.js.map +1 -0
  42. package/dist/stories/stale-callback.stories.d.ts +6 -0
  43. package/dist/stories/stale-callback.stories.d.ts.map +1 -0
  44. package/dist/stories/stale-callback.stories.js +59 -0
  45. package/dist/stories/stale-callback.stories.js.map +1 -0
  46. package/dist/stories/unmounted.stories.d.ts +6 -0
  47. package/dist/stories/unmounted.stories.d.ts.map +1 -0
  48. package/dist/stories/unmounted.stories.js +60 -0
  49. package/dist/stories/unmounted.stories.js.map +1 -0
  50. package/dist/tsconfig.tsbuildinfo +1 -0
  51. package/package.json +52 -0
  52. package/src/index.ts +11 -0
  53. package/src/useAsyncEffect.test.tsx +57 -0
  54. package/src/useAsyncEffect.ts +61 -0
  55. package/src/useControlledState.ts +39 -0
  56. package/src/useDynamicRef.ts +34 -0
  57. package/src/useMounted.ts +40 -0
  58. package/src/useStateUpdater.test.tsx +58 -0
  59. package/src/useStateUpdater.ts +40 -0
  60. package/src/useStateWithRef.ts +31 -0
  61. package/src/useTimestamp.ts +27 -0
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2022 DXOS.org
4
+ //
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useStateWithRef = void 0;
7
+ const react_1 = require("react");
8
+ /**
9
+ * Extension of useState to return an up-to-date reference.
10
+ * E.g., to use in callbacks where the state value is stale.
11
+ * https://css-tricks.com/dealing-with-stale-props-and-states-in-reacts-functional-components
12
+ *
13
+ * ```tsx
14
+ * const [value, setValue, valueRef] = useStateWithRef<string>();
15
+ * const handleAction = () => {
16
+ * console.log(valueRef.current);
17
+ * }
18
+ * ```
19
+ *
20
+ * @param initialValue
21
+ */
22
+ const useStateWithRef = (initialValue) => {
23
+ const [value, setValue] = (0, react_1.useState)(initialValue);
24
+ const ref = (0, react_1.useRef)();
25
+ (0, react_1.useEffect)(() => {
26
+ ref.current = value;
27
+ }, [initialValue, value]);
28
+ return [value, setValue, ref];
29
+ };
30
+ exports.useStateWithRef = useStateWithRef;
31
+ //# sourceMappingURL=useStateWithRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStateWithRef.js","sourceRoot":"","sources":["../../src/useStateWithRef.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,iCAAyF;AAEzF;;;;;;;;;;;;;GAaG;AACI,MAAM,eAAe,GAAG,CAC7B,YAA4B,EACwD,EAAE;IACtF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAgB,YAAY,CAAC,CAAC;IAChE,MAAM,GAAG,GAAG,IAAA,cAAM,GAAK,CAAC;IACxB,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1B,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Provides a timestamp that can be used to force re-rendering based on deps.
3
+ *
4
+ * ```tsx
5
+ * const [, update] = useTimestamp();
6
+ * const handleRefresh = () => update();
7
+ * ```
8
+ *
9
+ * @param deps
10
+ */
11
+ export declare const useTimestamp: (deps?: any[] | undefined) => [number, () => void, number | undefined];
12
+ //# sourceMappingURL=useTimestamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTimestamp.d.ts","sourceRoot":"","sources":["../../src/useTimestamp.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,gCAAmB,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,MAAM,GAAG,SAAS,CAUlF,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2022 DXOS.org
4
+ //
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useTimestamp = void 0;
7
+ const react_1 = require("react");
8
+ /**
9
+ * Provides a timestamp that can be used to force re-rendering based on deps.
10
+ *
11
+ * ```tsx
12
+ * const [, update] = useTimestamp();
13
+ * const handleRefresh = () => update();
14
+ * ```
15
+ *
16
+ * @param deps
17
+ */
18
+ const useTimestamp = (deps) => {
19
+ const [{ timestamp, previous }, setTimestamp] = (0, react_1.useState)({
20
+ timestamp: Date.now()
21
+ });
22
+ (0, react_1.useEffect)(() => {
23
+ setTimestamp({ timestamp: Date.now(), previous: timestamp });
24
+ }, deps || []);
25
+ return [timestamp, () => setTimestamp({ timestamp: Date.now(), previous: timestamp }), previous];
26
+ };
27
+ exports.useTimestamp = useTimestamp;
28
+ //# sourceMappingURL=useTimestamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTimestamp.js","sourceRoot":"","sources":["../../src/useTimestamp.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,iCAA4C;AAE5C;;;;;;;;;GASG;AACI,MAAM,YAAY,GAAG,CAAC,IAAY,EAA4C,EAAE;IACrF,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAA2C;QACjG,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/D,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IAEf,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;AACnG,CAAC,CAAC;AAVW,QAAA,YAAY,gBAUvB"}
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ };
4
+ export default _default;
5
+ export declare const Primary: () => JSX.Element;
6
+ //# sourceMappingURL=stale-callback.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stale-callback.stories.d.ts","sourceRoot":"","sources":["../../stories/stale-callback.stories.tsx"],"names":[],"mappings":";;;AAQA,wBAEE;AAEF,eAAO,MAAM,OAAO,mBA8BnB,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2021 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Primary = void 0;
26
+ const react_1 = __importStar(require("react"));
27
+ const src_1 = require("../src");
28
+ exports.default = {
29
+ title: 'react-async/stale-callback'
30
+ };
31
+ const Primary = () => {
32
+ const [value, setValue, valueRef] = (0, src_1.useStateWithRef)(0);
33
+ const [result, setResult] = (0, react_1.useState)({});
34
+ (0, react_1.useEffect)(() => {
35
+ let counter = 0;
36
+ const i = setInterval(() => {
37
+ setValue(++counter);
38
+ }, 1000);
39
+ return () => clearInterval(i);
40
+ }, []);
41
+ (0, react_1.useEffect)(() => {
42
+ const t = setTimeout(() => {
43
+ setResult({
44
+ value,
45
+ ref: valueRef.current // Ref will be 5.
46
+ });
47
+ }, 5000);
48
+ return () => clearTimeout(t);
49
+ }, []);
50
+ return (react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center', padding: 16 } },
51
+ react_1.default.createElement("div", { style: { paddingLeft: 16 } },
52
+ "Value: ",
53
+ value),
54
+ react_1.default.createElement("div", { style: { paddingLeft: 16 } },
55
+ "Result: ",
56
+ JSON.stringify(result))));
57
+ };
58
+ exports.Primary = Primary;
59
+ //# sourceMappingURL=stale-callback.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stale-callback.stories.js","sourceRoot":"","sources":["../../stories/stale-callback.stories.tsx"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAEF,+CAAmD;AAEnD,gCAAyC;AAEzC,kBAAe;IACb,KAAK,EAAE,4BAA4B;CACpC,CAAC;AAEK,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAA,qBAAe,EAAC,CAAC,CAAC,CAAC;IACvD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IAEzC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE;YACzB,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,SAAS,CAAC;gBACR,KAAK;gBACL,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,iBAAiB;aACxC,CAAC,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,uCAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAChE,uCAAK,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;;YAAU,KAAK,CAAO;QACrD,uCAAK,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;;YAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAO,CACnE,CACP,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,OAAO,WA8BlB"}
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ };
4
+ export default _default;
5
+ export declare const Primary: () => JSX.Element;
6
+ //# sourceMappingURL=unmounted.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmounted.stories.d.ts","sourceRoot":"","sources":["../../stories/unmounted.stories.tsx"],"names":[],"mappings":";;;AAQA,wBAEE;AAmCF,eAAO,MAAM,OAAO,mBAMnB,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2021 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Primary = void 0;
26
+ const react_1 = __importStar(require("react"));
27
+ const src_1 = require("../src");
28
+ exports.default = {
29
+ title: 'react-async/unmounted'
30
+ };
31
+ const AsyncComponent = ({ nocheck = false }) => {
32
+ const [value, setValue] = (0, react_1.useState)('Processing...');
33
+ const isMounted = (0, src_1.useMounted)();
34
+ (0, react_1.useEffect)(() => {
35
+ setTimeout(() => {
36
+ if (nocheck || isMounted()) { // Check if still mounted.
37
+ setValue('Done');
38
+ }
39
+ }, 2000);
40
+ }, []);
41
+ return (react_1.default.createElement("div", null, value));
42
+ };
43
+ const TestApp = () => {
44
+ const [show, setShow] = (0, react_1.useState)(true);
45
+ (0, react_1.useEffect)(() => {
46
+ setTimeout(() => {
47
+ setShow(false); // Remove element.
48
+ }, 1000);
49
+ }, []);
50
+ if (!show) {
51
+ return null;
52
+ }
53
+ return (react_1.default.createElement(AsyncComponent, { nocheck: true }));
54
+ };
55
+ const Primary = () => {
56
+ return (react_1.default.createElement("div", { style: { padding: 16 } },
57
+ react_1.default.createElement(TestApp, null)));
58
+ };
59
+ exports.Primary = Primary;
60
+ //# sourceMappingURL=unmounted.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmounted.stories.js","sourceRoot":"","sources":["../../stories/unmounted.stories.tsx"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;;;;;;;AAEF,+CAAmD;AAEnD,gCAAoC;AAEpC,kBAAe;IACb,KAAK,EAAE,uBAAuB;CAC/B,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,EAAE,OAAO,GAAG,KAAK,EAAyB,EAAE,EAAE;IACpE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,eAAe,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAA,gBAAU,GAAE,CAAC;IAC/B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,OAAO,IAAI,SAAS,EAAE,EAAE,EAAE,0BAA0B;gBACtD,QAAQ,CAAC,MAAM,CAAC,CAAC;aAClB;QACH,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,2CAAM,KAAK,CAAO,CACnB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,GAAG,EAAE;IACnB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IACvC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,UAAU,CAAC,GAAG,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB;QACpC,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,cAAc,IAAC,OAAO,SAAG,CAC3B,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,OAAO,CACL,uCAAK,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACzB,8BAAC,OAAO,OAAG,CACP,CACP,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,OAAO,WAMlB"}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es5.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.esnext.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.dom.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../../common/temp/node_modules/.pnpm/typescript@4.5.3/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../common/temp/node_modules/.pnpm/@types+react@17.0.37/node_modules/@types/react/global.d.ts","../../../../common/temp/node_modules/.pnpm/csstype@3.0.10/node_modules/csstype/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+prop-types@15.7.4/node_modules/@types/prop-types/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+scheduler@0.16.2/node_modules/@types/scheduler/tracing.d.ts","../../../../common/temp/node_modules/.pnpm/@types+react@17.0.37/node_modules/@types/react/index.d.ts","../src/useAsyncEffect.ts","../src/useControlledState.ts","../src/useDynamicRef.ts","../src/useMounted.ts","../../../../common/temp/node_modules/.pnpm/immutability-helper@3.1.1/node_modules/immutability-helper/index.d.ts","../src/useStateUpdater.ts","../src/useStateWithRef.ts","../src/useTimestamp.ts","../src/index.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/assert.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/globals.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/async_hooks.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/buffer.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/child_process.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/cluster.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/console.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/constants.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/crypto.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/dgram.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/dns.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/domain.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/events.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/fs.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/fs/promises.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/http.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/http2.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/https.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/inspector.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/module.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/net.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/os.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/path.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/perf_hooks.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/process.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/punycode.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/querystring.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/readline.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/repl.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/stream.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/string_decoder.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/timers.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/tls.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/trace_events.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/tty.d.ts","../../../../common/temp/node_modules/.pnpm/querystring@0.2.1/node_modules/querystring/decode.d.ts","../../../../common/temp/node_modules/.pnpm/querystring@0.2.1/node_modules/querystring/encode.d.ts","../../../../common/temp/node_modules/.pnpm/querystring@0.2.1/node_modules/querystring/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/url.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/util.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/v8.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/vm.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/wasi.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/worker_threads.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/zlib.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/globals.global.d.ts","../../../../common/temp/node_modules/.pnpm/@types+node@14.18.0/node_modules/@types/node/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+istanbul-lib-coverage@2.0.3/node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../../common/temp/node_modules/.pnpm/@jest+types@27.4.2/node_modules/@jest/types/build/Global.d.ts","../../../../common/temp/node_modules/.pnpm/@jest+types@27.4.2/node_modules/@jest/types/build/Circus.d.ts","../../../../common/temp/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+istanbul-lib-report@3.0.0/node_modules/@types/istanbul-lib-report/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+istanbul-reports@3.0.1/node_modules/@types/istanbul-reports/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+yargs-parser@20.2.1/node_modules/@types/yargs-parser/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+yargs@16.0.4/node_modules/@types/yargs/index.d.ts","../../../../common/temp/node_modules/.pnpm/@jest+types@27.4.2/node_modules/@jest/types/build/Config.d.ts","../../../../common/temp/node_modules/.pnpm/@jest+types@27.4.2/node_modules/@jest/types/build/TestResult.d.ts","../../../../common/temp/node_modules/.pnpm/@jest+types@27.4.2/node_modules/@jest/types/build/Transform.d.ts","../../../../common/temp/node_modules/.pnpm/@jest+types@27.4.2/node_modules/@jest/types/build/index.d.ts","../../../../common/temp/node_modules/.pnpm/jest-diff@27.4.2/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../common/temp/node_modules/.pnpm/pretty-format@27.4.2/node_modules/pretty-format/build/types.d.ts","../../../../common/temp/node_modules/.pnpm/pretty-format@27.4.2/node_modules/pretty-format/build/index.d.ts","../../../../common/temp/node_modules/.pnpm/jest-diff@27.4.2/node_modules/jest-diff/build/types.d.ts","../../../../common/temp/node_modules/.pnpm/jest-diff@27.4.2/node_modules/jest-diff/build/diffLines.d.ts","../../../../common/temp/node_modules/.pnpm/jest-diff@27.4.2/node_modules/jest-diff/build/printDiffs.d.ts","../../../../common/temp/node_modules/.pnpm/jest-diff@27.4.2/node_modules/jest-diff/build/index.d.ts","../../../../common/temp/node_modules/.pnpm/jest-matcher-utils@27.4.2/node_modules/jest-matcher-utils/build/index.d.ts","../../../../common/temp/node_modules/.pnpm/expect@27.0.6/node_modules/expect/build/jestMatchersObject.d.ts","../../../../common/temp/node_modules/.pnpm/expect@27.0.6/node_modules/expect/build/types.d.ts","../../../../common/temp/node_modules/.pnpm/expect@27.0.6/node_modules/expect/build/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+react-dom@17.0.11/node_modules/@types/react-dom/index.d.ts","../../../../common/temp/node_modules/.pnpm/@types+react-dom@17.0.11/node_modules/@types/react-dom/test-utils/index.d.ts","../../../../common/temp/node_modules/.pnpm/wait-for-expect@3.0.2/node_modules/wait-for-expect/lib/index.d.ts","../src/useAsyncEffect.test.tsx","../src/useStateUpdater.test.tsx","../stories/stale-callback.stories.tsx","../stories/unmounted.stories.tsx","../../../../common/temp/node_modules/.pnpm/@types+mocha@8.2.3/node_modules/@types/mocha/index.d.ts"],"fileInfos":[{"version":"89f78430e422a0f06d13019d60d5a45b37ec2d28e67eb647f73b1b0d19a46b72","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"e8c9f4e445a489991ca1a4232667de3ac36b07ba75ea335971fbeacf2d26fe67","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},{"version":"ecf78e637f710f340ec08d5d92b3f31b134a46a4fcf2e758690d8c46ce62cba6","affectsGlobalScope":true},"381899b8d1d4c1be716f18cb5242ba39f66f4b1e31d45af62a32a99f8edcb39d","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"1bc82f5b3bb93df76d19730c84467b0b346187198537135d63a672956f323720","affectsGlobalScope":true},"484b1f5459950e94c97a0b86c3200b96062608b9b25473070501079530ef6a8c","62857228847057d08f5c763ffb37540cda0ce86a13cdf69cf43816d748f3f30d","c884c246c835927718fe906e52fd9192b0251377b77fcf4fc0fb98bf648dcf92","d456c7a5d9d1aefdb945d56a173b0345fa0ffb33483e4ccb92cc96546c91885b","57fa82b21b6aa92c2f0e72a811842121e1c12e39382a24c54798a8b77a51c1e7","d38c5704d50131023f0433185560994abbac9b2dde16785f045b665c6e613ad4","5256f1b8277c43012801540b6f845631b8bfecdff5586bf54a0a277c02a2bd9e","393ba48f74d805a3a46eb1039fa8849826230700631b326d83faa1db2856631e","395386788c5c64560afd4cc4b0ed9c35d586d437f864d377ab5c176ad39bfcef","4c2c4f53e8eedd970f8afa369d7371544fb6231bf95e659f8602e09abe74d5a5",{"version":"dc5f6951bbf5b544349cbdef895c08dee6929818abd27d7d53c38cf1209091b3","affectsGlobalScope":true},"64e2803203b14d7f104f570f2152fde13abb6edc17b2ddb33d81ad86cf43d494","2c8d9e3331aec52d9a6d4040352c00282c3abaf48053ed0944528a4845c9caa3","9b2a8f604e7c0482a9061755f00b287cc99bd8718dc82d8207dd74c599b6dc43","d0fc76a91c828fbe3f0be5d683273634b7b101068333ceed975a8a9ac464137b",{"version":"1a048ff164b8d9609f5de3139d4e37f6e8a82af82087ac414b9208f52ef8aac7","affectsGlobalScope":true},"3111079f3cb5f2b9c812ca3f46161562bce5bfb355e915f46ed46c41714dc1c3","64576aba4ff801004122056ccd049f0597aa471dcfd7670a6a0b877ee8dd97c0","b32b6b16cb0bda68199582ad6f22242d07ee75fac9b1f28a98cd838afc5eea45","4441ee4119824bfaebc49308559edd7545978f9cb41a40f115074e1031dde75f",{"version":"60693a88462d0e97900123b5bf7c73e146ce0cc94da46a61fe6775b430d2ff05","affectsGlobalScope":true},{"version":"588c69eda58b9202676ec7ca11a72c3762819b46a0ed72462c769846153c447c","affectsGlobalScope":true},"cc829932ffaf5c49092f878bec18af1fa5d8591b45a45e2b7f757f793cb3b4ed","47db10fdc4e76c4f4598cf7c91ba6bfde6cf6d8082c51860fe751643bf359739","05d7d95e24bc2897bf20ce041c3dc3cca814e07148a93999145b1a0ad491094c","d1080e49778c0b2ce656042ebfa43f89dffb96ac00f86a34762188a21857ffd4","0ce99c641ea20b0c0c09d093fc28f18f5ab31dc80033707a1ac3154399de2559","f0c33a0b325d3499cc9aded7d32886f998c9a27b465097c6cc136944d0aafdaa","44e42ed6ec9c4451ebe89524e80ac8564e9dd0988c56e6c58f393c810730595d","03c91e8833eef54dc44db99d7deb469b5e3cec82f23054b4286a2380e0e00996","1606ea615c0a5ea9f5c1376a33e34c0e1112e8dee31a5b3b8a74ce781893aa6f","9fef9de633d01cb7f01f68195626a890ededd25cf96a1e785617d08c8668230d","4455c78d226d061b1203c7614c6c6eb5f4f9db5f00d44ff47d0112de8766fbc4",{"version":"bf89ceb26132596b859cd4d129ce3f447134b444dec87966ba65cd7e8e9e0cb0","affectsGlobalScope":true},"4465a636f5f6e9665a90e30691862c9e0a3ac2edc0e66296704f10865e924f2a","9af781f03d44f5635ed7844be0ce370d9d595d4b4ec67cad88f0fac03255257e","f9fd4c3ef6de27fa0e256f4e75b61711c4be05a3399f7714621d3edc832e36b0","e49290b7a927995c0d7e6b2b9c8296284b68a9036d9966531de65185269258d7","a11d4ba43bf0825d7285d54dec6cb951685cd458a4de3c5c1800f7cbf7799009","874ca809b79276460011480a2829f4c8d4db29416dd411f71efbf8f497f0ac09","82e1723b20fa0b15a7da0d1a03fec88348f82f640f7a2f308d6c0fac780cfc7c","e0202c3e09775b86b902f21623e55896cea98750efbdf0691ca7473af06fe551","23a28f834a078986bbf58f4e3705956983ff81c3c2493f3db3e5f0e8a9507779","4febdf7f3ec92706c58e0b4e8159cd6de718284ef384260b07c9641c13fc70ce","ad7e61eca7f2f8bf47e72695f9f6663b75e41d87ef49abdb17c0cb843862f8aa","ecba2e44af95b0599c269a92628cec22e752868bce37396740deb51a5c547a26","46a9fb41a8f3bc7539eeebc15a6e04b9e55d7537a081615ad3614220d34c3e0f","a2666b43d889b4882ac6ede1c48128bac351886854e94f832b20d3730e5062c5","7335933d9f30dcfd2c4b6080a8b78e81912a7fcefb1dafccb67ca4cb4b3ac23d","a6bfe9de9adef749010c118104b071d14943802ff0614732b47ce4f1c3e383cd","4c3d0e10396646db4a1e917fb852077ee77ae62e512913bef9cccc2bb0f8bd0e","3b220849d58140dcc6718f5b52dcd29fdb79c45bc28f561cbd29eb1cac6cce13","0ee22fce41f7417a24c808d266e91b850629113c104713a35854393d55994beb","22d1b1d965baba05766613e2e6c753bb005d4386c448cafd72c309ba689e8c24",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"2a7d39ea70e483d3ebcde44031b6552940f295349bee8d486e8bdf6380162302","de18acda71730bac52f4b256ce7511bb56cc21f6f114c59c46782eff2f632857","b35c484129671a62dbffdd0716d787923ef43f2f93b7e55528f94cef7e131d74","95b6c669e7ed7c5358c03f8aa24986640f6125ee81bb99e70e9155974f7fd253","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","f7e133b20ee2669b6c0e5d7f0cd510868c57cd64b283e68c7f598e30ce9d76d2","6ba73232c9d3267ca36ddb83e335d474d2c0e167481e3dec416c782894e11438","f7dd7280ee4f0420865e6423fe199aeac63d1d66203a8b631077cdc15501ef1f","ef62b4aa372f77458d84c26614b44129f929e263c81b5cd1034f5828a5530412","8610558ae88a43ad794c4ab1da4f0e8e174e0357c88f6cbb21f523e67414e9a9","0b0feb9837c561c0a67b61024328045bb16bac6e4b10f7b0b217d3b8b43b0b12","d8aab31ba8e618cc3eea10b0945de81cb93b7e8150a013a482332263b9305322","462bccdf75fcafc1ae8c30400c9425e1a4681db5d605d1a0edb4f990a54d8094","5923d8facbac6ecf7c84739a5c701a57af94a6f6648d6229a6c768cf28f0f8cb","7adecb2c3238794c378d336a8182d4c3dd2c4fa6fa1785e2797a3db550edea62","dc12dc0e5aa06f4e1a7692149b78f89116af823b9e1f1e4eae140cd3e0e674e6","1bfc6565b90c8771615cd8cfcf9b36efc0275e5e83ac7d9181307e96eb495161","8a8a96898906f065f296665e411f51010b51372fa260d5373bf9f64356703190","7f82ef88bdb67d9a850dd1c7cd2d690f33e0f0acd208e3c9eba086f3670d4f73","100db324c7664a9a2a4b76d7131fc69dfdf38d24542afc19825d05f401259fab","80b186d68c99a4cc9443cb3cab6eb9a2a136c65a9973ed403761961ca2cd94e6","00e95882237b1f291eb7ed34acf069003d2e6dc977c374f9798d7ad59b4aabbd","45a63e17814c570ea59407f231ef9c561510bd6edb36f17479b09b44619496c6","eb38f5d75ce5b2e143bf9492c8fc181fe7b96354c1661383acda37425b419edf","095b817a5042af7140cc5c6a59d84fe731156193191b4ec39a37d23e526cc653","1f08f4f96b58e7d21b4b64f1d807e4cf04012216a0173c773ac03d9445ecd9c4","889508e69e7e41a02eb678c78169d8ab3b637a9c22f6f53366904a6cf8570a77","2f3ea3c432abd85e91a5a2a67fdba93f2b8408ba21a4dc19ef6c85ca64b0e23e","51655d3b9ed8affa0cdd097ebce4c28febf138c9b24213fde460363a1794db4e",{"version":"5f186a758a616c107c70e8918db4630d063bd782f22e6e0b17573b125765b40b","affectsGlobalScope":true}],"options":{"composite":true,"declarationMap":true,"esModuleInterop":true,"experimentalDecorators":true,"jsx":2,"module":1,"noImplicitOverride":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":5},"fileIdsList":[[106,108],[110,112,114],[107],[108,109,115,116,117],[111],[60],[62],[63],[64,72,73,80,89],[64,65,72,80],[66,99],[67,68,73,81],[68,89],[69,70,72,80],[70],[71,72],[72],[72,73,74,89,98],[73,74],[75,80,89,98],[72,73,75,76,80,89,92,98],[75,77,89,92,98],[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,98,99,100,101,102,103,104,105],[72,78],[79,98],[70,72,80,89],[81],[82],[62,83],[84,94],[85],[86],[72,87],[87,88,99,101],[72,89],[90],[91],[80,92],[93],[80,94],[86,98],[99],[89,100],[101],[102],[72,74,89,98,101,103],[89,104],[50],[50,131],[46,47,48,49],[113],[128],[118,126,127],[119,122],[119,122,123,124],[121],[110,125],[120],[95,96],[51,52,53,54,56,57,58],[50,51,129,130,131,132],[50,56,129,130,131,132],[50,55],[50,59]],"referencedMap":[[109,1],[115,2],[108,3],[118,4],[111,3],[112,5],[60,6],[62,7],[63,8],[64,9],[65,10],[66,11],[67,12],[68,13],[69,14],[70,15],[71,16],[72,17],[73,18],[74,19],[75,20],[76,21],[77,22],[106,23],[78,24],[79,25],[80,26],[81,27],[82,28],[83,29],[84,30],[85,31],[86,32],[87,33],[88,34],[89,35],[90,36],[91,37],[92,38],[93,39],[94,40],[98,41],[99,42],[100,43],[101,44],[102,45],[103,46],[104,47],[130,48],[131,49],[50,50],[114,51],[129,52],[127,52],[128,53],[123,54],[125,55],[124,54],[122,56],[126,57],[121,58],[97,59],[59,60],[133,61],[51,48],[52,48],[53,48],[54,48],[134,62],[56,63],[57,48],[58,48],[135,64],[136,64]],"exportedModulesMap":[[109,1],[115,2],[108,3],[118,4],[111,3],[112,5],[60,6],[62,7],[63,8],[64,9],[65,10],[66,11],[67,12],[68,13],[69,14],[70,15],[71,16],[72,17],[73,18],[74,19],[75,20],[76,21],[77,22],[106,23],[78,24],[79,25],[80,26],[81,27],[82,28],[83,29],[84,30],[85,31],[86,32],[87,33],[88,34],[89,35],[90,36],[91,37],[92,38],[93,39],[94,40],[98,41],[99,42],[100,43],[101,44],[102,45],[103,46],[104,47],[130,48],[131,49],[50,50],[114,51],[129,52],[127,52],[128,53],[123,54],[125,55],[124,54],[122,56],[126,57],[121,58],[97,59],[59,60],[133,61],[51,48],[52,48],[53,48],[54,48],[134,62],[56,63],[57,48],[58,48],[135,64],[136,64]],"semanticDiagnosticsPerFile":[109,115,108,116,117,118,107,111,112,137,60,62,63,64,65,66,67,68,69,70,71,72,73,74,61,105,75,76,77,106,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,98,99,100,101,102,103,104,48,130,131,46,50,49,113,114,110,47,129,127,128,55,119,123,125,124,122,126,121,120,95,96,97,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,44,41,42,43,1,9,45,132,59,133,51,52,53,54,134,56,57,58,135,136]},"version":"4.5.3"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@dxos/react-async",
3
+ "version": "2.28.2",
4
+ "description": "Async utils",
5
+ "license": "MIT",
6
+ "author": "DXOS.org",
7
+ "main": "dist/src/index.js",
8
+ "types": "dist/src/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "src"
12
+ ],
13
+ "devDependencies": {
14
+ "@dxos/esbuild-plugins": "~2.28.4",
15
+ "@dxos/eslint-plugin": "~1.0.27",
16
+ "@dxos/protocols-toolchain": "2.28.4",
17
+ "@types/mocha": "~8.2.2",
18
+ "@types/node": "^14.0.9",
19
+ "@types/react": "^17.0.24",
20
+ "@types/react-dom": "^17.0.9",
21
+ "eslint": "^7.12.1",
22
+ "expect": "~27.0.2",
23
+ "react": "^17.0.2",
24
+ "react-dom": "^17.0.2",
25
+ "typescript": "^4.5.2",
26
+ "wait-for-expect": "^3.0.2"
27
+ },
28
+ "peerDependencies": {
29
+ "react": "*",
30
+ "react-dom": "*"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "toolchain": {
36
+ "forceCloseTests": true,
37
+ "jsdom": true,
38
+ "testingFramework": "mocha"
39
+ },
40
+ "dependencies": {
41
+ "immutability-helper": "^3.0.2"
42
+ },
43
+ "scripts": {
44
+ "book": "toolchain book",
45
+ "build": "toolchain build",
46
+ "build:book": "toolchain build:book",
47
+ "build:test": "toolchain build:test",
48
+ "lint": "toolchain lint",
49
+ "test": "toolchain test"
50
+ },
51
+ "readme": "## React Async\n\n### Configuration\n\nAdd the following to `package.json`.\n\n```json\n \"toolchain\": {\n \"forceCloseTests\": true,\n \"jsdom\": true,\n \"testingFramework\": \"mocha\"\n }\n```\n\nThe `react-dom/test-utils` requires the `raf` (React animation frame) polyfill to run headless.\n\n```ts\nimport 'raf/polyfill';\nimport { act } from 'react-dom/test-utils';\n```\n\n\n### Next\n\nEvaluate the following:\n\n- https://www.npmjs.com/package/react-async-hook (popular)\n- https://www.npmjs.com/package/use-enhanced-state\n- https://www.npmjs.com/package/react-hooks-lib\n"
52
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ export * from './useAsyncEffect';
6
+ export * from './useControlledState';
7
+ export * from './useDynamicRef';
8
+ export * from './useMounted';
9
+ export * from './useStateUpdater';
10
+ export * from './useStateWithRef';
11
+ export * from './useTimestamp';
@@ -0,0 +1,57 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import expect from 'expect';
6
+ import 'raf/polyfill';
7
+ import React, { useState } from 'react';
8
+ import ReactDOM from 'react-dom';
9
+ import { act } from 'react-dom/test-utils';
10
+ import waitForExpect from 'wait-for-expect';
11
+
12
+ import { useAsyncEffect } from './useAsyncEffect';
13
+
14
+ const doAsync = async <T, > (value: T) => {
15
+ return await new Promise<T>((resolve) => {
16
+ resolve(value);
17
+ });
18
+ };
19
+
20
+ const Test = () => {
21
+ const [value, setValue] = useState<string>();
22
+ useAsyncEffect(async (isMounted) => {
23
+ const value = await doAsync('DXOS');
24
+ if (isMounted()) {
25
+ setValue(value);
26
+ }
27
+ }, []);
28
+
29
+ return (
30
+ <h1>{value}</h1>
31
+ );
32
+ };
33
+
34
+ let rootContainer: any;
35
+
36
+ beforeEach(() => {
37
+ rootContainer = document.createElement('div');
38
+ document.body.appendChild(rootContainer);
39
+ });
40
+
41
+ afterEach(() => {
42
+ document.body.removeChild(rootContainer);
43
+ rootContainer = null;
44
+ });
45
+
46
+ describe('useAsyncEffect', () => {
47
+ it('gets async value.', async () => {
48
+ act(() => {
49
+ ReactDOM.render(<Test />, rootContainer);
50
+ });
51
+
52
+ const h1 = rootContainer.querySelector('h1');
53
+ await waitForExpect(() => {
54
+ expect(h1.textContent).toEqual('DXOS');
55
+ });
56
+ });
57
+ });
@@ -0,0 +1,61 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { useEffect } from 'react';
6
+
7
+ /**
8
+ * Process async event with optional non-async destructor.
9
+ * Inspired by: https://github.com/rauldeheer/use-async-effect/blob/master/index.js
10
+ *
11
+ * ```tsx
12
+ * useAsyncEffect(async () => {
13
+ * await test();
14
+ * }, []);
15
+ * ```
16
+ *
17
+ * The callback may check of the component is still mounted before doing state updates.
18
+ *
19
+ * ```tsx
20
+ * const [value, setValue] = useState<string>();
21
+ * useAsyncEffect<string>(async (isMounted) => {
22
+ * const value = await test();
23
+ * if (!isMounted()) {
24
+ * setValue(value);
25
+ * }
26
+ * }, () => console.log('Unmounted'), []);
27
+ * ```
28
+ *
29
+ * @param callback Receives a getter function that determines if the componet is still mounted.
30
+ * @param destructor Receives the value retuned from the callback.
31
+ * @param deps
32
+ */
33
+ // TODO(burdon): Creade useAsyncMemo?
34
+ // TODO(burdon): Replace setImmediate everywhere (approx 30 places).
35
+ export const useAsyncEffect = <T> (
36
+ callback: (isMounted: () => boolean) => Promise<T>,
37
+ destructor?: ((value?: T) => void) | any[],
38
+ deps?: any[]
39
+ ) => {
40
+ const [
41
+ effectDestructor,
42
+ effectDeps
43
+ ] = typeof destructor === 'function' ? [destructor, deps] : [undefined, destructor];
44
+
45
+ useEffect(() => {
46
+ let mounted = true;
47
+
48
+ let value: T;
49
+ const asyncResult = callback(() => mounted);
50
+
51
+ // TODO(burdon): Catch exception.
52
+ void Promise.resolve(asyncResult).then(result => {
53
+ value = result;
54
+ });
55
+
56
+ return () => {
57
+ mounted = false;
58
+ effectDestructor?.(value);
59
+ };
60
+ }, effectDeps);
61
+ };
@@ -0,0 +1,39 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { Dispatch, SetStateAction, useEffect, useState } from 'react';
6
+
7
+ /**
8
+ * Hook that manages state and that can be updated by caller.
9
+ * The optional callback is triggered only if the state is updated internally.
10
+ *
11
+ * ```tsx
12
+ * const Component = ({ value: controlledValue, onChange }: { value: string, onChange: (value:string) => void }) => {
13
+ * const [value, setValue] = useControlledState(controlledValue, onChange);
14
+ * const handleUpdate = (value: string) => setValue(value);
15
+ * }
16
+ *
17
+ * @param controlledValue
18
+ * @param onChange
19
+ * @param deps other deps that may change the state
20
+ */
21
+ export const useControlledState = <T> (
22
+ controlledValue: T,
23
+ onChange?: (value: T) => void,
24
+ deps?: any[]
25
+ ): [T, Dispatch<SetStateAction<T>>] => {
26
+ const [value, setValue] = useState<T>(controlledValue);
27
+ useEffect(() => {
28
+ setValue(controlledValue);
29
+ }, [controlledValue, ...(deps ?? [])]);
30
+
31
+ return [
32
+ value,
33
+ (callback: T | ((previous: T) => T)) => {
34
+ const newValue = (typeof callback === 'function') ? (callback as Function)(value) : callback;
35
+ setValue(newValue);
36
+ onChange?.(newValue);
37
+ }
38
+ ];
39
+ };
@@ -0,0 +1,34 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { RefObject, useEffect, useRef, useState } from 'react';
6
+
7
+ /**
8
+ * Extension of useRef that contains computed values based on dependencies.
9
+ * E.g., to use in callbacks where the state value is stale.
10
+ *
11
+ * ```tsx
12
+ * const valueRef = useDynamicRef<() => value>([value]);
13
+ * const handleAction = () => {
14
+ * console.log(valueRef.current);
15
+ * }
16
+ * ```
17
+ *
18
+ * @param initialValue
19
+ * @param deps
20
+ */
21
+ export const useDynamicRef = <V>(
22
+ initialValue: () => V,
23
+ deps: any[]
24
+ ): RefObject<V> => {
25
+ const [, setValue] = useState<V>(initialValue);
26
+ const ref = useRef<V>(initialValue());
27
+ useEffect(() => {
28
+ ref.current = initialValue();
29
+ // Must update state to trigger render cycle.
30
+ setValue(ref.current);
31
+ }, deps);
32
+
33
+ return ref;
34
+ };
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2022 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useRef } from 'react';
6
+
7
+ /**
8
+ * Provides a function to test if the component is still mounted.
9
+ * Avoids the following error:
10
+ * "Warning: Can't perform a React state update on an unmounted component."
11
+ *
12
+ * ```tsx
13
+ * const Test = () => {
14
+ * const isMounted = useMounted();
15
+ * const [value, setValue] = useState('');
16
+ * useEffect(() => {
17
+ * setTimeout(() => {
18
+ * if (isMounted()) {
19
+ * setValue(value);
20
+ * }
21
+ * }, 1000);
22
+ * }, []);
23
+ *
24
+ * return (
25
+ * <div>{value}</div>
26
+ * );
27
+ * }
28
+ * ```
29
+ */
30
+ export const useMounted = () => {
31
+ const mounted = useRef(false);
32
+ useEffect(() => {
33
+ mounted.current = true;
34
+ return () => {
35
+ mounted.current = false;
36
+ };
37
+ }, []);
38
+
39
+ return () => mounted.current;
40
+ };