@ahoo-wang/fetcher-react 1.3.2 → 1.8.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.
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import { useSyncExternalStore as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useCallback as n, useSyncExternalStore as r } from "react";
|
|
2
|
+
function l(s) {
|
|
3
|
+
const e = n(
|
|
4
|
+
(t) => s.addListener(t),
|
|
5
|
+
[s]
|
|
6
|
+
), c = n(
|
|
7
|
+
() => s.get(),
|
|
8
|
+
[s]
|
|
9
|
+
), o = r(
|
|
10
|
+
e,
|
|
11
|
+
c,
|
|
12
|
+
c
|
|
13
|
+
), u = n(
|
|
14
|
+
(t) => s.set(t),
|
|
15
|
+
[s]
|
|
16
|
+
);
|
|
17
|
+
return [o, u];
|
|
8
18
|
}
|
|
9
19
|
export {
|
|
10
|
-
|
|
20
|
+
l as useKeyStorage
|
|
11
21
|
};
|
|
12
22
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/storage/useKeyStorage.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useSyncExternalStore } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\n\n/**\n * A React hook that provides state management for a KeyStorage instance.\n * Subscribes to storage changes and returns the current value along with a setter function.\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage\n * @returns A tuple containing the current stored value and a function to update it\n */\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (value: T) => void] {\n const
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/storage/useKeyStorage.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\n\n/**\n * A React hook that provides state management for a KeyStorage instance.\n * Subscribes to storage changes and returns the current value along with a setter function.\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage\n * @returns A tuple containing the current stored value and a function to update it\n */\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (value: T) => void] {\n const subscribe = useCallback(\n (callback: () => void) => keyStorage.addListener(callback),\n [keyStorage],\n );\n const getSnapshot = useCallback(\n () => keyStorage.get(),\n [keyStorage],\n );\n const store = useSyncExternalStore(\n subscribe,\n getSnapshot,\n getSnapshot,\n );\n const setValue = useCallback(\n (value: T) => keyStorage.set(value),\n [keyStorage],\n );\n return [store, setValue];\n}"],"names":["useKeyStorage","keyStorage","subscribe","useCallback","callback","getSnapshot","store","useSyncExternalStore","setValue","value"],"mappings":";AAwBO,SAASA,EACdC,GACgC;AAChC,QAAMC,IAAYC;AAAA,IAChB,CAACC,MAAyBH,EAAW,YAAYG,CAAQ;AAAA,IACzD,CAACH,CAAU;AAAA,EAAA,GAEPI,IAAcF;AAAA,IAClB,MAAMF,EAAW,IAAA;AAAA,IACjB,CAACA,CAAU;AAAA,EAAA,GAEPK,IAAQC;AAAA,IACZL;AAAA,IACAG;AAAA,IACAA;AAAA,EAAA,GAEIG,IAAWL;AAAA,IACf,CAACM,MAAaR,EAAW,IAAIQ,CAAK;AAAA,IAClC,CAACR,CAAU;AAAA,EAAA;AAEb,SAAO,CAACK,GAAOE,CAAQ;AACzB;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.FetcherReact={},t.React))})(this,(function(t,e){"use strict";function i(n){const o=e.useCallback(s=>n.addListener(s),[n]),u=e.useCallback(()=>n.get(),[n]),c=e.useSyncExternalStore(o,u,u),d=e.useCallback(s=>n.set(s),[n]);return[c,d]}t.useKeyStorage=i,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/storage/useKeyStorage.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useSyncExternalStore } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\n\n/**\n * A React hook that provides state management for a KeyStorage instance.\n * Subscribes to storage changes and returns the current value along with a setter function.\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage\n * @returns A tuple containing the current stored value and a function to update it\n */\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (value: T) => void] {\n const
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/storage/useKeyStorage.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useSyncExternalStore } from 'react';\nimport { KeyStorage } from '@ahoo-wang/fetcher-storage';\n\n/**\n * A React hook that provides state management for a KeyStorage instance.\n * Subscribes to storage changes and returns the current value along with a setter function.\n *\n * @template T - The type of value stored in the key storage\n * @param keyStorage - The KeyStorage instance to subscribe to and manage\n * @returns A tuple containing the current stored value and a function to update it\n */\nexport function useKeyStorage<T>(\n keyStorage: KeyStorage<T>,\n): [T | null, (value: T) => void] {\n const subscribe = useCallback(\n (callback: () => void) => keyStorage.addListener(callback),\n [keyStorage],\n );\n const getSnapshot = useCallback(\n () => keyStorage.get(),\n [keyStorage],\n );\n const store = useSyncExternalStore(\n subscribe,\n getSnapshot,\n getSnapshot,\n );\n const setValue = useCallback(\n (value: T) => keyStorage.set(value),\n [keyStorage],\n );\n return [store, setValue];\n}"],"names":["useKeyStorage","keyStorage","subscribe","useCallback","callback","getSnapshot","store","useSyncExternalStore","setValue","value"],"mappings":"wQAwBO,SAASA,EACdC,EACgC,CAChC,MAAMC,EAAYC,EAAAA,YACfC,GAAyBH,EAAW,YAAYG,CAAQ,EACzD,CAACH,CAAU,CAAA,EAEPI,EAAcF,EAAAA,YAClB,IAAMF,EAAW,IAAA,EACjB,CAACA,CAAU,CAAA,EAEPK,EAAQC,EAAAA,qBACZL,EACAG,EACAA,CAAA,EAEIG,EAAWL,EAAAA,YACdM,GAAaR,EAAW,IAAIQ,CAAK,EAClC,CAACR,CAAU,CAAA,EAEb,MAAO,CAACK,EAAOE,CAAQ,CACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyStorage.d.ts","sourceRoot":"","sources":["../../src/storage/useKeyStorage.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"useKeyStorage.d.ts","sourceRoot":"","sources":["../../src/storage/useKeyStorage.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAmBhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "React integration for Fetcher HTTP client. Provides React Hooks and components for seamless data fetching with automatic re-rendering and loading states.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ahoo-wang/fetcher": "1.8.
|
|
41
|
-
"@ahoo-wang/fetcher-storage": "1.8.
|
|
40
|
+
"@ahoo-wang/fetcher": "1.8.1",
|
|
41
|
+
"@ahoo-wang/fetcher-storage": "1.8.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.8.0",
|