@ldo/solid-react 0.0.1-alpha.32 → 1.0.0-alpha.11

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.
Files changed (92) hide show
  1. package/README.md +124 -3
  2. package/dist/{SolidAuthContext.js → cjs/SolidAuthContext.js} +5 -2
  3. package/dist/cjs/SolidAuthContext.js.map +1 -0
  4. package/dist/{UnauthenticatedSolidLdoProvider.js → cjs/UnauthenticatedSolidLdoProvider.js} +6 -3
  5. package/dist/cjs/UnauthenticatedSolidLdoProvider.js.map +1 -0
  6. package/dist/cjs/createBrowserSolidReactMethods.js +88 -0
  7. package/dist/cjs/createBrowserSolidReactMethods.js.map +1 -0
  8. package/dist/cjs/defaultIntance.js +13 -0
  9. package/dist/cjs/defaultIntance.js.map +1 -0
  10. package/dist/{index.js → cjs/index.js} +2 -11
  11. package/dist/cjs/index.js.map +1 -0
  12. package/dist/cjs/useRootContainerFor.js +32 -0
  13. package/dist/cjs/useRootContainerFor.js.map +1 -0
  14. package/dist/esm/SolidAuthContext.js +9 -0
  15. package/dist/esm/SolidAuthContext.js.map +1 -0
  16. package/dist/esm/UnauthenticatedSolidLdoProvider.js +37 -0
  17. package/dist/esm/UnauthenticatedSolidLdoProvider.js.map +1 -0
  18. package/dist/esm/createBrowserSolidReactMethods.js +85 -0
  19. package/dist/esm/createBrowserSolidReactMethods.js.map +1 -0
  20. package/dist/esm/defaultIntance.js +9 -0
  21. package/dist/esm/defaultIntance.js.map +1 -0
  22. package/dist/esm/index.js +3 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/useRootContainerFor.js +29 -0
  25. package/dist/esm/useRootContainerFor.js.map +1 -0
  26. package/dist/{SolidAuthContext.d.ts → types/SolidAuthContext.d.ts} +4 -1
  27. package/dist/types/SolidAuthContext.d.ts.map +1 -0
  28. package/dist/{UnauthenticatedSolidLdoProvider.d.ts → types/UnauthenticatedSolidLdoProvider.d.ts} +4 -0
  29. package/dist/types/UnauthenticatedSolidLdoProvider.d.ts.map +1 -0
  30. package/dist/types/createBrowserSolidReactMethods.d.ts +17 -0
  31. package/dist/types/createBrowserSolidReactMethods.d.ts.map +1 -0
  32. package/dist/types/defaultIntance.d.ts +8 -0
  33. package/dist/types/defaultIntance.d.ts.map +1 -0
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/index.d.ts.map +1 -0
  36. package/dist/types/useRootContainerFor.d.ts +10 -0
  37. package/dist/types/useRootContainerFor.d.ts.map +1 -0
  38. package/package.json +31 -26
  39. package/src/SolidAuthContext.ts +3 -0
  40. package/src/UnauthenticatedSolidLdoProvider.tsx +6 -4
  41. package/src/createBrowserSolidReactMethods.tsx +132 -0
  42. package/src/defaultIntance.ts +20 -0
  43. package/src/index.ts +2 -12
  44. package/src/useRootContainerFor.ts +46 -0
  45. package/dist/BrowserSolidLdoProvider.d.ts +0 -2
  46. package/dist/BrowserSolidLdoProvider.js +0 -63
  47. package/dist/BrowserSolidLdoProvider.js.map +0 -1
  48. package/dist/SolidAuthContext.js.map +0 -1
  49. package/dist/SolidLdoProvider.d.ts +0 -8
  50. package/dist/SolidLdoProvider.js +0 -31
  51. package/dist/SolidLdoProvider.js.map +0 -1
  52. package/dist/UnauthenticatedSolidLdoProvider.js.map +0 -1
  53. package/dist/index.d.ts +0 -9
  54. package/dist/index.js.map +0 -1
  55. package/dist/useLdoMethods.d.ts +0 -12
  56. package/dist/useLdoMethods.js +0 -20
  57. package/dist/useLdoMethods.js.map +0 -1
  58. package/dist/useMatchObject.d.ts +0 -3
  59. package/dist/useMatchObject.js +0 -13
  60. package/dist/useMatchObject.js.map +0 -1
  61. package/dist/useMatchSubject.d.ts +0 -3
  62. package/dist/useMatchSubject.js +0 -13
  63. package/dist/useMatchSubject.js.map +0 -1
  64. package/dist/useResource.d.ts +0 -12
  65. package/dist/useResource.js +0 -63
  66. package/dist/useResource.js.map +0 -1
  67. package/dist/useRootContainer.d.ts +0 -3
  68. package/dist/useRootContainer.js +0 -26
  69. package/dist/useRootContainer.js.map +0 -1
  70. package/dist/useSubject.d.ts +0 -5
  71. package/dist/useSubject.js +0 -15
  72. package/dist/useSubject.js.map +0 -1
  73. package/dist/useSubscribeToResource.d.ts +0 -1
  74. package/dist/useSubscribeToResource.js +0 -40
  75. package/dist/useSubscribeToResource.js.map +0 -1
  76. package/dist/util/TrackingProxyContext.d.ts +0 -15
  77. package/dist/util/TrackingProxyContext.js +0 -75
  78. package/dist/util/TrackingProxyContext.js.map +0 -1
  79. package/dist/util/useTrackingProxy.d.ts +0 -3
  80. package/dist/util/useTrackingProxy.js +0 -34
  81. package/dist/util/useTrackingProxy.js.map +0 -1
  82. package/src/BrowserSolidLdoProvider.tsx +0 -97
  83. package/src/SolidLdoProvider.tsx +0 -55
  84. package/src/useLdoMethods.ts +0 -84
  85. package/src/useMatchObject.ts +0 -21
  86. package/src/useMatchSubject.ts +0 -21
  87. package/src/useResource.ts +0 -114
  88. package/src/useRootContainer.ts +0 -31
  89. package/src/useSubject.ts +0 -30
  90. package/src/useSubscribeToResource.ts +0 -52
  91. package/src/util/TrackingProxyContext.ts +0 -110
  92. package/src/util/useTrackingProxy.ts +0 -55
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Default exports for just Solid methods
3
+ */
4
+ export declare const dataset: import("@ldo/connected").ConnectedLdoDataset<import("@ldo/connected-solid").SolidConnectedPlugin[]>, useLdo: () => import("@ldo/react").UseLdoMethods<import("@ldo/connected-solid").SolidConnectedPlugin[]>, useMatchObject: <Type extends import("@ldo/ldo").LdoBase>(shapeType: import("@ldo/ldo").ShapeType<Type>, subject?: import("@ldo/rdf-utils").QuadMatch[0] | string, predicate?: import("@ldo/rdf-utils").QuadMatch[1] | string, graph?: import("@ldo/rdf-utils").QuadMatch[3] | string) => import("@ldo/jsonld-dataset-proxy").LdSet<Type>, useMatchSubject: <Type extends import("@ldo/ldo").LdoBase>(shapeType: import("@ldo/ldo").ShapeType<Type>, predicate?: import("@ldo/rdf-utils").QuadMatch[1] | string, object?: import("@ldo/rdf-utils").QuadMatch[2] | string, graph?: import("@ldo/rdf-utils").QuadMatch[3] | string) => import("@ldo/jsonld-dataset-proxy").LdSet<Type>, useResource: import("@ldo/react").useResourceType<import("@ldo/connected-solid").SolidConnectedPlugin[]>, useSubject: import("@ldo/react").useSubjectType, useSubscribeToResource: (...uris: string[]) => void, useLinkQuery: <Type extends import("@ldo/ldo").LdoBase, QueryInput extends Partial<{ [key in Exclude<keyof Type, "@context">]: import("@ldo/connected").LQInputFlattenSet<Type[key]>; }>>(shapeType: import("@ldo/ldo").ShapeType<Type>, startingResource: string, startingSubject: import("@ldo/rdf-utils").SubjectNode | string, linkQuery: QueryInput) => import("@ldo/connected").ExpandDeep<import("@ldo/connected").LQReturn<Type, QueryInput>> | undefined;
5
+ export declare const BrowserSolidLdoProvider: import("react").FunctionComponent<{
6
+ children?: import("react").ReactNode | undefined;
7
+ }>, useSolidAuth: typeof import("./SolidAuthContext.js").useSolidAuth, useRootContainerFor: (uri?: import("@ldo/connected-solid").SolidContainerUri | import("@ldo/connected-solid").SolidLeafUri, options?: import("@ldo/react").UseResourceOptions<"solid">) => import("@ldo/connected-solid").SolidContainer | undefined;
8
+ //# sourceMappingURL=defaultIntance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultIntance.d.ts","sourceRoot":"","sources":["../../src/defaultIntance.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MACL,OAAO,uGACP,MAAM,mGACN,cAAc,6TACd,eAAe,4TACf,WAAW,+FACX,UAAU,uCACV,sBAAsB,+BACtB,YAAY,qbACmC,CAAC;AAElD,eAAO,MAAQ,uBAAuB;;IAAE,YAAY,uDAAE,mBAAmB,iOAChC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./createBrowserSolidReactMethods.js";
2
+ export * from "./defaultIntance.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
2
+ import type { SolidConnectedPlugin, SolidContainer, SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid";
3
+ import type { UseResourceOptions, createUseResource } from "@ldo/react";
4
+ /**
5
+ * @internal
6
+ *
7
+ * Creates a useRootContainerFor function
8
+ */
9
+ export declare function createUseRootContainerFor(dataset: ConnectedLdoDataset<SolidConnectedPlugin[]>, useResource: ReturnType<typeof createUseResource<ConnectedPlugin[]>>): (uri?: SolidContainerUri | SolidLeafUri, options?: UseResourceOptions<"solid">) => SolidContainer | undefined;
10
+ //# sourceMappingURL=useRootContainerFor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRootContainerFor.d.ts","sourceRoot":"","sources":["../../src/useRootContainerFor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,CAAC,oBAAoB,EAAE,CAAC,EACpD,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,eAAe,EAAE,CAAC,CAAC,IAMlE,MAAM,iBAAiB,GAAG,YAAY,EACtC,UAAU,kBAAkB,CAAC,OAAO,CAAC,KACpC,cAAc,GAAG,SAAS,CAoB9B"}
package/package.json CHANGED
@@ -1,47 +1,52 @@
1
1
  {
2
2
  "name": "@ldo/solid-react",
3
- "version": "0.0.1-alpha.32",
3
+ "version": "1.0.0-alpha.11",
4
4
  "description": "A React library for LDO and Solid",
5
- "main": "dist/index.js",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/cjs/index.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
6
17
  "scripts": {
7
- "build": "tsc --project tsconfig.build.json",
8
- "watch": "tsc --watch",
9
- "test": "npm run test:integration",
10
- "test:watch": "jest --watch",
11
- "prepublishOnly": "npm run test && npm run build",
18
+ "build": "rimraf dist && npm run build:cjs && npm run build:esm",
19
+ "build:cjs": "tsc --project tsconfig.cjs.json",
20
+ "build:esm": "tsc --project tsconfig.esm.json",
21
+ "test": "vitest run --coverage",
22
+ "prepublishOnly": " npm run build",
12
23
  "build:ldo": "ldo build --input src/shapes --output src/ldo",
13
- "lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
14
- "test:integration": "start-server-and-test start-test-server http://localhost:3002 start-integration-test",
15
- "start-test-server": "ts-node ./test/test-server/runServer.ts",
16
- "start-integration-test": "jest --coverage"
24
+ "lint": "eslint src/** --fix --no-error-on-unmatched-pattern"
17
25
  },
18
26
  "repository": {
19
27
  "type": "git",
20
- "url": "git+https://github.com/o-development/ldobjects.git"
28
+ "url": "git+https://github.com/o-development/ldo.git"
21
29
  },
22
30
  "author": "Jackson Morgan",
23
31
  "license": "MIT",
24
32
  "bugs": {
25
- "url": "https://github.com/o-development/ldobjects/issues"
33
+ "url": "https://github.com/o-development/ldo/issues"
26
34
  },
27
- "homepage": "https://github.com/o-development/ldobjects/tree/main/packages/solid-react#readme",
35
+ "homepage": "https://github.com/o-development/ldo/tree/main/packages/solid-react#readme",
28
36
  "devDependencies": {
29
- "@ldo/rdf-utils": "^0.0.1-alpha.24",
37
+ "@babel/core": "^7.26.10",
38
+ "@babel/preset-env": "^7.26.9",
39
+ "@ldo/rdf-utils": "^1.0.0-alpha.11",
30
40
  "@rdfjs/types": "^1.0.1",
31
41
  "@testing-library/react": "^14.1.2",
32
- "@types/jest": "^27.0.3",
33
- "jest-environment-jsdom": "^27.0.0",
34
42
  "start-server-and-test": "^2.0.3",
35
- "ts-jest": "^27.1.2",
36
- "ts-node": "^10.9.2"
43
+ "whatwg-fetch": "^3.6.20"
37
44
  },
38
45
  "dependencies": {
39
- "@inrupt/solid-client-authn-browser": "^2.0.0",
40
- "@ldo/dataset": "^0.0.1-alpha.24",
41
- "@ldo/jsonld-dataset-proxy": "^0.0.1-alpha.29",
42
- "@ldo/ldo": "^0.0.1-alpha.29",
43
- "@ldo/solid": "^0.0.1-alpha.32",
44
- "@ldo/subscribable-dataset": "^0.0.1-alpha.24",
46
+ "@inrupt/solid-client-authn-browser": "2.3.0",
47
+ "@ldo/connected": "^1.0.0-alpha.11",
48
+ "@ldo/connected-solid": "^1.0.0-alpha.11",
49
+ "@ldo/react": "^1.0.0-alpha.11",
45
50
  "@rdfjs/data-model": "^1.2.0",
46
51
  "cross-fetch": "^3.1.6"
47
52
  },
@@ -52,5 +57,5 @@
52
57
  "publishConfig": {
53
58
  "access": "public"
54
59
  },
55
- "gitHead": "db1622a0660c8a7560726c5f7f9e8ddab6b122c5"
60
+ "gitHead": "84bd3d7cf0a1b28c5e20b019a6451973d69d0198"
56
61
  }
@@ -7,6 +7,9 @@ import { createContext, useContext } from "react";
7
7
  export type SessionInfo = ISessionInfo;
8
8
  export type LoginOptions = ILoginInputOptions;
9
9
 
10
+ /**
11
+ * Functions for authenticating with Solid
12
+ */
10
13
  export interface SolidAuthFunctions {
11
14
  login: (issuer: string, loginOptions?: LoginOptions) => Promise<void>;
12
15
  logout: () => Promise<void>;
@@ -1,10 +1,9 @@
1
1
  /* istanbul ignore file */
2
2
  import React, { useCallback, useMemo } from "react";
3
3
  import type { FunctionComponent, PropsWithChildren } from "react";
4
- import type { LoginOptions, SessionInfo } from "./SolidAuthContext";
5
- import { SolidAuthContext } from "./SolidAuthContext";
4
+ import type { LoginOptions, SessionInfo } from "./SolidAuthContext.js";
5
+ import { SolidAuthContext } from "./SolidAuthContext.js";
6
6
  import libraryFetch from "cross-fetch";
7
- import { SolidLdoProvider } from "./SolidLdoProvider";
8
7
 
9
8
  const DUMMY_SESSION: SessionInfo = {
10
9
  isLoggedIn: false,
@@ -14,6 +13,9 @@ const DUMMY_SESSION: SessionInfo = {
14
13
  expirationDate: undefined,
15
14
  };
16
15
 
16
+ /**
17
+ * A provider for interacting with Solid Pods without authenticating
18
+ */
17
19
  export const UnauthenticatedSolidLdoProvider: FunctionComponent<
18
20
  PropsWithChildren
19
21
  > = ({ children }) => {
@@ -56,7 +58,7 @@ export const UnauthenticatedSolidLdoProvider: FunctionComponent<
56
58
 
57
59
  return (
58
60
  <SolidAuthContext.Provider value={solidAuthFunctions}>
59
- <SolidLdoProvider>{children}</SolidLdoProvider>
61
+ {children}
60
62
  </SolidAuthContext.Provider>
61
63
  );
62
64
  };
@@ -0,0 +1,132 @@
1
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
2
+ import type { FunctionComponent, PropsWithChildren } from "react";
3
+ import type { LoginOptions, SessionInfo } from "./SolidAuthContext.js";
4
+ import { SolidAuthContext, useSolidAuth } from "./SolidAuthContext.js";
5
+ import {
6
+ getDefaultSession,
7
+ handleIncomingRedirect,
8
+ login as libraryLogin,
9
+ logout as libraryLogout,
10
+ fetch as libraryFetch,
11
+ } from "@inrupt/solid-client-authn-browser";
12
+ import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
13
+ import type { SolidConnectedPlugin } from "@ldo/connected-solid";
14
+ import { createUseRootContainerFor } from "./useRootContainerFor.js";
15
+ import { createUseResource } from "@ldo/react";
16
+
17
+ const PRE_REDIRECT_URI = "PRE_REDIRECT_URI";
18
+
19
+ /**
20
+ * Creates special react methods specific to the Solid
21
+ * @param dataset the connectedLdoDataset with a SolidConnectedPlugin
22
+ * @returns { BrowserSolidLdoProvider, useSolidAuth, useRootContainerFor }
23
+ */
24
+ export function createBrowserSolidReactMethods(
25
+ dataset: ConnectedLdoDataset<(SolidConnectedPlugin | ConnectedPlugin)[]>,
26
+ ) {
27
+ dataset.setContext("solid", { fetch: libraryFetch });
28
+
29
+ const BrowserSolidLdoProvider: FunctionComponent<PropsWithChildren> = ({
30
+ children,
31
+ }) => {
32
+ const [session, setSession] = useState<SessionInfo>(
33
+ getDefaultSession().info,
34
+ );
35
+ const [ranInitialAuthCheck, setRanInitialAuthCheck] = useState(false);
36
+
37
+ const runInitialAuthCheck = useCallback(async () => {
38
+ if (!window.localStorage.getItem(PRE_REDIRECT_URI)) {
39
+ window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
40
+ }
41
+
42
+ await handleIncomingRedirect({
43
+ restorePreviousSession: true,
44
+ });
45
+ // Set timout to ensure this happens after the redirect
46
+ setTimeout(() => {
47
+ setSession({ ...getDefaultSession().info });
48
+ window.history.replaceState(
49
+ {},
50
+ "",
51
+ window.localStorage.getItem(PRE_REDIRECT_URI),
52
+ );
53
+ window.localStorage.removeItem(PRE_REDIRECT_URI);
54
+
55
+ setRanInitialAuthCheck(true);
56
+ }, 0);
57
+ }, []);
58
+
59
+ const login = useCallback(
60
+ async (issuer: string, options?: LoginOptions) => {
61
+ const cleanUrl = new URL(window.location.href);
62
+ cleanUrl.hash = "";
63
+ cleanUrl.search = "";
64
+ const fullOptions = {
65
+ redirectUrl: cleanUrl.toString(),
66
+ clientName: "Solid App",
67
+ oidcIssuer: issuer,
68
+ ...options,
69
+ };
70
+ window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
71
+ await libraryLogin(fullOptions);
72
+ setSession({ ...getDefaultSession().info });
73
+ },
74
+ [],
75
+ );
76
+
77
+ const logout = useCallback(async () => {
78
+ await libraryLogout();
79
+ setSession({ ...getDefaultSession().info });
80
+ }, []);
81
+
82
+ const signUp = useCallback(
83
+ async (issuer: string, options?: LoginOptions) => {
84
+ // The typings on @inrupt/solid-client-authn-core have not yet been updated
85
+ // TODO: remove this ts-ignore when they are updated.
86
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
+ // @ts-ignore
88
+ return login(issuer, { ...options, prompt: "create" });
89
+ },
90
+ [login],
91
+ );
92
+
93
+ useEffect(() => {
94
+ runInitialAuthCheck();
95
+ }, []);
96
+
97
+ const solidAuthFunctions = useMemo(
98
+ () => ({
99
+ runInitialAuthCheck,
100
+ login,
101
+ logout,
102
+ signUp,
103
+ session,
104
+ ranInitialAuthCheck,
105
+ fetch: libraryFetch,
106
+ }),
107
+ [
108
+ login,
109
+ logout,
110
+ ranInitialAuthCheck,
111
+ runInitialAuthCheck,
112
+ session,
113
+ signUp,
114
+ ],
115
+ );
116
+
117
+ return (
118
+ <SolidAuthContext.Provider value={solidAuthFunctions}>
119
+ {children}
120
+ </SolidAuthContext.Provider>
121
+ );
122
+ };
123
+
124
+ return {
125
+ BrowserSolidLdoProvider,
126
+ useSolidAuth: useSolidAuth,
127
+ useRootContainerFor: createUseRootContainerFor(
128
+ dataset as ConnectedLdoDataset<SolidConnectedPlugin[]>,
129
+ createUseResource(dataset as ConnectedLdoDataset<ConnectedPlugin[]>),
130
+ ),
131
+ };
132
+ }
@@ -0,0 +1,20 @@
1
+ import { solidConnectedPlugin } from "@ldo/connected-solid";
2
+ import { createLdoReactMethods } from "@ldo/react";
3
+ import { createBrowserSolidReactMethods } from "./createBrowserSolidReactMethods.js";
4
+
5
+ /**
6
+ * Default exports for just Solid methods
7
+ */
8
+ export const {
9
+ dataset,
10
+ useLdo,
11
+ useMatchObject,
12
+ useMatchSubject,
13
+ useResource,
14
+ useSubject,
15
+ useSubscribeToResource,
16
+ useLinkQuery,
17
+ } = createLdoReactMethods([solidConnectedPlugin]);
18
+
19
+ export const { BrowserSolidLdoProvider, useSolidAuth, useRootContainerFor } =
20
+ createBrowserSolidReactMethods(dataset);
package/src/index.ts CHANGED
@@ -1,12 +1,2 @@
1
- export * from "./BrowserSolidLdoProvider";
2
- export * from "./UnauthenticatedSolidLdoProvider";
3
- export * from "./SolidAuthContext";
4
-
5
- export { useLdo } from "./SolidLdoProvider";
6
-
7
- // hooks
8
- export * from "./useResource";
9
- export * from "./useSubject";
10
- export * from "./useMatchSubject";
11
- export * from "./useMatchObject";
12
- export * from "./useRootContainer";
1
+ export * from "./createBrowserSolidReactMethods.js";
2
+ export * from "./defaultIntance.js";
@@ -0,0 +1,46 @@
1
+ import { useEffect, useState } from "react";
2
+ import type { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
3
+ import type {
4
+ SolidConnectedPlugin,
5
+ SolidContainer,
6
+ SolidContainerUri,
7
+ SolidLeafUri,
8
+ } from "@ldo/connected-solid";
9
+ import type { UseResourceOptions, createUseResource } from "@ldo/react";
10
+
11
+ /**
12
+ * @internal
13
+ *
14
+ * Creates a useRootContainerFor function
15
+ */
16
+ export function createUseRootContainerFor(
17
+ dataset: ConnectedLdoDataset<SolidConnectedPlugin[]>,
18
+ useResource: ReturnType<typeof createUseResource<ConnectedPlugin[]>>,
19
+ ) {
20
+ /**
21
+ * Gets the root container for a specific URI
22
+ */
23
+ return function useRootContainerFor(
24
+ uri?: SolidContainerUri | SolidLeafUri,
25
+ options?: UseResourceOptions<"solid">,
26
+ ): SolidContainer | undefined {
27
+ const [rootContainerUri, setRootContainerUri] = useState<
28
+ SolidContainerUri | undefined
29
+ >(undefined);
30
+
31
+ useEffect(() => {
32
+ if (uri) {
33
+ const givenResource = dataset.getResource(uri);
34
+ givenResource.getRootContainer().then((result) => {
35
+ if (!result.isError) {
36
+ setRootContainerUri(result.uri);
37
+ }
38
+ });
39
+ } else {
40
+ setRootContainerUri(undefined);
41
+ }
42
+ }, [uri]);
43
+
44
+ return useResource(rootContainerUri, options) as SolidContainer | undefined;
45
+ };
46
+ }
@@ -1,2 +0,0 @@
1
- import type { FunctionComponent, PropsWithChildren } from "react";
2
- export declare const BrowserSolidLdoProvider: FunctionComponent<PropsWithChildren>;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BrowserSolidLdoProvider = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const SolidAuthContext_1 = require("./SolidAuthContext");
7
- const solid_client_authn_browser_1 = require("@inrupt/solid-client-authn-browser");
8
- const SolidLdoProvider_1 = require("./SolidLdoProvider");
9
- const PRE_REDIRECT_URI = "PRE_REDIRECT_URI";
10
- const BrowserSolidLdoProvider = ({ children, }) => {
11
- const [session, setSession] = (0, react_1.useState)((0, solid_client_authn_browser_1.getDefaultSession)().info);
12
- const [ranInitialAuthCheck, setRanInitialAuthCheck] = (0, react_1.useState)(false);
13
- const runInitialAuthCheck = (0, react_1.useCallback)(async () => {
14
- if (!window.localStorage.getItem(PRE_REDIRECT_URI)) {
15
- window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
16
- }
17
- await (0, solid_client_authn_browser_1.handleIncomingRedirect)({
18
- restorePreviousSession: true,
19
- });
20
- setTimeout(() => {
21
- setSession({ ...(0, solid_client_authn_browser_1.getDefaultSession)().info });
22
- window.history.replaceState({}, "", window.localStorage.getItem(PRE_REDIRECT_URI));
23
- window.localStorage.removeItem(PRE_REDIRECT_URI);
24
- setRanInitialAuthCheck(true);
25
- }, 0);
26
- }, []);
27
- const login = (0, react_1.useCallback)(async (issuer, options) => {
28
- const cleanUrl = new URL(window.location.href);
29
- cleanUrl.hash = "";
30
- cleanUrl.search = "";
31
- const fullOptions = {
32
- redirectUrl: cleanUrl.toString(),
33
- clientName: "Solid App",
34
- oidcIssuer: issuer,
35
- ...options,
36
- };
37
- window.localStorage.setItem(PRE_REDIRECT_URI, window.location.href);
38
- await (0, solid_client_authn_browser_1.login)(fullOptions);
39
- setSession({ ...(0, solid_client_authn_browser_1.getDefaultSession)().info });
40
- }, []);
41
- const logout = (0, react_1.useCallback)(async () => {
42
- await (0, solid_client_authn_browser_1.logout)();
43
- setSession({ ...(0, solid_client_authn_browser_1.getDefaultSession)().info });
44
- }, []);
45
- const signUp = (0, react_1.useCallback)(async (issuer, options) => {
46
- return login(issuer, { ...options, prompt: "create" });
47
- }, [login]);
48
- (0, react_1.useEffect)(() => {
49
- runInitialAuthCheck();
50
- }, []);
51
- const solidAuthFunctions = (0, react_1.useMemo)(() => ({
52
- runInitialAuthCheck,
53
- login,
54
- logout,
55
- signUp,
56
- session,
57
- ranInitialAuthCheck,
58
- fetch: solid_client_authn_browser_1.fetch,
59
- }), [login, logout, ranInitialAuthCheck, runInitialAuthCheck, session, signUp]);
60
- return ((0, jsx_runtime_1.jsx)(SolidAuthContext_1.SolidAuthContext.Provider, { value: solidAuthFunctions, children: (0, jsx_runtime_1.jsx)(SolidLdoProvider_1.SolidLdoProvider, { children: children }) }));
61
- };
62
- exports.BrowserSolidLdoProvider = BrowserSolidLdoProvider;
63
- //# sourceMappingURL=BrowserSolidLdoProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BrowserSolidLdoProvider.js","sourceRoot":"","sources":["../src/BrowserSolidLdoProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyE;AAGzE,yDAAsD;AACtD,mFAM4C;AAC5C,yDAAsD;AAEtD,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAErC,MAAM,uBAAuB,GAAyC,CAAC,EAC5E,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAc,IAAA,8CAAiB,GAAE,CAAC,IAAI,CAAC,CAAC;IAC9E,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,mBAAmB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACjD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;YAClD,MAAM,CAAC,YAAY,CA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AAA,kBAAU,EAAC,wBAAgB,CAAC,CAAC;AACtC,CAAC;AAFD,oCAEC"}
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { type FunctionComponent, type PropsWithChildren } from "react";
3
- import type { UseLdoMethods } from "./useLdoMethods";
4
- export declare const SolidLdoReactContext: React.Context<UseLdoMethods>;
5
- export declare function useLdo(): UseLdoMethods;
6
- export interface SolidLdoProviderProps extends PropsWithChildren {
7
- }
8
- export declare const SolidLdoProvider: FunctionComponent<SolidLdoProviderProps>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolidLdoProvider = exports.useLdo = exports.SolidLdoReactContext = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const react_2 = require("react");
7
- const SolidAuthContext_1 = require("./SolidAuthContext");
8
- const solid_1 = require("@ldo/solid");
9
- const useLdoMethods_1 = require("./useLdoMethods");
10
- exports.SolidLdoReactContext = (0, react_1.createContext)(undefined);
11
- function useLdo() {
12
- return (0, react_1.useContext)(exports.SolidLdoReactContext);
13
- }
14
- exports.useLdo = useLdo;
15
- const SolidLdoProvider = ({ children, }) => {
16
- const { fetch } = (0, SolidAuthContext_1.useSolidAuth)();
17
- const solidLdoDataset = (0, react_2.useMemo)(() => {
18
- const ldoDataset = (0, solid_1.createSolidLdoDataset)({
19
- fetch,
20
- });
21
- ldoDataset.setMaxListeners(1000);
22
- return ldoDataset;
23
- }, []);
24
- (0, react_2.useEffect)(() => {
25
- solidLdoDataset.context.fetch = fetch;
26
- }, [fetch]);
27
- const value = (0, react_2.useMemo)(() => (0, useLdoMethods_1.createUseLdoMethods)(solidLdoDataset), [solidLdoDataset]);
28
- return ((0, jsx_runtime_1.jsx)(exports.SolidLdoReactContext.Provider, { value: value, children: children }));
29
- };
30
- exports.SolidLdoProvider = SolidLdoProvider;
31
- //# sourceMappingURL=SolidLdoProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SolidLdoProvider.js","sourceRoot":"","sources":["../src/SolidLdoProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyD;AACzD,iCAKe;AACf,yDAAkD;AAElD,sCAAmD;AAEnD,mDAAsD;AAEzC,QAAA,oBAAoB,GAI/B,IAAA,qBAAa,EAAgB,SAAS,CAAC,CAAC;AAE1C,SAAgB,MAAM;IACpB,OAAO,IAAA,kBAAU,EAAC,4BAAoB,CAAC,CAAC;AAC1C,CAAC;AAFD,wBAEC;AAIM,MAAM,gBAAgB,GAA6C,CAAC,EACzE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,+BAAY,GAAE,CAAC;IAGjC,MAAM,eAAe,GAAoB,IAAA,eAAO,EAAC,GAAG,EAAE;QACpD,MAAM,UAAU,GAAG,IAAA,6BAAqB,EAAC;YACvC,KAAK;SACN,CAAC,CAAC;QACH,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAGP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACxC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,KAAK,GAAkB,IAAA,eAAO,EAClC,GAAG,EAAE,CAAC,IAAA,mCAAmB,EAAC,eAAe,CAAC,EAC1C,CAAC,eAAe,CAAC,CAClB,CAAC;IAEF,OAAO,CACL,uBAAC,4BAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACxC,QAAQ,GACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,gBAAgB,oBA6B3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnauthenticatedSolidLdoProvider.js","sourceRoot":"","sources":["../src/UnauthenticatedSolidLdoProvider.tsx"],"names":[],"mappings":";;;;;;;AACA,iCAAoD;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
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from "./BrowserSolidLdoProvider";
2
- export * from "./UnauthenticatedSolidLdoProvider";
3
- export * from "./SolidAuthContext";
4
- export { useLdo } from "./SolidLdoProvider";
5
- export * from "./useResource";
6
- export * from "./useSubject";
7
- export * from "./useMatchSubject";
8
- export * from "./useMatchObject";
9
- export * from "./useRootContainer";
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,oEAAkD;AAClD,qDAAmC;AAEnC,uDAA4C;AAAnC,0GAAA,MAAM,OAAA;AAGf,gDAA8B;AAC9B,+CAA6B;AAC7B,oDAAkC;AAClC,mDAAiC;AACjC,qDAAmC"}
@@ -1,12 +0,0 @@
1
- import type { LdoBase, ShapeType } from "@ldo/ldo";
2
- import type { SubjectNode } from "@ldo/rdf-utils";
3
- import type { Resource, SolidLdoDataset, SolidLdoTransactionDataset } from "@ldo/solid";
4
- export interface UseLdoMethods {
5
- dataset: SolidLdoDataset;
6
- getResource: SolidLdoDataset["getResource"];
7
- getSubject<Type extends LdoBase>(shapeType: ShapeType<Type>, subject: string | SubjectNode): Type;
8
- createData<Type extends LdoBase>(shapeType: ShapeType<Type>, subject: string | SubjectNode, resource: Resource, ...additionalResources: Resource[]): Type;
9
- changeData<Type extends LdoBase>(input: Type, resource: Resource, ...additionalResources: Resource[]): Type;
10
- commitData(input: LdoBase): ReturnType<SolidLdoTransactionDataset["commitToPod"]>;
11
- }
12
- export declare function createUseLdoMethods(dataset: SolidLdoDataset): UseLdoMethods;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createUseLdoMethods = void 0;
4
- const solid_1 = require("@ldo/solid");
5
- function createUseLdoMethods(dataset) {
6
- return {
7
- dataset: dataset,
8
- getResource: dataset.getResource.bind(dataset),
9
- getSubject(shapeType, subject) {
10
- return dataset.usingType(shapeType).fromSubject(subject);
11
- },
12
- createData(shapeType, subject, resource, ...additionalResources) {
13
- return dataset.createData(shapeType, subject, resource, ...additionalResources);
14
- },
15
- changeData: solid_1.changeData,
16
- commitData: solid_1.commitData,
17
- };
18
- }
19
- exports.createUseLdoMethods = createUseLdoMethods;
20
- //# sourceMappingURL=useLdoMethods.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLdoMethods.js","sourceRoot":"","sources":["../src/useLdoMethods.ts"],"names":[],"mappings":";;;AAOA,sCAAoD;AAyBpD,SAAgB,mBAAmB,CAAC,OAAwB;IAC1D,OAAO;QACL,OAAO,EAAE,OAAO;QAIhB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC;QAO9C,UAAU,CACR,SAA0B,EAC1B,OAA6B;YAE7B,OAAO,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC;QAQD,UAAU,CACR,SAA0B,EAC1B,OAA6B,EAC7B,QAAkB,EAClB,GAAG,mBAA+B;YAElC,OAAO,OAAO,CAAC,UAAU,CACvB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,mBAAmB,CACvB,CAAC;QACJ,CAAC;QAMD,UAAU,EAAE,kBAAU;QAKtB,UAAU,EAAE,kBAAU;KACvB,CAAC;AACJ,CAAC;AAnDD,kDAmDC"}
@@ -1,3 +0,0 @@
1
- import type { LdoBase, ShapeType } from "@ldo/ldo";
2
- import type { QuadMatch } from "@ldo/rdf-utils";
3
- export declare function useMatchObject<Type extends LdoBase>(shapeType: ShapeType<Type>, subject?: QuadMatch[0] | string, predicate?: QuadMatch[1] | string, graph?: QuadMatch[3] | string): Type[];
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMatchObject = void 0;
4
- const react_1 = require("react");
5
- const useTrackingProxy_1 = require("./util/useTrackingProxy");
6
- function useMatchObject(shapeType, subject, predicate, graph) {
7
- const matchObject = (0, react_1.useCallback)((builder) => {
8
- return builder.matchObject(subject, predicate, graph);
9
- }, [subject, predicate, graph]);
10
- return (0, useTrackingProxy_1.useTrackingProxy)(shapeType, matchObject);
11
- }
12
- exports.useMatchObject = useMatchObject;
13
- //# sourceMappingURL=useMatchObject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMatchObject.js","sourceRoot":"","sources":["../src/useMatchObject.ts"],"names":[],"mappings":";;;AAGA,iCAAoC;AACpC,8DAA2D;AAE3D,SAAgB,cAAc,CAC5B,SAA0B,EAC1B,OAA+B,EAC/B,SAAiC,EACjC,KAA6B;IAE7B,MAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,CAAC,OAAyB,EAAE,EAAE;QAC5B,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC,EACD,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAC5B,CAAC;IAEF,OAAO,IAAA,mCAAgB,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAClD,CAAC;AAdD,wCAcC"}
@@ -1,3 +0,0 @@
1
- import type { LdoBase, ShapeType } from "@ldo/ldo";
2
- import type { QuadMatch } from "@ldo/rdf-utils";
3
- export declare function useMatchSubject<Type extends LdoBase>(shapeType: ShapeType<Type>, predicate?: QuadMatch[1] | string, object?: QuadMatch[2] | string, graph?: QuadMatch[3] | string): Type[];
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMatchSubject = void 0;
4
- const react_1 = require("react");
5
- const useTrackingProxy_1 = require("./util/useTrackingProxy");
6
- function useMatchSubject(shapeType, predicate, object, graph) {
7
- const matchSubject = (0, react_1.useCallback)((builder) => {
8
- return builder.matchSubject(predicate, object, graph);
9
- }, [predicate, object, graph]);
10
- return (0, useTrackingProxy_1.useTrackingProxy)(shapeType, matchSubject);
11
- }
12
- exports.useMatchSubject = useMatchSubject;
13
- //# sourceMappingURL=useMatchSubject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMatchSubject.js","sourceRoot":"","sources":["../src/useMatchSubject.ts"],"names":[],"mappings":";;;AAGA,iCAAoC;AACpC,8DAA2D;AAE3D,SAAgB,eAAe,CAC7B,SAA0B,EAC1B,SAAiC,EACjC,MAA8B,EAC9B,KAA6B;IAE7B,MAAM,YAAY,GAAG,IAAA,mBAAW,EAC9B,CAAC,OAAyB,EAAE,EAAE;QAC5B,OAAO,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC,EACD,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAC3B,CAAC;IAEF,OAAO,IAAA,mCAAgB,EAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC;AAdD,0CAcC"}
@@ -1,12 +0,0 @@
1
- import type { Container, ContainerUri, LeafUri, Leaf } from "@ldo/solid";
2
- export interface UseResourceOptions {
3
- suppressInitialRead?: boolean;
4
- reloadOnMount?: boolean;
5
- subscribe?: boolean;
6
- }
7
- export declare function useResource(uri: ContainerUri, options?: UseResourceOptions): Container;
8
- export declare function useResource(uri: LeafUri, options?: UseResourceOptions): Leaf;
9
- export declare function useResource(uri: string, options?: UseResourceOptions): Leaf | Container;
10
- export declare function useResource(uri?: ContainerUri, options?: UseResourceOptions): Container | undefined;
11
- export declare function useResource(uri?: LeafUri, options?: UseResourceOptions): Leaf | undefined;
12
- export declare function useResource(uri?: string, options?: UseResourceOptions): Leaf | Container | undefined;