Skip to content

Commit 7e09265

Browse files
committed
Init
0 parents  commit 7e09265

36 files changed

+8157
-0
lines changed

.eslintrc.cjs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
ignorePatterns: ['dist', '.eslintrc.cjs'],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': [
14+
'warn',
15+
{ allowConstantExport: true },
16+
],
17+
},
18+
}

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

.vercel/output/config.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 3,
3+
"routes": [
4+
{
5+
"src": "/(.*)",
6+
"headers": [
7+
{
8+
"key": "Cross-Origin-Embedder-Policy",
9+
"value": "require-corp"
10+
},
11+
{
12+
"key": "Cross-Origin-Opener-Policy",
13+
"value": "same-origin"
14+
}
15+
]
16+
}
17+
]
18+
}

.yarn/install-state.gz

453 KB
Binary file not shown.

.yarn/releases/yarn-4.0.2.cjs

+893
Large diffs are not rendered by default.

.yarnrc.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
yarnPath: .yarn/releases/yarn-4.0.2.cjs
2+
nodeLinker: node-modules
3+
supportedArchitectures:
4+
cpu:
5+
- "current"
6+
- "wasm32"

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default {
18+
// other rules...
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
sourceType: 'module',
22+
project: ['./tsconfig.json', './tsconfig.node.json'],
23+
tsconfigRootDir: __dirname,
24+
},
25+
}
26+
```
27+
28+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

components.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"tsx": true,
5+
"tailwind": {
6+
"config": "tailwind.config.js",
7+
"css": "src/index.css",
8+
"baseColor": "zinc",
9+
"cssVariables": false,
10+
"prefix": "tw-"
11+
},
12+
"aliases": {
13+
"components": "src/components",
14+
"utils": "src/lib/utils"
15+
}
16+
}

index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>@node-rs playground</title>
9+
</head>
10+
11+
<body class="tw-dark">
12+
<div id="root" class="tw-antialiased tw-bg-slate-900 tw-min-h-lvh tw-text-slate-100"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
15+
16+
</html>

package.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "napi-rs-playground",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@radix-ui/react-label": "^2.0.2",
14+
"@radix-ui/react-menubar": "^1.0.4",
15+
"@radix-ui/react-navigation-menu": "^1.1.4",
16+
"@radix-ui/react-select": "^2.0.0",
17+
"@radix-ui/react-slot": "^1.0.2",
18+
"@radix-ui/react-toast": "^1.1.5",
19+
"class-variance-authority": "^0.7.0",
20+
"clsx": "^2.1.0",
21+
"lucide-react": "^0.311.0",
22+
"react": "^18.2.0",
23+
"react-dom": "^18.2.0",
24+
"tailwind-merge": "^2.2.0",
25+
"tailwindcss-animate": "^1.0.7"
26+
},
27+
"devDependencies": {
28+
"@napi-rs/wasm-runtime": "^0.1.1",
29+
"@node-rs/argon2": "^1.7.2",
30+
"@node-rs/bcrypt": "^1.9.2",
31+
"@node-rs/crc32": "^1.9.2",
32+
"@node-rs/jieba": "^1.9.2",
33+
"@node-rs/xxhash": "^1.6.2",
34+
"@types/react": "^18.2.48",
35+
"@types/react-dom": "^18.2.18",
36+
"@typescript-eslint/eslint-plugin": "^6.19.0",
37+
"@typescript-eslint/parser": "^6.19.0",
38+
"@vitejs/plugin-react": "^4.2.1",
39+
"autoprefixer": "^10.4.16",
40+
"esbuild": "^0.19.11",
41+
"eslint": "^8.56.0",
42+
"eslint-plugin-react-hooks": "^4.6.0",
43+
"eslint-plugin-react-refresh": "^0.4.5",
44+
"postcss": "^8.4.33",
45+
"tailwindcss": "^3.4.1",
46+
"typescript": "^5.3.3",
47+
"vite": "^5.0.11"
48+
},
49+
"packageManager": "[email protected]"
50+
}

postcss.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

src/app.tsx

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { useState } from 'react'
2+
3+
import Argon2 from './argon2'
4+
import Bcrypt from './bcrypt'
5+
import Xxhash from './xxhash'
6+
import {
7+
NavigationMenu,
8+
NavigationMenuItem,
9+
NavigationMenuLink,
10+
NavigationMenuList,
11+
navigationMenuTriggerStyle,
12+
} from './components/ui/navigation-menu'
13+
14+
enum Package {
15+
Argon2 = '@node-rs/argon2',
16+
Bcrypt = '@node-rs/bcrypt',
17+
Jieba = '@node-rs/jieba',
18+
Xxhash = '@node-rs/xxhash',
19+
}
20+
21+
export default function Component() {
22+
const [pkg, setPackage] = useState<Package>(Package.Argon2)
23+
let SubComponent = Argon2
24+
switch (pkg) {
25+
case Package.Argon2:
26+
SubComponent = Argon2
27+
break
28+
case Package.Bcrypt:
29+
SubComponent = Bcrypt
30+
break
31+
case Package.Xxhash:
32+
SubComponent = Xxhash
33+
break
34+
}
35+
return (
36+
<div className="tw-mx-auto tw-max-w-2xl">
37+
<header className="tw-text-center tw-py-8">
38+
<h1 className="tw-text-4xl tw-font-bold">
39+
@node-rs packages playground
40+
</h1>
41+
<p className="tw-mt-2 tw-text-lg">
42+
Demo the <code>@node-rs/argon2</code>, <code>@node-rs/bcrypt</code>,
43+
<code>@node-rs/jieba</code> and <code>@node-rs/xxhash</code> packages
44+
</p>
45+
</header>
46+
<NavigationMenu>
47+
<NavigationMenuList>
48+
<NavigationMenuItem>
49+
<NavigationMenuLink
50+
className={`${navigationMenuTriggerStyle()} tw-cursor-pointer`}
51+
onSelect={() => {
52+
setPackage(Package.Argon2)
53+
}}
54+
active={pkg === Package.Argon2}
55+
>
56+
<code>@node-rs/argon2</code>
57+
</NavigationMenuLink>
58+
</NavigationMenuItem>
59+
<NavigationMenuItem>
60+
<NavigationMenuLink
61+
className={`${navigationMenuTriggerStyle()} tw-cursor-pointer`}
62+
onSelect={() => {
63+
setPackage(Package.Bcrypt)
64+
}}
65+
active={pkg === Package.Bcrypt}
66+
>
67+
<code>@node-rs/bcrypt</code>
68+
</NavigationMenuLink>
69+
</NavigationMenuItem>
70+
<NavigationMenuItem
71+
className="tw-cursor-not-allowed"
72+
value={Package.Jieba}
73+
>
74+
<NavigationMenuLink
75+
className={`${navigationMenuTriggerStyle()}`}
76+
active={pkg === Package.Jieba}
77+
>
78+
<code>@node-rs/jieba</code>
79+
</NavigationMenuLink>
80+
</NavigationMenuItem>
81+
<NavigationMenuItem value={Package.Xxhash}>
82+
<NavigationMenuLink
83+
className={`${navigationMenuTriggerStyle()} tw-cursor-pointer`}
84+
onSelect={() => {
85+
setPackage(Package.Xxhash)
86+
}}
87+
active={pkg === Package.Xxhash}
88+
>
89+
<code>@node-rs/xxhash</code>
90+
</NavigationMenuLink>
91+
</NavigationMenuItem>
92+
</NavigationMenuList>
93+
</NavigationMenu>
94+
<div className="tw-container tw-h-10"></div>
95+
<SubComponent />
96+
</div>
97+
)
98+
}

0 commit comments

Comments
 (0)