@pelicanplatform/components 1.0.12 → 1.0.15
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/AuthenticatedClient/AuthenticatedClient.js +1 -1
- package/dist/AuthenticatedClient/AuthenticatedClient.js.map +1 -1
- package/dist/Client/Client.js +1 -1
- package/dist/Client/Client.js.map +1 -1
- package/dist/PublicClient/PublicClient.js +1 -1
- package/dist/PublicClient/PublicClient.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/CollectionShortcuts/CollectionShortcuts.d.ts +0 -13
- package/dist/CollectionShortcuts/CollectionShortcuts.d.ts.map +0 -1
- package/dist/CollectionShortcuts/CollectionShortcuts.js +0 -22
- package/dist/CollectionShortcuts/CollectionShortcuts.js.map +0 -1
- package/dist/CollectionShortcuts/index.d.ts +0 -3
- package/dist/CollectionShortcuts/index.d.ts.map +0 -1
- package/dist/CollectionShortcuts/index.js +0 -3
- package/dist/CollectionShortcuts/index.js.map +0 -1
- package/dist/PelicanClientProvider/PelicanClientContext.d.ts +0 -27
- package/dist/PelicanClientProvider/PelicanClientContext.d.ts.map +0 -1
- package/dist/PelicanClientProvider/PelicanClientContext.js +0 -4
- package/dist/PelicanClientProvider/PelicanClientContext.js.map +0 -1
- package/dist/PelicanClientProvider/PelicanClientProvider.d.ts +0 -15
- package/dist/PelicanClientProvider/PelicanClientProvider.d.ts.map +0 -1
- package/dist/PelicanClientProvider/PelicanClientProvider.js +0 -383
- package/dist/PelicanClientProvider/PelicanClientProvider.js.map +0 -1
- package/dist/PelicanClientProvider/index.d.ts +0 -6
- package/dist/PelicanClientProvider/index.d.ts.map +0 -1
- package/dist/PelicanClientProvider/index.js +0 -4
- package/dist/PelicanClientProvider/index.js.map +0 -1
- package/dist/PelicanClientProvider/usePelicanClient.d.ts +0 -21
- package/dist/PelicanClientProvider/usePelicanClient.d.ts.map +0 -1
- package/dist/PelicanClientProvider/usePelicanClient.js +0 -29
- package/dist/PelicanClientProvider/usePelicanClient.js.map +0 -1
- package/dist/README.md +0 -0
- package/dist/package.json +0 -49
- package/dist/usePelicanClient/index.d.ts +0 -3
- package/dist/usePelicanClient/index.d.ts.map +0 -1
- package/dist/usePelicanClient/index.js +0 -3
- package/dist/usePelicanClient/index.js.map +0 -1
- package/dist/usePelicanClient/useAuthExchange.d.ts +0 -41
- package/dist/usePelicanClient/useAuthExchange.d.ts.map +0 -1
- package/dist/usePelicanClient/useAuthExchange.js +0 -88
- package/dist/usePelicanClient/useAuthExchange.js.map +0 -1
- package/dist/usePelicanClient/useCodeVerifier.d.ts +0 -12
- package/dist/usePelicanClient/useCodeVerifier.d.ts.map +0 -1
- package/dist/usePelicanClient/useCodeVerifier.js +0 -37
- package/dist/usePelicanClient/useCodeVerifier.js.map +0 -1
- package/dist/usePelicanClient/useEventCallback.d.ts +0 -18
- package/dist/usePelicanClient/useEventCallback.d.ts.map +0 -1
- package/dist/usePelicanClient/useEventCallback.js +0 -12
- package/dist/usePelicanClient/useEventCallback.js.map +0 -1
- package/dist/usePelicanClient/useEventListener.d.ts +0 -7
- package/dist/usePelicanClient/useEventListener.d.ts.map +0 -1
- package/dist/usePelicanClient/useEventListener.js +0 -57
- package/dist/usePelicanClient/useEventListener.js.map +0 -1
- package/dist/usePelicanClient/useIsomorphicLayoutEffect.d.ts +0 -16
- package/dist/usePelicanClient/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/dist/usePelicanClient/useIsomorphicLayoutEffect.js +0 -16
- package/dist/usePelicanClient/useIsomorphicLayoutEffect.js.map +0 -1
- package/dist/usePelicanClient/usePelicanClient.d.ts +0 -27
- package/dist/usePelicanClient/usePelicanClient.d.ts.map +0 -1
- package/dist/usePelicanClient/usePelicanClient.js +0 -245
- package/dist/usePelicanClient/usePelicanClient.js.map +0 -1
- package/dist/usePelicanClient/useSessionStorage.d.ts +0 -39
- package/dist/usePelicanClient/useSessionStorage.d.ts.map +0 -1
- package/dist/usePelicanClient/useSessionStorage.js +0 -121
- package/dist/usePelicanClient/useSessionStorage.js.map +0 -1
- package/dist/usePelicanClient/util.d.ts +0 -1
- package/dist/usePelicanClient/util.d.ts.map +0 -1
- package/dist/usePelicanClient/util.js +0 -2
- package/dist/usePelicanClient/util.js.map +0 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Alert, Badge, Box, IconButton, Paper, Skeleton, Snackbar } from "@mui/material";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
-
import { usePelicanClient } from "../PelicanClientProvider";
|
|
6
5
|
import ClientMetadata from "../ClientMetadata";
|
|
7
6
|
import ObjectUpload from "../ObjectUpload";
|
|
8
7
|
import ObjectView from "../ObjectView";
|
|
@@ -10,6 +9,7 @@ import CollectionView from "../CollectionView";
|
|
|
10
9
|
import { parseObjectUrl } from "@pelicanplatform/web-client";
|
|
11
10
|
import { UploadFile, List, CreateNewFolderOutlined } from "@mui/icons-material";
|
|
12
11
|
import AddCollectionButton from "../AddCollectionButton";
|
|
12
|
+
import { usePelicanClient } from "@pelicanplatform/hooks";
|
|
13
13
|
/**
|
|
14
14
|
* Inner component that uses the context
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticatedClient.js","sourceRoot":"","sources":["../../src/AuthenticatedClient/AuthenticatedClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAExE,OAAO,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,CAAC,YAED,KAAC,KAAK,IAAC,QAAQ,EAAC,OAAO,YACpB,KAAK,GACA,GACC,IACP,GACF,CACP,CAAC;AACJ,CAAC;AAED,eAAe,mBAAmB,CAAC"}
|
package/dist/Client/Client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import AuthenticatedClient from "../AuthenticatedClient";
|
|
4
4
|
import PublicClient from "../PublicClient";
|
|
5
|
-
import { PelicanClientProvider } from "
|
|
5
|
+
import { PelicanClientProvider } from "@pelicanplatform/hooks";
|
|
6
6
|
/**
|
|
7
7
|
* A Pelican web-client, which can be either authenticated or public based on props
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/Client/Client.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/Client/Client.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AAS7D;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,KAAkB,EAAE,EAAE;IACpC,OAAO,CACL,KAAC,qBAAqB,IAAC,gBAAgB,EAAE,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,YACnF,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,KAAC,mBAAmB,KAAG,CAAC,CAAC,CAAC,KAAC,YAAY,KAAG,GACxC,CACzB,CAAA;AACH,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { Box } from "@mui/material";
|
|
4
|
-
import { usePelicanClient } from "../PelicanClientProvider";
|
|
5
4
|
import { useEffect, useMemo, useState } from "react";
|
|
6
5
|
import { parseObjectUrl } from "@pelicanplatform/web-client";
|
|
6
|
+
import { usePelicanClient } from "@pelicanplatform/hooks";
|
|
7
7
|
/**
|
|
8
8
|
* A public Pelican client, with authentication features disabled.
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicClient.js","sourceRoot":"","sources":["../../src/PublicClient/PublicClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"PublicClient.js","sourceRoot":"","sources":["../../src/PublicClient/PublicClient.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAa,cAAc,EAAC,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAGxD;;GAEG;AACH,SAAS,YAAY;IAEnB,MAAM,EACJ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACT,aAAa,EACd,GAAG,gBAAgB,EAAE,CAAC;IAEvB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAe,EAAE,CAAC,CAAC;IAE/D,MAAM,gBAAgB,GAAG,KAAK,EAAE,CAAS,EAAE,EAAE;QAC3C,aAAa,CAAC,MAAM,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAA;IAED,2CAA2C;IAC3C,SAAS,CAAC,GAAG,EAAE;QACb,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,2CAA2C;QAC3C,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,EAAC,UAAU,EAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;YAC/C,OAAO,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACjD,CAAC;QAAC,WAAM,CAAC,CAAA,CAAC;IACZ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,KAAC,GAAG,uBAEE,CACP,CAAC;AACJ,CAAC;AAED,eAAe,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "
|
|
1
|
+
// Re-export all components and hooks from the respective packages
|
|
2
|
+
export * from "@pelicanplatform/hooks";
|
|
3
3
|
export { default as AuthenticatedClient } from "./AuthenticatedClient";
|
|
4
|
-
export { default } from "./Client";
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pelicanplatform/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"homepage": "https://pelicanplatform.org",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@mui/icons-material": "^7.0.0",
|
|
27
|
-
"@pelicanplatform/web-client": "1.0.22"
|
|
27
|
+
"@pelicanplatform/web-client": "1.0.22",
|
|
28
|
+
"@pelicanplatform/hooks": "1.0.0"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"@emotion/react": "^11.0.0",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Collection } from "../usePelicanClient";
|
|
2
|
-
interface CollectionShortcutsProps {
|
|
3
|
-
/** List of shortcut collections */
|
|
4
|
-
collections: Collection[];
|
|
5
|
-
/** Callback when a shortcut is clicked */
|
|
6
|
-
onClick: (favorite: string) => void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* A sidebar element to view a list of provided shortcuts, used for the user's authenticated routes.
|
|
10
|
-
*/
|
|
11
|
-
declare function CollectionShortcuts({ collections, onClick }: CollectionShortcutsProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export default CollectionShortcuts;
|
|
13
|
-
//# sourceMappingURL=CollectionShortcuts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionShortcuts.d.ts","sourceRoot":"","sources":["../../src/CollectionShortcuts/CollectionShortcuts.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAEpD,UAAU,wBAAwB;IAC9B,mCAAmC;IACnC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,0CAA0C;IAC1C,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;GAEG;AACH,iBAAS,mBAAmB,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,wBAAwB,2CAqC9E;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Star } from "@mui/icons-material";
|
|
4
|
-
import { Box, Paper, Typography } from "@mui/material";
|
|
5
|
-
/**
|
|
6
|
-
* A sidebar element to view a list of provided shortcuts, used for the user's authenticated routes.
|
|
7
|
-
*/
|
|
8
|
-
function CollectionShortcuts({ collections, onClick }) {
|
|
9
|
-
return (_jsxs(Paper, { variant: "outlined", sx: { width: "fit-content" }, children: [_jsx(Typography, { variant: "h6", sx: { px: 2, py: 1.5, fontWeight: 600 }, children: "Collections" }), collections.length === 0 ? (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { px: 2, py: 2 }, children: "No shortcuts available." })) : (_jsx(Box, { component: "ul", sx: { listStyle: "none", p: 0, m: 0 }, children: collections.map((favorite, index) => (_jsxs(Box, { component: "li", onClick: () => onClick(favorite.href), sx: {
|
|
10
|
-
px: 2,
|
|
11
|
-
py: 1,
|
|
12
|
-
cursor: "pointer",
|
|
13
|
-
display: "flex",
|
|
14
|
-
alignItems: "center",
|
|
15
|
-
gap: 1,
|
|
16
|
-
"&:hover": {
|
|
17
|
-
bgcolor: "action.hover",
|
|
18
|
-
},
|
|
19
|
-
}, children: [_jsx(Star, { fontSize: "small", color: "action" }), _jsx("span", { children: favorite.objectPath })] }, index))) }))] }));
|
|
20
|
-
}
|
|
21
|
-
export default CollectionShortcuts;
|
|
22
|
-
//# sourceMappingURL=CollectionShortcuts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionShortcuts.js","sourceRoot":"","sources":["../../src/CollectionShortcuts/CollectionShortcuts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAUvD;;GAEG;AACH,SAAS,mBAAmB,CAAC,EAAE,WAAW,EAAE,OAAO,EAA4B;IAC3E,OAAO,CACH,MAAC,KAAK,IAAC,OAAO,EAAC,UAAU,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,aAClD,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,4BAEnD,EACZ,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACxB,KAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,gBAAgB,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,wCAE1D,CAChB,CAAC,CAAC,CAAC,CACA,KAAC,GAAG,IAAC,SAAS,EAAC,IAAI,EAAC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,YACpD,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAClC,MAAC,GAAG,IACA,SAAS,EAAC,IAAI,EAEd,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EACrC,EAAE,EAAE;wBACA,EAAE,EAAE,CAAC;wBACL,EAAE,EAAE,CAAC;wBACL,MAAM,EAAE,SAAS;wBACjB,OAAO,EAAE,MAAM;wBACf,UAAU,EAAE,QAAQ;wBACpB,GAAG,EAAE,CAAC;wBACN,SAAS,EAAE;4BACP,OAAO,EAAE,cAAc;yBAC1B;qBACJ,aAED,KAAC,IAAI,IAAC,QAAQ,EAAC,OAAO,EAAC,KAAK,EAAC,QAAQ,GAAG,EACxC,yBAAO,QAAQ,CAAC,UAAU,GAAQ,KAf7B,KAAK,CAgBR,CACT,CAAC,GACA,CACT,IACG,CACX,CAAC;AACN,CAAC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/CollectionShortcuts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/CollectionShortcuts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { Federation, Namespace, Collection, ObjectList } from "@pelicanplatform/web-client";
|
|
3
|
-
export interface PelicanClientContextValue {
|
|
4
|
-
loading: boolean;
|
|
5
|
-
error: string | null;
|
|
6
|
-
authorizationRequired: boolean;
|
|
7
|
-
authorized: boolean;
|
|
8
|
-
setError: (error: string | null) => void;
|
|
9
|
-
objectUrl: string;
|
|
10
|
-
federationHostname: string | null;
|
|
11
|
-
objectPath: string | null;
|
|
12
|
-
federation: Federation | null;
|
|
13
|
-
namespace: Namespace | null;
|
|
14
|
-
collections: Collection[];
|
|
15
|
-
ensureMetadata: (targetObjectUrl: string) => Promise<{
|
|
16
|
-
federation: Federation;
|
|
17
|
-
namespace: Namespace | null;
|
|
18
|
-
}>;
|
|
19
|
-
getObjectList: (targetObjectUrl?: string, forceRefresh?: boolean) => Promise<ObjectList[]>;
|
|
20
|
-
invalidateObjectListCache: (targetObjectUrl?: string) => void;
|
|
21
|
-
handleDownload: (downloadObjectUrl: string) => Promise<void>;
|
|
22
|
-
handleUpload: (file: File, uploadObjectUrl?: string) => Promise<void>;
|
|
23
|
-
handleLogin: () => Promise<void>;
|
|
24
|
-
setObjectUrl: Dispatch<SetStateAction<string>>;
|
|
25
|
-
}
|
|
26
|
-
export declare const PelicanClientContext: import("react").Context<PelicanClientContextValue | null>;
|
|
27
|
-
//# sourceMappingURL=PelicanClientContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PelicanClientContext.d.ts","sourceRoot":"","sources":["../../src/PelicanClientProvider/PelicanClientContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE5F,MAAM,WAAW,yBAAyB;IAExC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IAGpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAGzC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAG1B,cAAc,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC;QACnD,UAAU,EAAE,UAAU,CAAC;QACvB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;KAC5B,CAAC,CAAC;IAGH,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3F,yBAAyB,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,cAAc,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAGjC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAChD;AAED,eAAO,MAAM,oBAAoB,2DAAwD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PelicanClientContext.js","sourceRoot":"","sources":["../../src/PelicanClientProvider/PelicanClientContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;AAwChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAmC,IAAI,CAAC,CAAC;AAE1F,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface PelicanClientProviderProps {
|
|
3
|
-
/** Initial object URL */
|
|
4
|
-
initialObjectUrl?: string;
|
|
5
|
-
/** Whether to enable authentication features */
|
|
6
|
-
enableAuth?: boolean;
|
|
7
|
-
/** Child components that will have access to the context */
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Provider component that manages Pelican client state and provides it to child components.
|
|
12
|
-
* Wrap your app or component tree with this provider to enable usePelicanClient hook.
|
|
13
|
-
*/
|
|
14
|
-
export declare function PelicanClientProvider({ initialObjectUrl, enableAuth, children }: PelicanClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
//# sourceMappingURL=PelicanClientProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PelicanClientProvider.d.ts","sourceRoot":"","sources":["../../src/PelicanClientProvider/PelicanClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAyBjF,MAAM,WAAW,0BAA0B;IACzC,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACE,gBAAqB,EACrB,UAAiB,EACjB,QAAQ,EACT,EAAE,0BAA0B,2CA0blE"}
|
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { UnauthenticatedError, downloadResponse, fetchFederation, fetchNamespace, get, list, parseObjectUrl, put, startAuthorizationCodeFlow, verifyToken, getTokenCollections } from "@pelicanplatform/web-client";
|
|
5
|
-
import { PelicanClientContext } from "./PelicanClientContext";
|
|
6
|
-
import { useSessionStorage } from "../usePelicanClient/useSessionStorage";
|
|
7
|
-
import { useCodeVerifier } from "../usePelicanClient/useCodeVerifier";
|
|
8
|
-
import { useAuthExchange } from "../usePelicanClient/useAuthExchange";
|
|
9
|
-
/**
|
|
10
|
-
* Provider component that manages Pelican client state and provides it to child components.
|
|
11
|
-
* Wrap your app or component tree with this provider to enable usePelicanClient hook.
|
|
12
|
-
*/
|
|
13
|
-
export function PelicanClientProvider({ initialObjectUrl = "", enableAuth = true, children }) {
|
|
14
|
-
const [objectUrl, setObjectUrl] = useState(initialObjectUrl);
|
|
15
|
-
const [loading, setLoading] = useState(true);
|
|
16
|
-
const [error, setError] = useState(null);
|
|
17
|
-
const [federations, setFederations] = useSessionStorage("pelican-wc-federations", {});
|
|
18
|
-
const [prefixToNamespace, setPrefixToNamespace] = useSessionStorage("pelican-wc-p2n", {});
|
|
19
|
-
const [authorizationRequired, setAuthorizationRequired] = useState(!enableAuth);
|
|
20
|
-
// Store in-flight metadata fetch promises to prevent duplicate concurrent requests
|
|
21
|
-
const metadataPromises = useRef(new Map());
|
|
22
|
-
// Cache for object list responses to avoid redundant requests
|
|
23
|
-
const objectListCache = useRef(new Map());
|
|
24
|
-
// Cache TTL in milliseconds (5 minutes)
|
|
25
|
-
const OBJECT_LIST_CACHE_TTL = 5 * 60 * 1000;
|
|
26
|
-
// Handle OAuth authorization code exchange
|
|
27
|
-
const [codeVerifier, ensureCodeVerifier] = useCodeVerifier();
|
|
28
|
-
const { loading: authLoading } = useAuthExchange({
|
|
29
|
-
enabled: enableAuth,
|
|
30
|
-
codeVerifier: codeVerifier,
|
|
31
|
-
getNamespace: (federationHostname, namespacePrefix) => {
|
|
32
|
-
var _a;
|
|
33
|
-
return (_a = federations[federationHostname]) === null || _a === void 0 ? void 0 : _a.namespaces[namespacePrefix];
|
|
34
|
-
},
|
|
35
|
-
onTokenReceived: (result) => {
|
|
36
|
-
var _a;
|
|
37
|
-
const newNamespace = {
|
|
38
|
-
...(_a = federations[result.federationHostname]) === null || _a === void 0 ? void 0 : _a.namespaces[result.namespacePrefix],
|
|
39
|
-
token: result.token
|
|
40
|
-
};
|
|
41
|
-
setActiveNamespace(newNamespace);
|
|
42
|
-
setFederations((f) => {
|
|
43
|
-
var _a;
|
|
44
|
-
return ({
|
|
45
|
-
...f,
|
|
46
|
-
[result.federationHostname]: {
|
|
47
|
-
...f[result.federationHostname],
|
|
48
|
-
namespaces: {
|
|
49
|
-
...(_a = f[result.federationHostname]) === null || _a === void 0 ? void 0 : _a.namespaces,
|
|
50
|
-
[result.namespacePrefix]: newNamespace,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
const { federationHostname, objectPath } = useMemo(() => {
|
|
58
|
-
try {
|
|
59
|
-
return parseObjectUrl(objectUrl);
|
|
60
|
-
}
|
|
61
|
-
catch (_a) {
|
|
62
|
-
return { federationHostname: null, objectPath: null };
|
|
63
|
-
}
|
|
64
|
-
}, [objectUrl]);
|
|
65
|
-
const federation = federationHostname && federations
|
|
66
|
-
? federations[federationHostname] || null
|
|
67
|
-
: null;
|
|
68
|
-
/**
|
|
69
|
-
* There is a brief blip when the derived namespace is null before metadata is loaded.
|
|
70
|
-
* To avoid losing the namespace in that case we keep track of the last active namespace.
|
|
71
|
-
*/
|
|
72
|
-
const [activeNamespace, setActiveNamespace] = useState(null);
|
|
73
|
-
const derivedNamespace = useMemo(() => {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
if (!objectPath || !federation)
|
|
76
|
-
return null;
|
|
77
|
-
const namespaceKey = (_a = prefixToNamespace === null || prefixToNamespace === void 0 ? void 0 : prefixToNamespace[objectPath]) === null || _a === void 0 ? void 0 : _a.namespace;
|
|
78
|
-
if (!namespaceKey)
|
|
79
|
-
return null;
|
|
80
|
-
return ((_b = federation.namespaces) === null || _b === void 0 ? void 0 : _b[namespaceKey]) || null;
|
|
81
|
-
}, [prefixToNamespace, objectPath, federation]);
|
|
82
|
-
// On mount, attempt to set activeNamespace from stored federations if possible
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (derivedNamespace) {
|
|
85
|
-
setActiveNamespace(derivedNamespace);
|
|
86
|
-
}
|
|
87
|
-
}, []);
|
|
88
|
-
const namespace = derivedNamespace || activeNamespace;
|
|
89
|
-
const prevCollectionsRef = useRef([]);
|
|
90
|
-
const collections = useMemo(() => {
|
|
91
|
-
if ((!verifyToken(namespace === null || namespace === void 0 ? void 0 : namespace.token) && prevCollectionsRef.current.length > 0) || !namespace) {
|
|
92
|
-
prevCollectionsRef.current = [];
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const newCollections = getTokenCollections(namespace);
|
|
96
|
-
if (JSON.stringify(prevCollectionsRef.current) !== JSON.stringify(newCollections)) {
|
|
97
|
-
prevCollectionsRef.current = newCollections;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return prevCollectionsRef.current;
|
|
101
|
-
}, [namespace]);
|
|
102
|
-
const authorized = collections.length > 0 || !authorizationRequired || !enableAuth;
|
|
103
|
-
/**
|
|
104
|
-
* Helper function to remove expired tokens from state.
|
|
105
|
-
*/
|
|
106
|
-
const cleanExpiredTokens = useCallback(() => {
|
|
107
|
-
setFederations((prevFederations) => {
|
|
108
|
-
const updatedFederations = {};
|
|
109
|
-
for (const [fedKey, federation] of Object.entries(prevFederations)) {
|
|
110
|
-
const updatedNamespaces = {};
|
|
111
|
-
for (const [nsKey, namespace] of Object.entries(federation.namespaces)) {
|
|
112
|
-
const updatedNamespace = { ...namespace };
|
|
113
|
-
if (namespace.token && !verifyToken(namespace.token)) {
|
|
114
|
-
setError("Cleaned expired authentication token. Please log in again.");
|
|
115
|
-
delete updatedNamespace.token;
|
|
116
|
-
}
|
|
117
|
-
updatedNamespaces[nsKey] = updatedNamespace;
|
|
118
|
-
}
|
|
119
|
-
updatedFederations[fedKey] = {
|
|
120
|
-
...federation,
|
|
121
|
-
namespaces: updatedNamespaces
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
return updatedFederations;
|
|
125
|
-
});
|
|
126
|
-
}, []);
|
|
127
|
-
/**
|
|
128
|
-
* Helper function to ensure federation and namespace metadata is available.
|
|
129
|
-
* Fetches on-demand if not in cache. Deduplicates concurrent requests for the same URL.
|
|
130
|
-
*/
|
|
131
|
-
const ensureMetadata = useCallback(async (targetObjectUrl) => {
|
|
132
|
-
var _a;
|
|
133
|
-
const { federationHostname, objectPath } = parseObjectUrl(targetObjectUrl);
|
|
134
|
-
if (!federationHostname || !objectPath) {
|
|
135
|
-
throw new Error(`Invalid object URL: ${targetObjectUrl}`);
|
|
136
|
-
}
|
|
137
|
-
const cacheKey = `${federationHostname}:${objectPath}`;
|
|
138
|
-
// Check if there's already an in-flight request for this URL
|
|
139
|
-
const existingPromise = metadataPromises.current.get(cacheKey);
|
|
140
|
-
if (existingPromise) {
|
|
141
|
-
return existingPromise;
|
|
142
|
-
}
|
|
143
|
-
// Check if we already have both federation and namespace in cache
|
|
144
|
-
const _federation = federations[federationHostname];
|
|
145
|
-
const namespaceKey = (_a = prefixToNamespace[objectPath]) === null || _a === void 0 ? void 0 : _a.namespace;
|
|
146
|
-
const _namespace = namespaceKey && _federation
|
|
147
|
-
? _federation.namespaces[namespaceKey]
|
|
148
|
-
: null;
|
|
149
|
-
if (_federation && _namespace) {
|
|
150
|
-
return { federation: _federation, namespace: _namespace };
|
|
151
|
-
}
|
|
152
|
-
// Create a new promise for this fetch operation
|
|
153
|
-
const fetchPromise = (async () => {
|
|
154
|
-
var _a;
|
|
155
|
-
try {
|
|
156
|
-
let federation = federations[federationHostname];
|
|
157
|
-
if (!federation) {
|
|
158
|
-
federation = await fetchFederation(federationHostname);
|
|
159
|
-
setFederations((prev) => ({
|
|
160
|
-
...prev,
|
|
161
|
-
[federationHostname]: federation
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
// Check if we have already mapped that object prefix to a namespace
|
|
165
|
-
const namespaceKey = (_a = prefixToNamespace[objectPath]) === null || _a === void 0 ? void 0 : _a.namespace;
|
|
166
|
-
let namespace = namespaceKey ? federation.namespaces[namespaceKey] : null;
|
|
167
|
-
// If it is not mapped, fetch the namespace metadata and map it
|
|
168
|
-
if (!namespace) {
|
|
169
|
-
namespace = await fetchNamespace(objectPath, federation);
|
|
170
|
-
setActiveNamespace((p) => {
|
|
171
|
-
if (p && p.prefix === namespace.prefix) {
|
|
172
|
-
return p;
|
|
173
|
-
}
|
|
174
|
-
return namespace;
|
|
175
|
-
});
|
|
176
|
-
setPrefixToNamespace((prev) => ({
|
|
177
|
-
...prev,
|
|
178
|
-
[objectPath]: {
|
|
179
|
-
federation: federationHostname,
|
|
180
|
-
namespace: namespace.prefix
|
|
181
|
-
}
|
|
182
|
-
}));
|
|
183
|
-
// If the namespace doesn't exist in the federation yet, add it
|
|
184
|
-
if (namespace && !(namespace.prefix in federation.namespaces)) {
|
|
185
|
-
setFederations((prev) => ({
|
|
186
|
-
...prev,
|
|
187
|
-
[federationHostname]: {
|
|
188
|
-
...federation,
|
|
189
|
-
namespaces: {
|
|
190
|
-
...federation.namespaces,
|
|
191
|
-
[namespace.prefix]: namespace
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return { federation, namespace };
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
setError("Couldn't fetch metadata: " + e);
|
|
201
|
-
throw e;
|
|
202
|
-
}
|
|
203
|
-
finally {
|
|
204
|
-
metadataPromises.current.delete(cacheKey);
|
|
205
|
-
}
|
|
206
|
-
})();
|
|
207
|
-
metadataPromises.current.set(cacheKey, fetchPromise);
|
|
208
|
-
return fetchPromise;
|
|
209
|
-
}, [federations, prefixToNamespace]);
|
|
210
|
-
// Store the latest ensureMetadata function in a ref
|
|
211
|
-
const ensureMetadataRef = useRef(ensureMetadata);
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
ensureMetadataRef.current = ensureMetadata;
|
|
214
|
-
}, [ensureMetadata]);
|
|
215
|
-
// Pull Federation and Namespace Metadata as needed for the current objectUrl
|
|
216
|
-
useEffect(() => {
|
|
217
|
-
(async () => {
|
|
218
|
-
setLoading(true);
|
|
219
|
-
const { federationHostname, objectPath } = parseObjectUrl(objectUrl);
|
|
220
|
-
if (!objectUrl || !federationHostname || !objectPath) {
|
|
221
|
-
setLoading(false);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
try {
|
|
225
|
-
await ensureMetadataRef.current(objectUrl);
|
|
226
|
-
}
|
|
227
|
-
catch (e) {
|
|
228
|
-
setError(`Failed to fetch metadata for ${objectUrl}: ${e}`);
|
|
229
|
-
}
|
|
230
|
-
setLoading(false);
|
|
231
|
-
})();
|
|
232
|
-
}, [objectUrl]);
|
|
233
|
-
/**
|
|
234
|
-
* Get the list of objects at the specified URL.
|
|
235
|
-
* Results are cached with a TTL to avoid redundant requests.
|
|
236
|
-
*/
|
|
237
|
-
const getObjectList = useCallback(async (targetObjectUrl, forceRefresh = false) => {
|
|
238
|
-
try {
|
|
239
|
-
const urlToFetch = targetObjectUrl || objectUrl;
|
|
240
|
-
// Check cache first (unless force refresh is requested)
|
|
241
|
-
if (!forceRefresh) {
|
|
242
|
-
const cached = objectListCache.current.get(urlToFetch);
|
|
243
|
-
if (cached && Date.now() - cached.timestamp < OBJECT_LIST_CACHE_TTL) {
|
|
244
|
-
return cached.data;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
const { federationHostname, objectPath } = parseObjectUrl(urlToFetch);
|
|
248
|
-
const { federation, namespace } = await ensureMetadataRef.current(objectUrl);
|
|
249
|
-
if (!federation || !namespace) {
|
|
250
|
-
throw new Error("Federation or Namespace metadata is missing");
|
|
251
|
-
}
|
|
252
|
-
let objects = await list(urlToFetch, federation, namespace);
|
|
253
|
-
// No longer need authorization
|
|
254
|
-
setAuthorizationRequired(false);
|
|
255
|
-
// Get authenticated collections for the current namespace and filter objects based on permissions
|
|
256
|
-
const currentCollections = getTokenCollections(namespace);
|
|
257
|
-
// add parent directory entry
|
|
258
|
-
const pathParts = objectPath.split("/").filter((p) => p.length > 0);
|
|
259
|
-
const parentParts = pathParts.slice(0, -1);
|
|
260
|
-
const parentPath = parentParts.length > 0 ? "/" + parentParts.join("/") : "";
|
|
261
|
-
// Check if the parent directory is within any of the user's collections before adding it to the list
|
|
262
|
-
if (pathParts.length > 0 && currentCollections.some(c => parentPath.startsWith(namespace.prefix + c.objectPath))) {
|
|
263
|
-
objects.push({
|
|
264
|
-
href: parentPath || "/",
|
|
265
|
-
getcontentlength: 0,
|
|
266
|
-
getlastmodified: "",
|
|
267
|
-
resourcetype: "collection",
|
|
268
|
-
iscollection: true,
|
|
269
|
-
executable: "",
|
|
270
|
-
status: "",
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
const objectPathWithoutSlash = objectPath.replace(/\/+$/, "");
|
|
274
|
-
objects = objects.filter((obj) => obj.href !== objectPathWithoutSlash && obj.href !== "");
|
|
275
|
-
objects.reverse();
|
|
276
|
-
// Cache the result
|
|
277
|
-
objectListCache.current.set(urlToFetch, {
|
|
278
|
-
data: objects,
|
|
279
|
-
timestamp: Date.now()
|
|
280
|
-
});
|
|
281
|
-
return objects;
|
|
282
|
-
}
|
|
283
|
-
catch (e) {
|
|
284
|
-
if (e instanceof UnauthenticatedError) {
|
|
285
|
-
setAuthorizationRequired(true);
|
|
286
|
-
cleanExpiredTokens();
|
|
287
|
-
return [];
|
|
288
|
-
}
|
|
289
|
-
setError(`Failed to fetch object list for ${targetObjectUrl || objectUrl}: ${e}`);
|
|
290
|
-
return [];
|
|
291
|
-
}
|
|
292
|
-
}, [objectUrl, OBJECT_LIST_CACHE_TTL]);
|
|
293
|
-
/**
|
|
294
|
-
* Invalidate the object list cache for a specific URL or all URLs.
|
|
295
|
-
*/
|
|
296
|
-
const invalidateObjectListCache = useCallback((targetObjectUrl) => {
|
|
297
|
-
if (targetObjectUrl) {
|
|
298
|
-
// Delete target cache and parent caches in case of directory changes
|
|
299
|
-
const toDelete = targetObjectUrl.replace("pelican://", "").split("/").map((_, idx, arr) => "pelican://" + arr.slice(0, idx + 1).join("/"));
|
|
300
|
-
toDelete.forEach(url => {
|
|
301
|
-
objectListCache.current.delete(url);
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
objectListCache.current.clear();
|
|
306
|
-
}
|
|
307
|
-
}, []);
|
|
308
|
-
const handleDownload = useCallback(async (downloadObjectUrl) => {
|
|
309
|
-
try {
|
|
310
|
-
const { federation, namespace } = await ensureMetadataRef.current(objectUrl);
|
|
311
|
-
if (!federation || !namespace)
|
|
312
|
-
return;
|
|
313
|
-
const response = await get(downloadObjectUrl, federation, namespace);
|
|
314
|
-
downloadResponse(response);
|
|
315
|
-
}
|
|
316
|
-
catch (e) {
|
|
317
|
-
if (e instanceof UnauthenticatedError) {
|
|
318
|
-
setAuthorizationRequired(true);
|
|
319
|
-
cleanExpiredTokens();
|
|
320
|
-
}
|
|
321
|
-
setError(`Download failed: ${e}`);
|
|
322
|
-
throw e;
|
|
323
|
-
}
|
|
324
|
-
}, []);
|
|
325
|
-
const handleUpload = useCallback(async (file, uploadObjectUrl) => {
|
|
326
|
-
try {
|
|
327
|
-
const targetUrl = uploadObjectUrl || objectUrl;
|
|
328
|
-
const { federation, namespace } = await ensureMetadataRef.current(objectUrl);
|
|
329
|
-
if (!federation || !namespace)
|
|
330
|
-
return;
|
|
331
|
-
const finalUploadUrl = targetUrl.endsWith("/")
|
|
332
|
-
? `${targetUrl}${file.name}`
|
|
333
|
-
: `${targetUrl}/${file.name}`;
|
|
334
|
-
await put(finalUploadUrl, file, federation, namespace);
|
|
335
|
-
// Invalidate cache for the directory after successful upload
|
|
336
|
-
invalidateObjectListCache(targetUrl);
|
|
337
|
-
}
|
|
338
|
-
catch (e) {
|
|
339
|
-
if (e instanceof UnauthenticatedError) {
|
|
340
|
-
setAuthorizationRequired(true);
|
|
341
|
-
cleanExpiredTokens();
|
|
342
|
-
}
|
|
343
|
-
setError(`Upload failed: ${e}`);
|
|
344
|
-
throw e;
|
|
345
|
-
}
|
|
346
|
-
}, [objectUrl, invalidateObjectListCache]);
|
|
347
|
-
const handleLogin = useCallback(async () => {
|
|
348
|
-
try {
|
|
349
|
-
const { federation, namespace } = await ensureMetadataRef.current(objectUrl);
|
|
350
|
-
if (!federation || !namespace)
|
|
351
|
-
return;
|
|
352
|
-
if (!enableAuth)
|
|
353
|
-
return;
|
|
354
|
-
await startAuthorizationCodeFlow(ensureCodeVerifier(), namespace, federation, { objectUrl });
|
|
355
|
-
}
|
|
356
|
-
catch (e) {
|
|
357
|
-
setError(`Login failed: ${e}`);
|
|
358
|
-
throw e;
|
|
359
|
-
}
|
|
360
|
-
}, [objectUrl, ensureCodeVerifier, enableAuth]);
|
|
361
|
-
const contextValue = {
|
|
362
|
-
loading: loading || authLoading,
|
|
363
|
-
error,
|
|
364
|
-
setError,
|
|
365
|
-
authorizationRequired,
|
|
366
|
-
authorized,
|
|
367
|
-
objectUrl,
|
|
368
|
-
federationHostname,
|
|
369
|
-
objectPath,
|
|
370
|
-
federation,
|
|
371
|
-
namespace,
|
|
372
|
-
collections,
|
|
373
|
-
ensureMetadata,
|
|
374
|
-
getObjectList,
|
|
375
|
-
invalidateObjectListCache,
|
|
376
|
-
handleDownload,
|
|
377
|
-
handleUpload,
|
|
378
|
-
handleLogin,
|
|
379
|
-
setObjectUrl,
|
|
380
|
-
};
|
|
381
|
-
return (_jsx(PelicanClientContext.Provider, { value: contextValue, children: children }));
|
|
382
|
-
}
|
|
383
|
-
//# sourceMappingURL=PelicanClientProvider.js.map
|