plugins init commit

This commit is contained in:
Hossein Mehrabi 2022-10-19 18:00:28 +03:30
parent bcd5902d8b
commit a05951f6b7
188 changed files with 6754 additions and 3446 deletions

37
.gitignore vendored
View File

@ -1,26 +1,23 @@
# Dependencies
/node_modules
.DS_Store
.vscode/*
!.vscode/extensions.json
.idea
*.iml
*.code-workspace
.changelog
.history
# Production
/build
node_modules
.yarn
# Generated files
.eslintcache
yarn-error.log
build
coverage
.docusaurus
.cache-loader
# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
packages/logos-*/lib/*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.yalc
yalc.lock
.idea
static/search-index.json
lerna-debug.log

View File

@ -1,2 +0,0 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

View File

@ -2,4 +2,3 @@
. "$(dirname -- "$0")/_/husky.sh"
yarn prettier:staged
yarn typecheck

5
.idea/.gitignore vendored
View File

@ -1,5 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/logos-documentation-website-template.iml" filepath="$PROJECT_DIR$/.idea/logos-documentation-website-template.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,2 +1,9 @@
*.mdx
*.md
dist
node_modules
.yarn
build
coverage
.docusaurus
__fixtures__
packages/logos-*/lib/*

View File

@ -1,41 +0,0 @@
# Website
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
### Installation
```
$ yarn
```
### Local Development
```
$ yarn start
```
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
### Build
```
$ yarn build
```
This command generates static content into the `build` directory and can be served using any static contents hosting service.
### Deployment
Using SSH:
```
$ USE_SSH=true yarn deploy
```
Not using SSH:
```
$ GIT_USER=<Your GitHub username> yarn deploy
```
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

View File

@ -1,3 +0,0 @@
module.exports = {
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
};

View File

@ -1,9 +0,0 @@
---
sidebar_position: 4
title: Blog
description: Codex is building a Decentralized Durability Storage Engine
---
import {BlogPosts} from '@site/src/components/mdx/BlogPosts';
# Blog Posts
<BlogPosts/>

View File

@ -1,147 +0,0 @@
---
sidebar_position: 2
description: Codex is building a Decentralized Durability Storage Engine
---
# How to use Codex
> The Codex project aims to create a decentralized durability engine that allows persisting data in p2p networks. In other words, it allows storing files and data with predictable durability guarantees for later retrieval.
> WARNING: This project is under active development and is considered pre-alpha.
[![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](#stability)
[![CI](https://github.com/status-im/nim-codex/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/status-im/nim-codex/actions?query=workflow%3ACI+branch%3Amain)
[![Codecov](https://codecov.io/gh/status-im/nim-codex/branch/main/graph/badge.svg?token=XFmCyPSNzW)](https://codecov.io/gh/status-im/nim-codex)
[![Discord](https://img.shields.io/discord/895609329053474826)](https://discord.gg/CaJTh24ddQ)
## Build and Run
For detailed instructions on preparing to build nim-codex see [*Building Codex*](BUILDING.md).
To build the project, clone it and run:
```bash
make update && make exec
```
The executable will be placed under the `build` directory under the project root.
Run the client with:
```bash
build/codex
```
### CLI Options
```
build/codex --help
Usage:
codex [OPTIONS]... command
The following options are available:
--log-level Sets the log level [=LogLevel.INFO].
--metrics Enable the metrics server [=false].
--metrics-address Listening address of the metrics server [=127.0.0.1].
--metrics-port Listening HTTP port of the metrics server [=8008].
-d, --data-dir The directory where codex will store configuration and data..
-l, --listen-port Specifies one or more listening ports for the node to listen on. [=0].
-i, --listen-ip The public IP [=0.0.0.0].
--udp-port Specify the discovery (UDP) port [=8090].
--net-privkey Source of network (secp256k1) private key file (random|<path>) [=random].
-b, --bootstrap-node Specifies one or more bootstrap nodes to use when connecting to the network..
--max-peers The maximum number of peers to connect to [=160].
--agent-string Node agent string which is used as identifier in network [=Codex].
-p, --api-port The REST Api port [=8080].
-c, --cache-size The size in MiB of the block cache, 0 disables the cache [=100].
--persistence Enables persistence mechanism, requires an Ethereum node [=false].
--eth-provider The URL of the JSON-RPC API of the Ethereum node [=ws://localhost:8545].
--eth-account The Ethereum account that is used for storage contracts [=EthAddress.none].
--eth-deployment The json file describing the contract deployment [=string.none].
Available sub-commands:
codex initNode
```
### Example: running two Codex clients
```bash
build/codex --data-dir="$(pwd)/Codex1" -i=127.0.0.1
```
This will start codex with a data directory pointing to `Codex1` under the current execution directory and announce itself on the DHT under `127.0.0.1`.
To run a second client that automatically discovers nodes on the network, we need to get the Signed Peer Record (SPR) of first client, Client1. We can do this by querying the `/info` endpoint of the node's REST API.
`curl http://127.0.0.1:8080/api/codex/v1/info`
This should output information about Client1, including its PeerID, TCP/UDP addresses, data directory, and SPR:
```json
{
"id": "16Uiu2HAm92LGXYTuhtLaZzkFnsCx6FFJsNmswK6o9oPXFbSKHQEa",
"addrs": [
"/ip4/0.0.0.0/udp/8090",
"/ip4/0.0.0.0/tcp/49336"
],
"repo": "/repos/status-im/nim-codex/Codex1",
"spr": "spr:CiUIAhIhAmqg5fVU2yxPStLdUOWgwrkWZMHW2MHf6i6l8IjA4tssEgIDARpICicAJQgCEiECaqDl9VTbLE9K0t1Q5aDCuRZkwdbYwd_qLqXwiMDi2ywQ5v2VlAYaCwoJBH8AAAGRAh-aGgoKCAR_AAABBts3KkcwRQIhAPOKl38CviplVbMVnA_9q3N1K_nk5oGuNp7DWeOqiJzzAiATQ2acPyQvPxLU9YS-TiVo4RUXndRcwMFMX2Yjhw8k3A"
}
```
Now, let's start a second client, Client2. Because we're already using the default ports TCP (:8080) and UDP (:8090) for the first client, we have to specify new ports to avoid a collision. Additionally, we can specify the SPR from Client1 as the bootstrap node for discovery purposes, allowing Client2 to determine where content is located in the network.
```bash
build/codex --data-dir="$(pwd)/Codex2" -i=127.0.0.1 --api-port=8081 --udp-port=8091 --bootstrap-node=spr:CiUIAhIhAmqg5fVU2yxPStLdUOWgwrkWZMHW2MHf6i6l8IjA4tssEgIDARpICicAJQgCEiECaqDl9VTbLE9K0t1Q5aDCuRZkwdbYwd_qLqXwiMDi2ywQ5v2VlAYaCwoJBH8AAAGRAh-aGgoKCAR_AAABBts3KkcwRQIhAPOKl38CviplVbMVnA_9q3N1K_nk5oGuNp7DWeOqiJzzAiATQ2acPyQvPxLU9YS-TiVo4RUXndRcwMFMX2Yjhw8k3A
```
There are now two clients running. We could upload a file to Client1 and download that file (given its CID) using Client2, by using the clients' REST API.
## Interacting with the client
The client exposes a REST API that can be used to interact with the clients. These commands could be invoked with any HTTP client, however the following endpoints assume the use of the `curl` command.
### `/api/codex/v1/connect/{peerId}`
Connect to a peer identified by its peer id. Takes an optional `addrs` parameter with a list of valid [multiaddresses](https://multiformats.io/multiaddr/). If `addrs` is absent, the peer will be discovered over the DHT.
Example:
```bash
curl "127.0.0.1:8080/api/codex/v1/connect/<peer id>?addrs=<multiaddress>"
```
### `/api/codex/v1/download/{id}`
Download data identified by a `Cid`.
Example:
```bash
curl -vvv "127.0.0.1:8080/api/codex/v1/download/<Cid of the content>" --output <name of output file>
```
### `/api/codex/v1/upload`
Upload a file, upon success returns the `Cid` of the uploaded file.
Example:
```bash
curl -vvv -H "content-type: application/octet-stream" -H Expect: -T "<path to file>" "127.0.0.1:8080/api/codex/v1/upload" -X POST
```
### `/api/codex/v1/info`
Get useful node info such as its peer id, address and SPR.
Example:
```bash
curl -vvv "127.0.0.1:8080/api/codex/v1/info"
```

View File

@ -1,70 +0,0 @@
---
sidebar_position: 1
title: Home
description: Codex is building a Decentralized Durability Storage Engine
---
import {Hero} from '@site/src/components/mdx/Hero';
import {FeatureList} from '@site/src/components/mdx/FeatureList';
import {FeatureCard} from '@site/src/components/mdx/FeatureCard';
import {Quote} from '@site/src/components/mdx/Quote';
import {ExternalReferenceCard} from '@site/src/components/mdx/ExternalReferenceCard';
import {TeamList} from '@site/src/components/mdx/TeamList';
import {BlogPosts} from '@site/src/components/mdx/BlogPosts';
<Hero title={"Codex"}
subtitle={"Codex is building a Decentralized Durability Storage Engine"}
linkText={"PoC Dagger"}
label={"Introduction"}
linkUrl={"https://github.com/status-im/nim-codex"}/>
## What is Codex?
<Quote>
<ul>
<li>Codex is aiming to solve the fundamental issues of data durability in decentralized systems.</li>
<li>Codex is a research group working in all areas of decentralized storage.</li>
<li>Codex is a decentralized storage protocol for durable information.</li>
</ul>
</Quote>
## Features
<FeatureList>
<FeatureCard title={"Fast erasure coding"}
index={0}
text={"Codex uses high-performance Reed-Solomon encoding to guarantee the durability of the datasets."}/>
<FeatureCard title={"SNARK-based proof of retrievability"}
index={1}
text={"To implement space-efficient data retrievability, Codex leverages state-of-the-art SNARK-based proofs."}/>
<FeatureCard title={"Low-overhead lazy repair"}
index={2}
text={"Data repairs in Codex are grouped through lazy repair to decrease network bandwidth overhead."}/>
<FeatureCard title={"Data Availability Sampling"}
index={3}
text={"Codex samples datasets frequently to guarantee data durability in a Byzantine environment."}/>
</FeatureList>
## Blog Posts
<BlogPosts/>
## Resources
<ExternalReferenceCard linkUrl={"/docs/codex-whitepaper.pdf"}
linkText={"White-paper"}
referenceType={"pdf"}
>
Read our white-paper to know more about Codex.
</ExternalReferenceCard>
<ExternalReferenceCard linkUrl={"https://github.com/status-im/nim-codex"}
linkText={"Nim Codex"}
referenceType={"github"}
>
Play with the first version of Codex.
</ExternalReferenceCard>
<ExternalReferenceCard linkUrl={"https://github.com/status-im/codex-research"}
linkText={"Codex Research"}
referenceType={"github"}
>
Checkout our research models and track our progress.
</ExternalReferenceCard>
## The Codex Team
<TeamList/>

View File

@ -1,40 +0,0 @@
---
description: Codex is building a Decentralized Durability Storage Engine
---
# Codex Students Program
## About Status
Status is an organization building the tools and infrastructure for the advancement of a secure, private, and open web3. We have been completely distributed since inception. Our team is currently 100+ core contributors strong and welcomes a growing number of community members from all walks of life, scattered all around the globe. We care deeply about open source, and our organizational structure has a minimal hierarchy and no fixed work hours. We believe in working with a high degree of autonomy while supporting the organization's priorities.
## About Codex
The Codex team is working on a next-generation storage engine that attempts to “untie the knot” of incentivized storage. Were building Codex to be a reliable and predictable p2p storage infrastructure that will allow for many business and casual use cases. We rely on strong data possession (PoR and PDP) and incentive schemes to guarantee long-term persistence and data availability. Check some of our current research here: https://github.com/status-im/codex-research
## Students Program
This program is available to undergraduate and graduate students officially enrolled in a university, pursuing their B.Sc. or M.Sc. in the field of Computer Sciences or a related domain. The duration of the program could be between 3 and 6 months.
## Bonus if you have
* Distributed system
* Storage and I/O
* P2P networking
* Analytical modeling
* Scalable simulations
* Data analytics
* Parallel programming
* Stress testing
* Continuous integration
* Technical writing
The Codex Student Program aims to do research and development in, but not limited to:
* P2P and distributed computing scheme: leader election, consensus algorithms
* Proofs of (non-)inclusion, retrievability proofs, availability proofs, fraud proofs
* Game theory, incentivization, tokenomics
* Decentralized storage systems, erasure coding, and storage related proofs
* Storage performance measurement and testing
> The above is not a requirement wed still love to hear from you anyway if you think youd be a great fit for this role!

View File

@ -1,140 +0,0 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
require('dotenv').config()
const lightCodeTheme = require('prism-react-renderer/themes/github')
const darkCodeTheme = require('prism-react-renderer/themes/dracula')
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Codex',
tagline: 'Codex is building a Decentralized Durability Engine Engine',
url: 'https://codex.storage',
baseUrl: '/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',
customFields: {
ghostAPiKey: process.env.GHOST_API_KEY,
},
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'status-im', // Usually your GitHub org/user name.
projectName: 'codex-nim', // Usually your repo name.
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
// editUrl: '',
},
// blog: {
// showReadingTime: true,
// // Please change this to your repo.
// // Remove this to remove the "edit this page" links.
// editUrl:
// 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
// },
theme: {
customCss: require.resolve('./src/css/custom.scss'),
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
docs: { sidebar: { hideable: true } },
metadata: [
{ name: 'keywords', content: 'codex, storage' },
{
name: 'description',
content:
'Codex is building a Decentralized Durability Storage Engine',
},
{ name: 'image', content: 'img/codex-preview-image.png' },
],
colorMode: {
disableSwitch: true,
},
navbar: {
title: '',
logo: {
alt: 'Codex',
src: 'img/logo.svg',
height: 26,
width: 24,
},
items: [
{
to: 'blog',
label: 'Blog',
},
{
type: 'localeDropdown',
position: 'right',
},
],
},
footer: {
logo: {
alt: 'Codex',
src: 'img/logo.svg',
href: '/',
width: 22,
},
links: [
{
title: 'Community',
items: [
{
label: 'Discord',
href: '4qdQN5JaWW',
},
{
label: 'Twitter',
href: 'codexstorage',
},
],
},
],
copyright: `Codex, ${new Date().getFullYear()}`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
}),
plugins: [
'docusaurus-plugin-sass',
[
'@acid-info/docusaurus-search-local',
{
hashed: true,
indexDocs: true,
indexBlog: false,
indexPages: true,
docsRouteBasePath: '/',
},
],
],
}
module.exports = config

6
lerna.json Normal file
View File

@ -0,0 +1,6 @@
{
"version": "0.0.0",
"npmClient": "yarn",
"useWorkspaces": true,
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}

View File

@ -1,61 +1,42 @@
{
"name": "logos-documentation-website-template",
"name": "root",
"version": "0.0.0",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc",
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"watch": "lerna run watch",
"prepare": "husky install",
"prettier": "pretty-quick",
"prettier:staged": "pretty-quick --staged"
},
"dependencies": {
"@acid-info/docusaurus-search-local": "^0.32.1",
"@docusaurus/core": "2.1.0",
"@docusaurus/preset-classic": "2.1.0",
"@mdx-js/react": "^1.6.22",
"@tryghost/content-api": "^1.11.4",
"clsx": "^1.2.1",
"copy-to-clipboard": "^3.3.2",
"dotenv": "^16.0.3",
"lodash": "^4.17.21",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-use": "^17.4.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.1.0",
"@tsconfig/docusaurus": "^1.0.5",
"@types/lodash": "^4.14.186",
"docusaurus-plugin-sass": "^0.2.2",
"@types/node": "^18.0.3",
"@types/react": "^18.0.15",
"cross-env": "^7.0.3",
"gulp": "^4.0.2",
"gulp-cli": "^2.3.0",
"gulp-replace": "^1.1.3",
"gulp-sass": "^5.1.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"husky": "^8.0.1",
"lerna": "^6.0.1",
"merge2": "^1.4.1",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"sass": "^1.55.0",
"typescript": "^4.7.4"
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rimraf": "^3.0.2",
"typescript": "~4.7.4",
"typescript-transform-paths": "^3.3.1"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"engines": {
"node": ">=16.14"
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
}
}

View File

@ -0,0 +1,33 @@
{
"name": "@acid-info/logos-docusaurus-search-local",
"version": "0.1.0",
"description": "Docusaurus local search plugin",
"main": "lib/index.js",
"types": "src/theme.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/acid-info/logos-docusaurus-plugins.git",
"directory": "packages/docusaurus-search-local"
},
"license": "MIT",
"scripts": {
"build": "tsc --build",
"watch": "tsc --build --watch"
},
"dependencies": {
"@docusaurus/core": "2.1.0",
"@docusaurus/module-type-aliases": "2.1.0",
"@docusaurus/types": "2.1.0",
"@docusaurus/utils": "2.1.0",
"@docusaurus/utils-common": "2.1.0",
"@docusaurus/utils-validation": "2.1.0",
"@easyops-cn/docusaurus-search-local": "^0.33.2",
"lodash": "^4.17.21"
},
"engines": {
"node": ">=16.14"
},
"devDependencies": {
"@types/lodash": "^4.14.186"
}
}

View File

@ -0,0 +1,141 @@
import {
SearchDocument,
SearchDocumentType,
SearchResult,
// @ts-ignore
} from '@easyops-cn/docusaurus-search-local/dist/client/shared/interfaces'
// @ts-ignore
import { fetchIndexes } from '@easyops-cn/docusaurus-search-local/dist/client/client/theme/SearchBar/fetchIndexes'
// @ts-ignore
import { getStemmedPositions } from '@easyops-cn/docusaurus-search-local/dist/client/client/utils/getStemmedPositions'
// @ts-ignore
import { highlightStemmed } from '@easyops-cn/docusaurus-search-local/dist/client/client/utils/highlightStemmed'
// @ts-ignore
import { SearchSourceFactory } from '@easyops-cn/docusaurus-search-local/dist/client/client/utils/SearchSourceFactory'
// @ts-ignore
import * as proxied from '@easyops-cn/docusaurus-search-local/dist/client/client/utils/proxiedGenerated'
const loadIndex = async (params: { versionUrl: string }) => {
const { wrappedIndexes, zhDictionary } = await fetchIndexes(params.versionUrl)
return { wrappedIndexes, zhDictionary }
}
class Search {
public baseUrl: string
public loading = false
public source:
| ((input: string, callback: (result: SearchResult[]) => void) => void)
| null = null
constructor(private config: SearchConfig) {
this.baseUrl = config.preferredVersionPath
}
init = async () => {
this.loading = true
const { wrappedIndexes, zhDictionary } = await loadIndex({
versionUrl: this.baseUrl,
})
this.source = SearchSourceFactory(
wrappedIndexes,
zhDictionary,
this.config.resultsLimit,
)
}
query = async (input: string) => {
if (!this.source) throw new Error('Not initialized')
const { promise, callback } = createPromise<SearchResult[]>()
this.source && this.source(input, callback)
return {
results: (await promise).map((result) => this.formatResult(result)),
}
}
formatResult = (result: SearchResult) => {
return {
...result,
type: this.resultTypeToString(result.type),
page: result.page ? this.formatDocument(result.page) : null,
document: result.document ? this.formatDocument(result.document) : null,
highlighted: highlightStemmed(
result.document.t,
getStemmedPositions(result.metadata, 't'),
result.tokens,
),
}
}
resultTypeToString = (type: SearchDocumentType) =>
({ 0: ResultType.Title, 1: ResultType.Heading, 2: ResultType.Paragraph }[
type as number
])
formatDocument = (doc: SearchDocument) => {
return {
id: doc.i,
title: doc.t,
url: doc.u,
hash: doc.h,
parentId: doc.p,
breadcrumb: doc.b,
sectionTitle: doc.s,
}
}
}
export enum ResultType {
Title = 'title',
Heading = 'heading',
Paragraph = 'paragraph',
}
export type SearchConfig = {
resultsLimit: number
preferredVersionPath: string
}
export const createPromise = <T = any>() => {
let resolve: any, reject: any
const promise = new Promise<T>((res, rej) => {
resolve = res
reject = rej
})
const callback = (data: T, error?: Error): void => {
if (error) return void reject(error)
resolve(data)
}
return {
reject,
resolve,
promise,
callback,
}
}
const main = async () => {
if (typeof window === 'undefined') return
const win = window as any
win.getProxiedGeneratedData = () => proxied
win.createSearchInstance = async (config: SearchConfig) => {
const search = new Search(config)
return search
}
}
main()

View File

@ -0,0 +1,31 @@
import type { LoadContext, Plugin } from '@docusaurus/types'
import { PluginOptions } from '@easyops-cn/docusaurus-search-local'
import * as path from 'path'
// @ts-ignore
import searchPlugin from '@easyops-cn/docusaurus-search-local/dist/server/server/index'
// @ts-ignore
import { validateOptions } from '@easyops-cn/docusaurus-search-local/dist/server/server/index'
export default function searchPlugin(
context: LoadContext,
options: PluginOptions,
): Plugin<undefined> {
const plugin = searchPlugin(context, options) as any
delete plugin.getThemePath
delete plugin.getPathsToWatch
delete plugin.contentLoaded
return {
...plugin,
name: 'logos-docusaurus-search-local',
getClientModules: () => [
...(typeof plugin.getClientModules !== 'undefined'
? plugin.getClientModules()
: []),
path.resolve(__dirname, './client/index.js'),
],
}
}
export { validateOptions, type PluginOptions }

View File

@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"composite": true,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo-client",
"rootDir": "src",
"outDir": "lib",
"module": "esnext",
"target": "esnext",
"lib": ["DOM"]
},
"include": ["src/client", "src/*.d.ts"],
"exclude": ["**/__tests__/**"]
}

View File

@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"references": [{ "path": "./tsconfig.client.json" }],
"compilerOptions": {
"noEmit": false,
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
"outDir": "lib",
"lib": ["DOM"]
},
"include": ["src"],
"exclude": ["src/theme", "**/__tests__/**"]
}

View File

@ -0,0 +1,114 @@
const _ = require('lodash')
const gulp = require('gulp')
const path = require('path')
const merge = require('merge2')
const rimraf = require('rimraf')
const ts = require('gulp-typescript')
const replace = require('gulp-replace')
const sourcemaps = require('gulp-sourcemaps')
const sass = require('gulp-sass')(require('sass'))
const { replaceTscAliasPaths } = require('tsc-alias')
const project = ts.createProject('./tsconfig.client.json', {
declaration: true,
isolatedModules: false,
})
const SOURCE_DIR = project.config.compilerOptions.rootDir ?? 'src'
const OUT_DIR = project.config.compilerOptions.outDir ?? 'lib'
const CLIENT_DIR = 'client'
const STATIC_DIR = 'static'
const sourceDir = path.resolve('./', SOURCE_DIR)
const outDir = path.resolve('./', OUT_DIR)
const sourceClientDir = path.join(sourceDir, CLIENT_DIR)
const sourceStaticDir = path.join(sourceClientDir, STATIC_DIR)
const outClientDir = path.join(outDir, CLIENT_DIR)
const outStaticDir = path.join(outClientDir, STATIC_DIR)
const cleanup = async (cb) => {
rimraf(outDir, cb)
}
const build = (cb) => {
return gulp.series(cleanup, buildClient, clientPostBuild, buildServer)(cb)
}
const buildClient = () => {
const compiled = project.src().pipe(sourcemaps.init()).pipe(project())
return merge(compiled.dts, compiled.js.pipe(sourcemaps.write())).pipe(
gulp.dest(outDir),
)
}
const clientPostBuild = (done) =>
gulp.series(
(cb) =>
replaceTscAliasPaths({
configFile: './tsconfig.client.json',
})
.then(cb)
.catch(cb),
() =>
gulp
.src(path.join(outClientDir, '/**/*.js'), { base: outClientDir })
.pipe(
replace(/import (.+?) from '([^']+)\.scss'/g, (str) =>
str.replace('.scss', '.css'),
),
)
.pipe(gulp.dest(outClientDir)),
transpileStyles,
copyStaticFiles,
)(done)
const buildServer = () => {
const project = ts.createProject('./tsconfig.json', {
isolatedModules: false,
})
const compiled = project.src().pipe(project())
return merge(compiled.dts, compiled.js).pipe(gulp.dest(outDir))
}
const transpileSass = () =>
gulp
.src(path.join(sourceClientDir, '**/*.scss'))
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest(outClientDir))
const copyCssFiles = () =>
gulp
.src(path.join(sourceClientDir, '**/*.{css,scss}'), {
base: sourceClientDir,
})
.pipe(gulp.dest(outClientDir))
const copyStaticFiles = () =>
gulp
.src(path.join(sourceStaticDir, '**/*'), { base: sourceStaticDir })
.pipe(gulp.dest(outStaticDir))
const transpileStyles = (cb) => gulp.series(transpileSass, copyCssFiles)(cb)
const watch = async () => {
gulp.watch([path.join(sourceDir, '**/*.{ts,tsx,css,scss}')], (cb) => {
build(cb)
})
}
gulp.task('build', build)
gulp.task('watch', watch)
gulp.task('cleanup', cleanup)
gulp.task('build-server', buildServer)
gulp.task('build-client', buildClient)
gulp.task('client-post-build', clientPostBuild)
gulp.task('transpile-styles', transpileStyles)
gulp.task('copy-static-files', copyStaticFiles)

