@raster-app/react 0.1.0-canary-fd0f8dd → 0.1.0-canary-84a5119
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 +33 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -69,9 +69,11 @@ The same provider gives your components hooks.
|
|
|
69
69
|
import {
|
|
70
70
|
RasterProvider,
|
|
71
71
|
createRasterClient,
|
|
72
|
+
getThumbUrl,
|
|
72
73
|
localStorageCredentialStore,
|
|
73
74
|
useAssets,
|
|
74
75
|
useSession,
|
|
76
|
+
useSignIn,
|
|
75
77
|
} from '@raster-app/react'
|
|
76
78
|
|
|
77
79
|
// Create the client once, outside any component.
|
|
@@ -89,12 +91,39 @@ export function App() {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
function Library() {
|
|
92
|
-
const { credentials, isConfigured } = useSession()
|
|
94
|
+
const { credentials, isConfigured, signOut } = useSession()
|
|
95
|
+
const { state, signInWithDevice } = useSignIn()
|
|
96
|
+
// Your organization's and library's ids.
|
|
93
97
|
const { assets, hasMore, loadMore } = useAssets({ organizationId: 'acme', libraryId: 'lib-1' })
|
|
94
98
|
|
|
95
|
-
if (credentials === undefined) return null // still
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
if (credentials === undefined) return null // still reading the saved sign-in
|
|
100
|
+
|
|
101
|
+
if (!isConfigured) {
|
|
102
|
+
if (state.status === 'awaitingApproval') {
|
|
103
|
+
return <p>Approve {state.device.userCode} in the Raster tab that just opened.</p>
|
|
104
|
+
}
|
|
105
|
+
return (
|
|
106
|
+
<button type="button" onClick={signInWithDevice}>
|
|
107
|
+
Sign in with Raster
|
|
108
|
+
</button>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
{assets?.map((asset) => (
|
|
115
|
+
<img key={asset.id} src={getThumbUrl(asset)} alt={asset.name ?? ''} width={200} />
|
|
116
|
+
))}
|
|
117
|
+
{hasMore && (
|
|
118
|
+
<button type="button" onClick={loadMore}>
|
|
119
|
+
Load more
|
|
120
|
+
</button>
|
|
121
|
+
)}
|
|
122
|
+
<button type="button" onClick={signOut}>
|
|
123
|
+
Sign out
|
|
124
|
+
</button>
|
|
125
|
+
</>
|
|
126
|
+
)
|
|
98
127
|
}
|
|
99
128
|
```
|
|
100
129
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raster-app/react",
|
|
3
|
-
"version": "0.1.0-canary-
|
|
3
|
+
"version": "0.1.0-canary-84a5119",
|
|
4
4
|
"description": "React provider and hooks for the Raster SDK: session, organizations, libraries, assets, search and uploads.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://raster.app/docs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"test": "bun test"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@raster-app/sdk": "0.1.0-canary-
|
|
43
|
+
"@raster-app/sdk": "0.1.0-canary-84a5119",
|
|
44
44
|
"@tanstack/react-query": "^5.103.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|