@dxos/react-client 2.29.2-dev.f64f2a6f → 2.29.2-dev.f6ed60b8
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/.rush/temp/package-deps_build.json +6 -9
- package/.rush/temp/package-deps_build:test.json +6 -9
- package/.rush/temp/package-deps_prerelease.json +6 -9
- package/.rush/temp/shrinkwrap-deps.json +1 -73
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +0 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/invitations/useHaloInvitations.d.ts.map +1 -1
- package/dist/src/hooks/invitations/useHaloInvitations.js.map +1 -1
- package/dist/src/hooks/invitations/useInvitations.d.ts.map +1 -1
- package/dist/src/hooks/invitations/useInvitations.js.map +1 -1
- package/dist/src/hooks/invitations/usePartyInvitations.d.ts.map +1 -1
- package/dist/src/hooks/invitations/usePartyInvitations.js +2 -1
- package/dist/src/hooks/invitations/usePartyInvitations.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -24
- package/src/hooks/index.ts +0 -1
- package/src/hooks/invitations/useHaloInvitations.ts +2 -2
- package/src/hooks/invitations/useInvitations.ts +0 -1
- package/src/hooks/invitations/usePartyInvitations.ts +2 -1
- package/dist/src/hooks/ipfs/index.d.ts +0 -3
- package/dist/src/hooks/ipfs/index.d.ts.map +0 -1
- package/dist/src/hooks/ipfs/index.js +0 -18
- package/dist/src/hooks/ipfs/index.js.map +0 -1
- package/dist/src/hooks/ipfs/useIpfsClient.d.ts +0 -17
- package/dist/src/hooks/ipfs/useIpfsClient.d.ts.map +0 -1
- package/dist/src/hooks/ipfs/useIpfsClient.js +0 -41
- package/dist/src/hooks/ipfs/useIpfsClient.js.map +0 -1
- package/dist/src/hooks/ipfs/useIpfsFiles.d.ts +0 -19
- package/dist/src/hooks/ipfs/useIpfsFiles.d.ts.map +0 -1
- package/dist/src/hooks/ipfs/useIpfsFiles.js +0 -48
- package/dist/src/hooks/ipfs/useIpfsFiles.js.map +0 -1
- package/dxos-react-client-2.29.2-dev.f64f2a6f.tgz +0 -0
- package/out/book/esbuild-server-book.js +0 -216179
- package/out/book/index.html +0 -14
- package/src/hooks/ipfs/index.ts +0 -6
- package/src/hooks/ipfs/useIpfsClient.ts +0 -36
- package/src/hooks/ipfs/useIpfsFiles.ts +0 -59
package/out/book/index.html
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<link rel="stylesheet" href="esbuild-server-book.css">
|
|
8
|
-
<title>ESBuild-Server Book</title>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<div id='root'></div>
|
|
12
|
-
<script src='esbuild-server-book.js'></script>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
package/src/hooks/ipfs/index.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { CID, create } from 'ipfs-http-client';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { useMemo } from 'react';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Return URL to IPFS resource on local gateway.
|
|
11
|
-
* @param gateway
|
|
12
|
-
* @param cid
|
|
13
|
-
* @param filename
|
|
14
|
-
*/
|
|
15
|
-
export const getIpfsUrl = (gateway: string, cid: CID, filename?: string) => {
|
|
16
|
-
const args = filename ? [`filename=${encodeURI(filename)}`] : [];
|
|
17
|
-
return path.join(gateway, String(cid), '?', args.join('&'));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* https://www.npmjs.com/package/ipfs-http-client#example
|
|
22
|
-
* NOTE: We need to run our own servers to enable CORS.
|
|
23
|
-
* Ports
|
|
24
|
-
* - 8001 Gateway
|
|
25
|
-
* - 5001 API
|
|
26
|
-
*/
|
|
27
|
-
// TODO(kaplanski): Factor out IPFS related functionality to its own package.
|
|
28
|
-
export const useIpfsClient = (url?: string) => {
|
|
29
|
-
return useMemo(() => {
|
|
30
|
-
if (!url) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return create({ url });
|
|
35
|
-
}, [url]);
|
|
36
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { CID, IPFSHTTPClient } from 'ipfs-http-client';
|
|
6
|
-
import { useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Party } from '@dxos/client';
|
|
9
|
-
|
|
10
|
-
import { useSelection } from '../echo-selections';
|
|
11
|
-
|
|
12
|
-
export type IPFSFile = {
|
|
13
|
-
filename?: string
|
|
14
|
-
cid: CID
|
|
15
|
-
size?: number
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns a list of mapped IPFS files.
|
|
20
|
-
* @param party
|
|
21
|
-
* @param type
|
|
22
|
-
*/
|
|
23
|
-
export const useIpfsFiles = (party: Party | undefined, type: string) => {
|
|
24
|
-
// TODO(burdon): Schema definitions for types?
|
|
25
|
-
// TODO(burdon): Use reducer to do mapping?
|
|
26
|
-
const items = useSelection(party?.select().filter({ type }));
|
|
27
|
-
|
|
28
|
-
const files: IPFSFile[] = useMemo(() => items?.map(item => ({
|
|
29
|
-
filename: item.model.getProperty('filename'),
|
|
30
|
-
cid: item.model.getProperty('cid'),
|
|
31
|
-
size: item.model.getProperty('size')
|
|
32
|
-
})), [items]) ?? [];
|
|
33
|
-
|
|
34
|
-
return files;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// TODO(wittjosiah): This is not returning IPFSFiles.
|
|
38
|
-
export const uploadFilesToIpfs = async (
|
|
39
|
-
ipfsClient: IPFSHTTPClient,
|
|
40
|
-
files: File[],
|
|
41
|
-
onError?: (error: Error) => void
|
|
42
|
-
) => {
|
|
43
|
-
return await Promise.all(files.map(async (file) => {
|
|
44
|
-
// https://docs.ipfs.io/reference/js/api
|
|
45
|
-
// https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client
|
|
46
|
-
try {
|
|
47
|
-
const { cid, path, size } = await ipfsClient.add(file);
|
|
48
|
-
await ipfsClient.pin.add(cid);
|
|
49
|
-
// TODO(kaplanski): path is CID v0. cid is CID v1. Current default is v0, but will be updated to v1 in the future. We'll need to update to support v1.
|
|
50
|
-
return {
|
|
51
|
-
cid: path,
|
|
52
|
-
size,
|
|
53
|
-
filename: file.name
|
|
54
|
-
};
|
|
55
|
-
} catch (err) {
|
|
56
|
-
onError?.(err instanceof Error ? err : new Error(err as string)); // TODO(burdon): Generalize.
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
};
|