View File

@ -0,0 +1,61 @@
{
"name": "@acid-info/logos-docusaurus-theme",
"version": "0.1.0",
"description": "A Docusaurus theme for Logos documentation websites",
"main": "lib/index.js",
"types": "src/theme.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/acid-info/logos-docusaurus-plugins.git",
"directory": "packages/logos-docusaurus-theme"
},
"license": "MIT",
"scripts": {
"cleanup": "yarn cleanup",
"watch": "yarn gulp watch",
"build": "yarn gulp build",
"build:client": "yarn gulp build-client && yarn gulp client-post-build",
"build:server": "yarn gulp build-server"
},
"dependencies": {
"@docusaurus/core": "2.1.0",
"@docusaurus/mdx-loader": "2.1.0",
"@docusaurus/module-type-aliases": "2.1.0",
"@docusaurus/plugin-content-blog": "2.1.0",
"@docusaurus/plugin-content-docs": "2.1.0",
"@docusaurus/plugin-content-pages": "2.1.0",
"@docusaurus/theme-classic": "^2.1.0",
"@docusaurus/theme-common": "2.1.0",
"@docusaurus/theme-translations": "2.1.0",
"@docusaurus/types": "2.1.0",
"@docusaurus/utils": "2.1.0",
"@docusaurus/utils-common": "2.1.0",
"@docusaurus/utils-validation": "2.1.0",
"@mdx-js/react": "^1.6.22",
"@tryghost/content-api": "^1.11.4",
"clsx": "^1.2.1",
"copy-text-to-clipboard": "^3.0.1",
"copy-to-clipboard": "^3.3.2",
"docusaurus-plugin-sass": "^0.2.2",
"dotenv": "^16.0.3",
"lodash": "^4.17.21",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-use": "^17.4.0",
"utility-types": "^3.10.0"
},
"devDependencies": {
"@types/lodash": "^4.14.186",
"@types/mdx-js__react": "^1.5.5",
"sass": "^1.55.0",
"tsc-alias": "^1.7.0"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=16.14"
}
}

