Skip to content

Commit

Permalink
Merge pull request #12 from sandwichfarm/monorepo
Browse files Browse the repository at this point in the history
Monorepo
  • Loading branch information
dskvr authored Oct 28, 2024
2 parents be85901 + 964c022 commit 20e609f
Show file tree
Hide file tree
Showing 76 changed files with 11,887 additions and 30 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
notemine
target

./pkg
!./demo/pkg
node_modules
dist
**/*/node_modules
**/*/dist
target
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# note⛏️
**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).
# @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
**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).

# deps
```
cargo install wasm-pack
```
## 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`)

# build
## Contrib
`@notemine` monorepo presently uses `yarn workspaces` without any monorepo toolkit (pending). Recommended to use `yarn v2` until monorepo is fully configured.
```
cargo clean
wasm-pack build --target web --release
yarn install
```

# run demo
Use workspace commands:
```
cd demo && npx serve
yarn workspace @notemine/wrapper ...
```

# license
GNU General Public License v3.0

1 change: 0 additions & 1 deletion demo/pkg

This file was deleted.

Empty file added demos/reactjs/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions demos/svelte-demo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"jsx-a11y/rule-name": "off"
}
}
4 changes: 4 additions & 0 deletions demos/svelte-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
/public/build/

.DS_Store
Empty file added demos/svelte-demo/.gitkeep
Empty file.
18 changes: 18 additions & 0 deletions demos/svelte-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# `@notemine/svelte-demo`

The vanilla-js demo ported to Svelte with `@notemine/wrapper` as the dependency instead of `@notemine/core`

```
yarn install
```

## Usage
Run development server
```
yarn dev
```

Build package
```
yarn build
```
36 changes: 36 additions & 0 deletions demos/svelte-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@notemine/svelte-demo",
"version": "0.1.0",
"type": "module",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear"
},
"dependencies": {
"@notemine/wrapper": "workspace:*",
"@rollup/plugin-alias": "5.1.1",
"@rollup/plugin-url": "8.0.2",
"@rollup/plugin-wasm": "6.2.2",
"nostr-tools": "2.7.2",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.36.0",
"rollup-plugin-web-worker-loader": "1.6.1",
"sirv-cli": "^2.0.0",
"webpack-env": "0.8.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "28.0.0",
"@rollup/plugin-node-resolve": "15.3.0",
"@rollup/plugin-terser": "^0.4.0",
"rollup": "^3.15.0",
"rollup-plugin-copy": "3.5.0",
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-postcss": "4.0.2",
"rollup-plugin-svelte": "^7.1.2",
"svelte": "^3.55.0",
"svelte-preprocess": "6.0.2",
"webpack": "5.94.0"
}
}
Binary file added demos/svelte-demo/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions demos/svelte-demo/public/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
html, body {
position: relative;
width: 100%;
height: 100%;
}

body {
color: #333;
margin: 0;
padding: 8px;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

a {
color: rgb(0,100,200);
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

a:visited {
color: rgb(0,80,160);
}

label {
display: block;
}

input, button, select, textarea {
font-family: inherit;
font-size: inherit;
-webkit-padding: 0.4em 0;
padding: 0.4em;
margin: 0 0 0.5em 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 2px;
}

input:disabled {
color: #ccc;
}

button {
color: #333;
background-color: #f4f4f4;
outline: none;
}

button:disabled {
color: #999;
}

button:not(:disabled):active {
background-color: #ddd;
}

button:focus {
border-color: #666;
}
File renamed without changes
18 changes: 18 additions & 0 deletions demos/svelte-demo/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>

<title>Svelte app</title>

<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/bundle.css'>

<script defer src='/build/bundle.js'></script>
</head>

<body>
</body>
</html>
92 changes: 92 additions & 0 deletions demos/svelte-demo/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import wasm from '@rollup/plugin-wasm';
import postcss from 'rollup-plugin-postcss';
import { terser } from 'rollup-plugin-terser';
import { sveltePreprocess } from 'svelte-preprocess';
import livereload from 'rollup-plugin-livereload';
import { spawn } from 'child_process';
import copy from 'rollup-plugin-copy'
import alias from '@rollup/plugin-alias';


const production = !process.env.ROLLUP_WATCH;

function serve() {
let server;

function toExit() {
if (server) server.kill(0);
}

return {
writeBundle() {
if (server) return;
server = spawn('yarn', ['start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
});

process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
}

export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife', // IIFE format works well in the browser context
name: 'app',
file: 'public/build/bundle.js',
},
plugins: [
svelte({
compilerOptions: {
dev: !production,
},
preprocess: sveltePreprocess(),
}),

resolve({
browser: true,
dedupe: ['svelte'],
}),

commonjs({
include: 'node_modules/**', // Ensure CommonJS modules are properly handled
sourceMap: !production,
}),

copy({
targets: [
{ src: 'node_modules/@notemine/wrapper/dist/notemine_bg.wasm', dest: 'public/build' }
]
}),

// typescript({
// include: ['src/**/*', 'node_modules/@notemine/wrapper/dist/**/*'],
// }),

wasm(), // Handle WASM files

// Add PostCSS for CSS handling
postcss({
extract: true,
}),

// Auto-reload in development mode
!production && serve(),
!production && livereload('public'),

// Minify for production
production && terser(),
],

watch: {
clearScreen: false,
},
};
Loading

0 comments on commit 20e609f

Please sign in to comment.