@ar.io/wayfinder-react 1.0.6 → 1.0.7-alpha.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/README.md +5 -7
- package/dist/components/wayfinder-provider.js +12 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,13 +38,11 @@ function App() {
|
|
|
38
38
|
<WayfinderProvider
|
|
39
39
|
// pass in the wayfinder options
|
|
40
40
|
// https://github.com/ar-io/wayfinder/tree/alpha/packages/wayfinder-core#custom-configuration
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
sortBy: 'operatorStake',
|
|
47
|
-
}),
|
|
41
|
+
// by default, the provider will cache the gateways in local storage for 1 hour to avoid unnecessary network requests
|
|
42
|
+
gatewaysProvider={new NetworkGatewaysProvider({
|
|
43
|
+
ario: ARIO.mainnet(),
|
|
44
|
+
limit: 10,
|
|
45
|
+
sortBy: 'operatorStake',
|
|
48
46
|
})}
|
|
49
47
|
>
|
|
50
48
|
<YourApp />
|
|
@@ -15,13 +15,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { Wayfinder } from '@ar.io/wayfinder-core';
|
|
18
|
+
import { LocalStorageGatewaysProvider, Wayfinder, } from '@ar.io/wayfinder-core';
|
|
19
19
|
import { createContext, useMemo } from 'react';
|
|
20
20
|
import { WAYFINDER_REACT_VERSION } from '../version.js';
|
|
21
21
|
export const WayfinderContext = createContext(undefined);
|
|
22
22
|
export const WayfinderProvider = ({ children, ...options }) => {
|
|
23
|
+
// wrap the gateways provider in a local storage provider if it is not already
|
|
24
|
+
const gatewaysProvider = useMemo(() => {
|
|
25
|
+
if (options.gatewaysProvider &&
|
|
26
|
+
!(options.gatewaysProvider instanceof LocalStorageGatewaysProvider)) {
|
|
27
|
+
return new LocalStorageGatewaysProvider({
|
|
28
|
+
gatewaysProvider: options.gatewaysProvider,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return options.gatewaysProvider;
|
|
32
|
+
}, [options.gatewaysProvider]);
|
|
23
33
|
const wayfinder = useMemo(() => new Wayfinder({
|
|
24
34
|
...options,
|
|
35
|
+
gatewaysProvider,
|
|
25
36
|
telemetrySettings: {
|
|
26
37
|
enabled: false,
|
|
27
38
|
clientName: 'wayfinder-react',
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ar.io/wayfinder-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7-alpha.1",
|
|
4
4
|
"description": "React components for WayFinder",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"format:check": "biome format --config-path=../../biome.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ar.io/wayfinder-core": "1.0.
|
|
34
|
+
"@ar.io/wayfinder-core": "1.0.5-alpha.1",
|
|
35
35
|
"react": "^18.2.0",
|
|
36
36
|
"react-dom": "^18.2.0"
|
|
37
37
|
},
|