@uniflowed/hooks 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser.js CHANGED
@@ -55,7 +55,7 @@
55
55
  // | `usePermission` | `"unknown"` | what the browser answers |
56
56
  // | `useScrollLock` | nothing at all — effects do not run in a prerender | the page is held |
57
57
  //
58
- // `packages/hooks/hooks-ssr.test.js` renders every one of them in a process with
58
+ // `npm/hooks/hooks-ssr.test.js` renders every one of them in a process with
59
59
  // no document and asserts the markup, so a row of this table that stopped being
60
60
  // true would fail there rather than in somebody's browser.
61
61
  //
package/index.js CHANGED
@@ -111,8 +111,8 @@
111
111
  // cross-tab sync;
112
112
  // broadcast channels; the clipboard; a server-sent event stream, including the
113
113
  // one case the platform's own reconnection gives up on; the render anchor and
114
- // the seeded stream in `render.js`. `packages/hooks/hooks.test.js` covers
115
- // behaviour and cleanup, and `packages/hooks/hooks-ssr.test.js` renders the
114
+ // the seeded stream in `render.js`. `npm/hooks/hooks.test.js` covers
115
+ // behaviour and cleanup, and `npm/hooks/hooks-ssr.test.js` renders the
116
116
  // whole surface in a process that has no DOM at all.
117
117
  //
118
118
  // **Experimental.** `useGeolocation`, `useNetwork` and `usePermission`. The
package/lifecycle.js CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  useEffect,
29
29
  useInsertionEffect,
30
30
  useLayoutEffect,
31
+ useMemo,
31
32
  useRef,
32
33
  useState,
33
34
  } from "@uniflowed/react";
@@ -61,7 +62,14 @@ export hook useStableCallback<TArgs extends $ReadOnlyArray<mixed>, TReturn>(
61
62
  latest.current = callback;
62
63
  }, [callback]);
63
64
 
64
- return useCallback((...args: TArgs) => latest.current(...args), []);
65
+ // `useMemo` over a function rather than `useCallback`: the same cache, and
66
+ // `useCallback`'s bound cannot hold a function generic in its arguments.
67
+ return useMemo(
68
+ () =>
69
+ (...args: TArgs) =>
70
+ latest.current(...args),
71
+ [],
72
+ );
65
73
  }
66
74
 
67
75
  /** The value from the previous render, or `undefined` on the first. */
@@ -72,8 +80,10 @@ export hook usePrevious<T>(value: T): T | void {
72
80
  }, [value]);
73
81
  // This hook's public value is the last committed render; reading the ref
74
82
  // during render is the contract rather than hidden reactive input.
75
- // uf-lint-disable-next-line react-compiler/refs
83
+ // uf-lint-disable react-compiler/refs
84
+ // $FlowExpectedError[react-rule-unsafe-ref] the same deliberate read, as Flow's React rules see it.
76
85
  return previous.current;
86
+ // uf-lint-enable react-compiler/refs
77
87
  }
78
88
 
79
89
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/hooks",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "The React hooks an application writes anyway, prerender-safe, part of the Unified Toolchain for Flow.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/ubugeeei-prod/uf.git",
11
- "directory": "packages/hooks"
11
+ "directory": "npm/hooks"
12
12
  },
13
13
  "exports": {
14
14
  ".": "./index.js",
@@ -28,8 +28,8 @@
28
28
  "!*.test.js"
29
29
  ],
30
30
  "dependencies": {
31
- "@uniflowed/core": "0.9.0",
32
- "@uniflowed/react": "0.9.0"
31
+ "@uniflowed/core": "0.11.0",
32
+ "@uniflowed/react": "0.11.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=19"
package/render.js CHANGED
@@ -77,7 +77,7 @@
77
77
  // the price of the guarantee rather than an oversight. A render that has to be
78
78
  // reproducible fixes `at` and `seed` itself, which is what those two props are
79
79
  // for; `gives the same document however the host takes it` in
80
- // `packages/router/streaming.test.js` is a test that compares two renders and says
80
+ // `npm/router/streaming.test.js` is a test that compares two renders and says
81
81
  // so.
82
82
  //
83
83
  // # What belongs in this module
package/state.js CHANGED
@@ -396,7 +396,7 @@ function announce(key: string): void {
396
396
  * # Why this guard is written twice
397
397
  *
398
398
  * `@uniflowed/state`'s `createJSONStorage`
399
- * (`packages/state/internal/composed.js`) guards the same four hazards — a
399
+ * (`npm/state/internal/composed.js`) guards the same four hazards — a
400
400
  * storage property that throws, a read that throws, a write that throws, and
401
401
  * finding the object a `storage` event arrives on — and reaches the same
402
402
  * conclusions about each. Merging the two was considered and declined;