@stryke/hooks 0.4.60 → 0.4.62

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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  # Changelog for Stryke - Hooks
4
4
 
5
+ ## [0.4.61](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.61) (03/02/2026)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.28**
10
+ - Updated **helpers** to **v0.9.45**
11
+ - Updated **types** to **v0.10.42**
12
+ - Updated **env** to **v0.20.63**
13
+
14
+ ## [0.4.60](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.60) (03/02/2026)
15
+
16
+ ### Updated Dependencies
17
+
18
+ - Updated **type-checks** to **v0.5.27**
19
+ - Updated **helpers** to **v0.9.44**
20
+ - Updated **types** to **v0.10.41**
21
+ - Updated **env** to **v0.20.62**
22
+
5
23
  ## [0.4.59](https://github.com/storm-software/stryke/releases/tag/hooks%400.4.59) (03/02/2026)
6
24
 
7
25
  ### Updated Dependencies
@@ -1 +1 @@
1
- {"version":3,"file":"use-memo-stable.d.cts","names":[],"sources":["../src/use-memo-stable.ts"],"sourcesContent":[],"mappings":";;AAgEA;;;;;;;;;;;;;iBAAgB,wCACG,0BAEhB"}
1
+ {"version":3,"file":"use-memo-stable.d.cts","names":[],"sources":["../src/use-memo-stable.ts"],"sourcesContent":[],"mappings":";;AA6DA;;;;;;;;;;;;;iBAAgB,wCACG,0BAEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-memo-stable.d.mts","names":[],"sources":["../src/use-memo-stable.ts"],"sourcesContent":[],"mappings":";;AAgEA;;;;;;;;;;;;;iBAAgB,wCACG,0BAEhB"}
1
+ {"version":3,"file":"use-memo-stable.d.mts","names":[],"sources":["../src/use-memo-stable.ts"],"sourcesContent":[],"mappings":";;AA6DA;;;;;;;;;;;;;iBAAgB,wCACG,0BAEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-memo-stable.mjs","names":["initial: Cache<TResult>","useCache: boolean","cache: Cache<TResult>"],"sources":["../src/use-memo-stable.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n/* eslint-disable @cspell/spellchecker */\n\n/**\n\n * Forked from use-memo-one by Alex Reardon\n */\n\ninterface Cache<TData> {\n inputs?: any[];\n result: TData;\n}\n\nconst areInputsEqual = (newInputs: any[], lastInputs: any[]) => {\n // no checks needed if the inputs length has changed\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n // Using for loop for speed. It generally performs better than array.every\n // https://github.com/alexreardon/memoize-one/pull/59\n\n for (const [i, newInput] of newInputs.entries()) {\n // using shallow equality check\n if (newInput !== lastInputs[i]) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * `useMemo` and `useCallback` cache the most recent result. However, this cache can be destroyed by React when it wants to.\n *\n * `useMemoStable` and `useCallbackStable` are concurrent mode safe alternatives to `useMemo` and `useCallback` that do provide semantic guarantee. What this means is that you will always get the same reference for a memoized value so long as there is no input change.\n *\n * Using `useMemoStable` and `useCallbackStable` will consume more memory than useMemo and `useCallback` in order to provide a stable cache. React can release the cache of `useMemo` and `useCallback`, but `useMemoStable` will not release the cache until it is garbage collected.\n *\n * @remarks\n * You may rely on useMemo as a performance optimization, not as a semantic guarantee. In the future, React may choose to “forget” some previously memoized values and recalculate them on next render, e.g. to free memory for offscreen components. Write your code so that it still works without `useMemo` — and then add it to optimize performance.\n *\n * @param getResult - The function used to generate the result\n * @param inputs - The inputs to watch for changes\n * @returns The memoized result\n */\nexport function useMemoStable<TResult>(\n getResult: () => TResult,\n inputs?: any[]\n): TResult {\n // using useState to generate initial value as it is lazy\n const initial: Cache<TResult> = useState(() => ({\n inputs,\n result: getResult()\n }))[0];\n const isFirstRun = useRef<boolean>(true);\n const committed = useRef<Cache<TResult>>(initial);\n\n // persist any uncommitted changes after they have been committed\n const useCache: boolean =\n isFirstRun.current ||\n Boolean(\n inputs &&\n committed.current.inputs &&\n areInputsEqual(inputs, committed.current.inputs)\n );\n\n // create a new cache if required\n const cache: Cache<TResult> = useMemo(\n () =>\n useCache\n ? committed.current\n : {\n inputs,\n result: getResult()\n },\n [inputs, getResult, useCache]\n );\n\n // commit the cache\n useEffect(() => {\n isFirstRun.current = false;\n committed.current = cache;\n }, [cache]);\n\n return cache.result;\n}\n"],"mappings":";;;AAgCA,MAAM,kBAAkB,WAAkB,eAAsB;AAE9D,KAAI,UAAU,WAAW,WAAW,OAClC,QAAO;AAKT,MAAK,MAAM,CAAC,GAAG,aAAa,UAAU,SAAS,CAE7C,KAAI,aAAa,WAAW,GAC1B,QAAO;AAIX,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,cACd,WACA,QACS;CAET,MAAMA,UAA0B,gBAAgB;EAC9C;EACA,QAAQ,WAAW;EACpB,EAAE,CAAC;CACJ,MAAM,aAAa,OAAgB,KAAK;CACxC,MAAM,YAAY,OAAuB,QAAQ;CAGjD,MAAMC,WACJ,WAAW,WACX,QACE,UACA,UAAU,QAAQ,UAClB,eAAe,QAAQ,UAAU,QAAQ,OAAO,CACjD;CAGH,MAAMC,QAAwB,cAE1B,WACI,UAAU,UACV;EACE;EACA,QAAQ,WAAW;EACpB,EACP;EAAC;EAAQ;EAAW;EAAS,CAC9B;AAGD,iBAAgB;AACd,aAAW,UAAU;AACrB,YAAU,UAAU;IACnB,CAAC,MAAM,CAAC;AAEX,QAAO,MAAM"}
1
+ {"version":3,"file":"use-memo-stable.mjs","names":["initial: Cache<TResult>","useCache: boolean","cache: Cache<TResult>"],"sources":["../src/use-memo-stable.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\n/**\n * Forked from use-memo-one by Alex Reardon\n */\n\ninterface Cache<TData> {\n inputs?: any[];\n result: TData;\n}\n\nconst areInputsEqual = (newInputs: any[], lastInputs: any[]) => {\n // no checks needed if the inputs length has changed\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n // Using for loop for speed. It generally performs better than array.every\n // https://github.com/alexreardon/memoize-one/pull/59\n\n for (const [i, newInput] of newInputs.entries()) {\n // using shallow equality check\n if (newInput !== lastInputs[i]) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * `useMemo` and `useCallback` cache the most recent result. However, this cache can be destroyed by React when it wants to.\n *\n * `useMemoStable` and `useCallbackStable` are concurrent mode safe alternatives to `useMemo` and `useCallback` that do provide semantic guarantee. What this means is that you will always get the same reference for a memoized value so long as there is no input change.\n *\n * Using `useMemoStable` and `useCallbackStable` will consume more memory than useMemo and `useCallback` in order to provide a stable cache. React can release the cache of `useMemo` and `useCallback`, but `useMemoStable` will not release the cache until it is garbage collected.\n *\n * @remarks\n * You may rely on useMemo as a performance optimization, not as a semantic guarantee. In the future, React may choose to “forget” some previously memoized values and recalculate them on next render, e.g. to free memory for offscreen components. Write your code so that it still works without `useMemo` — and then add it to optimize performance.\n *\n * @param getResult - The function used to generate the result\n * @param inputs - The inputs to watch for changes\n * @returns The memoized result\n */\nexport function useMemoStable<TResult>(\n getResult: () => TResult,\n inputs?: any[]\n): TResult {\n // using useState to generate initial value as it is lazy\n const initial: Cache<TResult> = useState(() => ({\n inputs,\n result: getResult()\n }))[0];\n const isFirstRun = useRef<boolean>(true);\n const committed = useRef<Cache<TResult>>(initial);\n\n // persist any uncommitted changes after they have been committed\n const useCache: boolean =\n isFirstRun.current ||\n Boolean(\n inputs &&\n committed.current.inputs &&\n areInputsEqual(inputs, committed.current.inputs)\n );\n\n // create a new cache if required\n const cache: Cache<TResult> = useMemo(\n () =>\n useCache\n ? committed.current\n : {\n inputs,\n result: getResult()\n },\n [inputs, getResult, useCache]\n );\n\n // commit the cache\n useEffect(() => {\n isFirstRun.current = false;\n committed.current = cache;\n }, [cache]);\n\n return cache.result;\n}\n"],"mappings":";;;AA6BA,MAAM,kBAAkB,WAAkB,eAAsB;AAE9D,KAAI,UAAU,WAAW,WAAW,OAClC,QAAO;AAKT,MAAK,MAAM,CAAC,GAAG,aAAa,UAAU,SAAS,CAE7C,KAAI,aAAa,WAAW,GAC1B,QAAO;AAIX,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,cACd,WACA,QACS;CAET,MAAMA,UAA0B,gBAAgB;EAC9C;EACA,QAAQ,WAAW;EACpB,EAAE,CAAC;CACJ,MAAM,aAAa,OAAgB,KAAK;CACxC,MAAM,YAAY,OAAuB,QAAQ;CAGjD,MAAMC,WACJ,WAAW,WACX,QACE,UACA,UAAU,QAAQ,UAClB,eAAe,QAAQ,UAAU,QAAQ,OAAO,CACjD;CAGH,MAAMC,QAAwB,cAE1B,WACI,UAAU,UACV;EACE;EACA,QAAQ,WAAW;EACpB,EACP;EAAC;EAAQ;EAAW;EAAS,CAC9B;AAGD,iBAAgB;AACd,aAAW,UAAU;AACrB,YAAU,UAAU;IACnB,CAAC,MAAM,CAAC;AAEX,QAAO,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/hooks",
3
- "version": "0.4.60",
3
+ "version": "0.4.62",
4
4
  "type": "module",
5
5
  "description": "A package containing shared hooks that can be used in any React UI project",
6
6
  "repository": {
@@ -106,5 +106,5 @@
106
106
  "tsdown": "^0.17.2"
107
107
  },
108
108
  "publishConfig": { "access": "public" },
109
- "gitHead": "7755bd92180cadaa0ef8168e4e123deaacc4ccb8"
109
+ "gitHead": "b8125bf046febc1991df62777827d0481c2c89c0"
110
110
  }