-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: TSDoc, new TypeDoc theme, re-export of common React APIs (#846)
* fix: TSDoc, new TypeDoc theme, re-export of common React APIs * Fixes linting issue * Removes invalid TSDoc tag
- Loading branch information
1 parent
a501740
commit 7b1cbde
Showing
65 changed files
with
536 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@lens-protocol/react-native": patch | ||
"@lens-protocol/react-web": patch | ||
"@lens-protocol/client": patch | ||
"@lens-protocol/react": patch | ||
--- | ||
|
||
**fix:** TSDoc and better exporting of shared parts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=SF+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap"); | ||
|
||
:root, | ||
:root[data-theme="light"], | ||
:root[data-theme="dark"] { | ||
--font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, | ||
"Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol" !important; | ||
--font-mono: "SF Mono", "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, Courier, monospace !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,53 @@ | ||
# `@lens-protocol/client` | ||
# Lens JavaScript SDK | ||
|
||
The official framework-agnostic Lens API Client. | ||
The official framework-agnostic JavaScript SDK for Lens Protocol. | ||
|
||
--- | ||
|
||
This package enables you to interact with the Lens API via a type safe interface that abstracts away some of the GraphQL intricacies. | ||
|
||
## Documentation | ||
|
||
- [GitHub monorepo](https://github.com/lens-protocol/lens-sdk) | ||
- [Getting Started](https://docs.lens.xyz/docs/lensclient-sdk-1) | ||
- [Reference](https://lens-protocol.github.io/lens-sdk/modules/_lens_protocol_client.html) | ||
|
||
## Quick start | ||
|
||
Install the Lens React Native SDK package using your package manager of choice: | ||
|
||
| Package Manager | Command | | ||
| :-------------: | :----------------------------------------- | | ||
| npm | `npm install @lens-protocol/client@latest` | | ||
| yarn | `yarn add @lens-protocol/client@latest` | | ||
| pnpm | `pnpm add @lens-protocol/client@latest` | | ||
|
||
Development configuration example: | ||
|
||
```ts | ||
import { LensClient, development } from '@lens-protocol/client'; | ||
|
||
const client = new LensClient({ | ||
environment: development, | ||
}); | ||
``` | ||
|
||
Production configuration example: | ||
|
||
```ts | ||
import { LensClient, production } from '@lens-protocol/client'; | ||
|
||
const client = new LensClient({ | ||
environment: production, | ||
}); | ||
``` | ||
|
||
In a browser-based implementation you can use the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) to persist authentication state. | ||
|
||
```ts | ||
const client = new LensClient({ | ||
environment: production, | ||
|
||
storage: window.localStorage, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,78 @@ | ||
# `@lens-protocol/react-native` | ||
# Lens React Native SDK | ||
|
||
The official Lens Protocol React bindings for React Native. | ||
|
||
--- | ||
|
||
This package enables you to build mobile applications on top of the Lens Protocol using React Native. | ||
|
||
## Documentation | ||
|
||
- [GitHub monorepo](https://github.com/lens-protocol/lens-sdk) | ||
- [Getting Started](https://lens-protocol.github.io/lens-sdk/modules/_lens_protocol_react_web.html#md:quick-start) | ||
- [SDK Reference](https://lens-protocol.github.io/lens-sdk/modules/_lens_protocol_react_web.html) | ||
- [Reference](https://lens-protocol.github.io/lens-sdk/modules/_lens_protocol_react_native.html) | ||
|
||
## Quick start | ||
|
||
Install the Lens React Native SDK package using your package manager of choice: | ||
|
||
| Package Manager | Command | | ||
| :-------------: | :----------------------------------------------- | | ||
| npm | `npm install @lens-protocol/react-native@latest` | | ||
| yarn | `yarn add @lens-protocol/react-native@latest` | | ||
| pnpm | `pnpm add @lens-protocol/react-native@latest` | | ||
|
||
First we need to create so-called bindings. Bindings are just an object implementing the `IBindings` interface. This is used by the Lens SDK to access the Signer and the Provider. | ||
|
||
In this example we will limit ourselves to the bare minimum and we will use the `ethers.js` library to create the bindings. | ||
|
||
```ts | ||
// wallet.ts | ||
import { IBindings } from '@lens-protocol/react-native'; | ||
import { providers, Wallet } from 'ethers'; | ||
|
||
const provider = new providers.InfuraProvider('maticmum'); | ||
const wallet = new Wallet('<your-private-key>', provider); | ||
|
||
export const bindings: IBindings = { | ||
getProvider: async () => provider, | ||
getSigner: async () => wallet, | ||
}; | ||
``` | ||
|
||
Create the `LensConfig`. In this example we will use `react-native-mmkk` as underlying storage. You can use any storage you want as long as it implements the `IStorageProvider` interface. | ||
|
||
First install the `react-native-mmkv` package: | ||
|
||
| Package Manager | Command | | ||
| :-------------: | :------------------------------ | | ||
| npm | `npm install react-native-mmkv` | | ||
| yarn | `yarn add react-native-mmkv` | | ||
| pnpm | `pnpm add react-native-mmkv` | | ||
|
||
Create the `LensConfig` object: | ||
|
||
```ts | ||
import { LensConfig, development } from '@lens-protocol/react-web'; | ||
import { storage } from '@lens-protocol/react-web/storage/mmkv'; | ||
import { bindings } from './wallet.ts'; | ||
|
||
const lensConfig: LensConfig = { | ||
bindings, | ||
environment: development, | ||
storage: storage(), | ||
}; | ||
``` | ||
|
||
Wrap your app with the `<LensProvider>` and pass the `LensConfig` as a prop. | ||
|
||
```tsx | ||
import { LensProvider } from '@lens-protocol/react-web'; | ||
|
||
function App() { | ||
return ( | ||
<LensProvider config={lensConfig}> | ||
<YourApp /> | ||
</LensProvider> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { BaseProvider, EnvironmentConfig, IBindings, QueryParams } from '@lens-protocol/react'; | ||
import { ILogger } from '@lens-protocol/shared-kernel'; | ||
import { IObservableStorageProvider, IStorageProvider } from '@lens-protocol/storage'; | ||
import { ReactNode } from 'react'; | ||
|
||
/** | ||
* `<LensProvider>` configuration | ||
*/ | ||
export type LensConfig = { | ||
/** | ||
* Provides integration with the ethers.js Signer and Provider | ||
*/ | ||
bindings: IBindings; | ||
/** | ||
* The environment to use. See {@link production} or {@link development}. | ||
*/ | ||
environment: EnvironmentConfig; | ||
/** | ||
* The logger interface to use when something worth logging happens | ||
* | ||
* @defaultValue `ConsoleLogger`, an internal implementation of `ILogger` interface that logs to the console | ||
*/ | ||
logger?: ILogger; | ||
/** | ||
* Enable debug mode. Disable gas estimation on self-funded transactions. | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
debug?: boolean; | ||
/** | ||
* The storage provider to use. | ||
* | ||
* If a implementation of {@link IObservableStorageProvider} is provided, | ||
* the provider will be used to subscribe to changes in the storage. | ||
*/ | ||
storage: IStorageProvider | IObservableStorageProvider; | ||
/** | ||
* The common query params allow you customize some aspect of the returned data. | ||
*/ | ||
params?: QueryParams; | ||
/** | ||
* The value of the `Origin` HTTP header to use when making requests to the Lens API. | ||
* | ||
* @example | ||
* ```md | ||
* https://example.xyz | ||
* ``` | ||
* | ||
* @defaultValue if not provided, the requests will be made without the `Origin` header. | ||
*/ | ||
origin?: string; | ||
}; | ||
|
||
/** | ||
* <LensProvider> props | ||
*/ | ||
export type LensProviderProps = { | ||
/** | ||
* The children to render | ||
*/ | ||
children: ReactNode; | ||
/** | ||
* The configuration for the Lens SDK | ||
*/ | ||
config: LensConfig; | ||
}; | ||
|
||
/** | ||
* Manages the lifecycle and internal state of the Lens SDK | ||
* | ||
* @group Components | ||
* @param props - {@link LensProviderProps} | ||
*/ | ||
export const LensProvider = BaseProvider<LensConfig>; |
Oops, something went wrong.