View File

@ -1,23 +1,23 @@
import React from 'react'
import { useColorMode } from '@docusaurus/theme-common'
import { clsx } from 'clsx'
import React from 'react'
import styles from './style.module.scss'
import DotSvg from '@site/static/icons/dot.svg'
import ArrowRCircleSvg from '@site/static/icons/arrow-right-circle.svg'
import ArrowLCircleSvg from '@site/static/icons/arrow-left-circle.svg'
import GithubSvg from '@site/static/icons/github.svg'
import FolderSvg from '@site/static/icons/folder.svg'
import TwitterSvg from '@site/static/icons/twitter.svg'
import DiscordSvg from '@site/static/icons/discord.svg'
import LinkedinSvg from '@site/static/icons/linkedin.svg'
import DiscourseSvg from '@site/static/icons/discourse.svg'
import TelegramSvg from '@site/static/icons/telegram.svg'
import StatusSvg from '@site/static/icons/status.svg'
import SearchSvg from '@site/static/icons/search.svg'
import DropdownSvg from '@site/static/icons/dropdown.svg'
import GScholarSvg from '@site/static/icons/gscholar.svg'
import ArrowLCircleSvg from '../../static/icons/arrow-left-circle.svg'
import ArrowRCircleSvg from '../../static/icons/arrow-right-circle.svg'
import DiscordSvg from '../../static/icons/discord.svg'
import DiscourseSvg from '../../static/icons/discourse.svg'
import DotSvg from '../../static/icons/dot.svg'
import DropdownSvg from '../../static/icons/dropdown.svg'
import FolderSvg from '../../static/icons/folder.svg'
import GithubSvg from '../../static/icons/github.svg'
import GScholarSvg from '../../static/icons/gscholar.svg'
import LinkedinSvg from '../../static/icons/linkedin.svg'
import SearchSvg from '../../static/icons/search.svg'
import StatusSvg from '../../static/icons/status.svg'
import TelegramSvg from '../../static/icons/telegram.svg'
import TwitterSvg from '../../static/icons/twitter.svg'
type TIconProps = {
size?: 's' | 'm' | 'l'
@ -126,7 +126,6 @@ export const IconSearch = (props: TIconProps): JSX.Element => (
export const IconDropdown = (props: TIconProps): JSX.Element => (
<Icon {...props}>
<DropdownSvg />
</Icon>
)

View File

@ -8,7 +8,7 @@ import {
IconTelegram,
IconGScholar,
} from './Icon'
import { ECommunityProviders } from '@site/src/types/ui.types'
import { ECommunityProviders } from '@logos-theme/types/ui.types'
type TProps = {
handler: string
@ -73,6 +73,6 @@ export const SocialMediaItem = (props: TProps): JSX.Element => {
</a>
)
default:
return null
return <></>
}
}

View File

@ -2,8 +2,9 @@ import React, { useEffect, useState } from 'react'
import clsx from 'clsx'
import styles from './style.module.scss'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
// @ts-ignore
import GhostContentAPI from '@tryghost/content-api'
import { LinkButton } from '@site/src/components/Button/LinkButton'
import { LinkButton } from '@logos-theme/components/Button/LinkButton'
type TProps = {
children: React.ReactNode
@ -28,7 +29,7 @@ const useGhostBlogPosts = (limit: number = 10) => {
siteConfig: {
customFields: { ghostAPiKey },
},
} = useDocusaurusContext()
} = useDocusaurusContext() as any
const [posts, setPosts] = useState<IGhostBlogPost[]>([])
useEffect(() => {

View File

@ -6,7 +6,7 @@ import {
IconFolder,
IconFolderFilled,
IconGithub,
} from '../../Icon'
} from '../../Icon/index'
import styles from './style.module.scss'
type TProps = {

View File

@ -5,7 +5,7 @@ import styles from './style.module.scss'
type TProps = {
title: string
text: string
index?: string
index: string
link?: string
children: React.ReactNode
}

View File

@ -2,7 +2,7 @@ import Link from '@docusaurus/Link'
import clsx from 'clsx'
import React from 'react'
import { ButtonWithIcon } from '../../Button/ButtonWithIcon'
import { IconArrowRightCircle, IconDot } from '../../Icon'
import { IconArrowRightCircle, IconDot } from '../../Icon/index'
import styles from './style.module.scss'
type TProps = {

View File

@ -1,14 +1,14 @@
import React from 'react'
import clsx from 'clsx'
import styles from './style.module.scss'
import { useTeam } from '@site/src/lib/team.utils'
import { ELogosTeamNames } from '@site/src/types/team'
import { useTeam } from '@logos-theme/lib/team.utils'
import { ELogosTeamNames } from '@logos-theme/types/team'
import { SocialMediaItem } from '../../Icon/SocialmediaLink'
import { ECommunityProviders } from '@site/src/types/ui.types'
import { ECommunityProviders } from '@logos-theme/types/ui.types'
import {
globalStore,
selectHiddenSidebar,
} from '@site/src/containers/GlobalStore'
} from '@logos-theme/containers/GlobalStore/index'
type TProps = {
children: React.ReactNode

View File

@ -0,0 +1,7 @@
export * from './BlogPosts'
export * from './ExternalReferenceCard'
export * from './FeatureCard'
export * from './FeatureList'
export * from './Hero'
export * from './Quote'
export * from './TeamList'

View File

@ -1,4 +1,4 @@
import { Store as StoreBase } from '@site/src/lib/store'
import { Store as StoreBase } from '@logos-theme/lib/store/index'
export namespace GlobalStore {
export type State = {

View File

@ -9,10 +9,12 @@ export const settle = async <R, E = Error>(
}
}
export const settleSync = <R, E = Error>(func: () => R): [R, E] => {
export const settleSync = <R, E = Error>(
func: () => R,
): [R, undefined] | [undefined, E] => {
try {
return [func(), null]
} catch (error) {
return [func(), undefined]
} catch (error: any) {
return [undefined, error]
}
}

View File

@ -63,8 +63,8 @@ export class Store<
public Provider: React.FC<React.PropsWithChildren<{ store: StoreType<S> }>> =
({ children, store }) => {
this.stateRef = useRef()
this.setStateRef = useRef()
this.stateRef = useRef(store.state)
this.setStateRef = useRef(store.setState)
this.injectedRef = useRef(this.inject.map((hook) => null))
if (!this.context) {

View File

@ -3,7 +3,7 @@ import { useActivePluginAndVersion } from '@docusaurus/plugin-content-docs/clien
export const useActiveVersionPath = () => {
const data = useActivePluginAndVersion({ failfast: false })
if (data) {
if (data?.activeVersion) {
return data.activeVersion.path
}

View File

@ -12,7 +12,7 @@ export const useWindowEventListener = <K extends keyof WindowEventMap, T = any>(
) => {
useEventListener(
key,
() => typeof window !== 'undefined' && window,
() => typeof window !== 'undefined' && (window as any),
listener,
options,
deps,

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 264 B

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 598 B

After

Width:  |  Height:  |  Size: 598 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 423 B

View File

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

View File

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 164 B

View File

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

View File

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 246 B

View File

Before

Width:  |  Height:  |  Size: 212 B

After

Width:  |  Height:  |  Size: 212 B

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 779 B

After

Width:  |  Height:  |  Size: 779 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 343 B

View File

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 413 B

View File

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

View File

Before

Width:  |  Height:  |  Size: 893 B

After

Width:  |  Height:  |  Size: 893 B

View File

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 251 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Some files were not shown because too many files have changed in this diff Show More