Skip to content

Commit

Permalink
add docs+workflow fix demo workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Oct 28, 2024
1 parent 249be03 commit e471bc7
Show file tree
Hide file tree
Showing 38 changed files with 13,561 additions and 3,257 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# name: Deploy Docusaurus site to GitHub Pages

# on:
# push:
# branches:
# - main # or the branch you want to deploy from

# jobs:
# build-deploy:
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: docs

# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# with:
# submodules: true

# - name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version: '16.x' # Ensure this matches your project's Node.js version

# - name: Install dependencies
# run: npm install

# - name: Build Docusaurus site
# run: npm run build

# - name: Deploy to GitHub Pages
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: build
9 changes: 5 additions & 4 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Delete demo/pkg symlink
run: rm -fr demo/pkg
# - name: Delete demos/vanilla-js/pkg symlink
# run: rm -fr demos/vanilla-js/pkg

- name: Setup Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
Expand All @@ -36,14 +36,15 @@ jobs:

- name: Clean and Build with wasm-pack
run: |
cd packages/rust
cargo clean
wasm-pack build --target web --release
- name: Prepare Demo Directory
run: mkdir -p demo/pkg
run: mkdir -p demos/vanilla-js/pkg

- name: Copy Build Artifacts to Demo
run: cp -r pkg/* demo/pkg/
run: cp -r packages/rust/pkg/* demos/vanilla-js/pkg/

- name: Setup GitHub Pages
uses: actions/configure-pages@v5
Expand Down
Binary file modified .yarn/install-state.gz
Binary file not shown.
20 changes: 20 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
41 changes: 41 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus](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.
3 changes: 3 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
78 changes: 78 additions & 0 deletions docs/docs/packages/core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# @notemine/core
**notemine** mines nostr notes, is written in rust, targets web and compiles to wasm. Variable difficulty and realtime hashrate. There's a [demo](https://sandwichfarm.github.io/notemine).

# related
- [`notemine-js`](https://github.com/sandwichfarm/notemine-js) is an npm module that wraps this package with observables for use with modern stacks.
- [`notemine-hw`](https://github.com/plebemineira/notemine_hw) is a fork ported to a cli application that leverages hardware acceleration

# install
```js
npm install notemine
pnpm install notemine
yarn add notemine
```

# usage
```js
import init, { mine_event } from './pkg/notemine.js';

//You shouldn't need to pass id or sig, and created_at is optional.
const event = {
"pubkey": "e771af0b05c8e95fcdf6feb3500544d2fb1ccd384788e9f490bb3ee28e8ed66f",
"kind": 1,
"tags": [],
"content": "hello world",
}

const difficulty = 21
let cancel = false

function reportProgress(hashRate = undefined, bestPow = undefined) {
if(hashRate){
console.log(`hash rate: ${hashRate}`);
}
if(bestPow){
console.log('best pow: ', bestPow);
}
}

function shouldCancel() {
//Add some logic here
//if it returns true, wasm should stop mining.
return cancel
}

const run = async () => {
//this is synchronous.
const minedResult = mine_event(
event,
difficulty,
startNonce.toString(),
nonceStep.toString(),
reportProgress,
shouldCancel
);
}
await init({});
```

# build

## deps
```
cargo install wasm-pack
```

## build
```
cargo clean
wasm-pack build --target web --release
```

## run demo
```
cd demo && npx serve
```

# license
GNU General Public License v3.0
24 changes: 24 additions & 0 deletions docs/docs/packages/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# notemine⛏️

**notemine** mines nostr notes, is written in rust, targets web and compiles to wasm. Variable difficulty and realtime hashrate. There's some [demos](https://sandwichfarm.github.io/notemine).

## Packages:
- [`@notemine/core`](./packages/core/) - It is in here you find the `rust` source for the moner. Build step generates JS Bindings, type declarations and wasm file via `wasm-bindgen`. The base of all packages in this monorepo.
- [`@notemine/wrapper`](./packages/wrapper/) - A user-friendly wrapper for `@notemine/core` that greatly simplifies usage in modern stacks and deployments with modern bundlers. Provides observables, manages workers, tracks internal state and bundles wasm as _inline base64_ within _inline_ web-workers for hassle-free use in modern apps targeted for the browser.
- _[`@notemine/svelte`](./packages/svelte/)_ [coming soon] - Library optimized for Svelte that exports stores and components for hassle-free use in svelte projects.
- _[`@notemine/reactjs`](./packages/reactjs/)_ [coming soon] - Library optimized for ReactJS that exports stores and components for hassle-free use in svelte projects.

## Demos:
- [`@notemine/vanilla-js-demo`](./demos/vanilla-js/) - Demo of Notemine written with vanilla Javascript, HTML and CSS that implements `@notemine/core`. No bundlers.
- [`@notemine/svelte-demo`](./demos/svelte/) - Vanilla JS Demo Ported to Svelte that implements `@notemine/wrapper` (note: future version will implement `@notemine/svelte`)

## Contrib
`@notemine` monorepo presently uses `yarn workspaces` without any monorepo toolkit (pending). Recommended to use `yarn v2` until monorepo is fully configured.
```
yarn install
```

Use workspace commands:
```
yarn workspace @notemine/wrapper ...
```
3 changes: 3 additions & 0 deletions docs/docs/packages/reactjs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@notemine/reactjs`

Future home of `notemine` for ReactJS.
16 changes: 16 additions & 0 deletions docs/docs/packages/rust.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# @notemine/rust
Rust source code for **notemine** that compiles to WASM.

# deps
```
cargo install wasm-pack
```

# build
```
cargo clean
wasm-pack build --target web --release
```

# license
GNU General Public License v3.0
3 changes: 3 additions & 0 deletions docs/docs/packages/svelte.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@notemine/svelte`

Future home of `notemine` for svelte.
Loading

0 comments on commit e471bc7

Please sign in to comment.