Browse Source

refactor: switch to deno

pull/477/head
Dan Ditomaso 1 year ago
parent
commit
db08542b39
  1. 12
      .github/workflows/ci.yml
  2. 14
      .github/workflows/nightly.yml
  3. 14
      .github/workflows/pr.yml
  4. 14
      .github/workflows/release.yml
  5. 3
      .gitignore
  6. 1
      .npmrc
  7. 9
      .vscode/settings.json
  8. 71
      README.md
  9. 27
      biome.json
  10. 6729
      deno.lock
  11. 36
      package.json
  12. 24
      tsconfig.json
  13. 2
      vite.config.ts

12
.github/workflows/ci.yml

@ -16,14 +16,16 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup bun - name: Setup Deno
uses: oven-sh/setup-bun@v2 uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install Dependencies - name: Install Dependencies
run: bun install run: deno install
- name: Run tests - name: Run tests
run: bun run test:run run: deno task test
- name: Build Package - name: Build Package
run: bun run build run: deno task build

14
.github/workflows/nightly.yml

@ -15,20 +15,22 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup bun - name: Setup Deno
uses: oven-sh/setup-bun@v2 uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install Dependencies - name: Install Dependencies
run: bun install run: deno install
- name: Run tests - name: Run tests
run: bun run test:run run: deno task test
- name: Build Package - name: Build Package
run: bun run build run: deno task build
- name: Package Output - name: Package Output
run: bun run package run: deno task package
- name: Archive compressed build - name: Archive compressed build
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

14
.github/workflows/pr.yml

@ -9,20 +9,22 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup bun - name: Setup Deno
uses: oven-sh/setup-bun@v2 uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install Dependencies - name: Install Dependencies
run: bun install run: deno install
- name: Run tests - name: Run tests
run: bun run test:run run: deno task test
- name: Build Package - name: Build Package
run: bun run build run: deno task build
- name: Compress build - name: Compress build
run: bun run package run: deno task package
- name: Archive compressed build - name: Archive compressed build
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

14
.github/workflows/release.yml

@ -15,20 +15,22 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup bun - name: Setup Deno
uses: oven-sh/setup-bun@v2 uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install Dependencies - name: Install Dependencies
run: bun install run: deno install
- name: Run tests - name: Run tests
run: bun run test:run run: deno task test
- name: Build Package - name: Build Package
run: bun run build run: deno task build
- name: Package Output - name: Package Output
run: bun run package run: deno task package
- name: Archive compressed build - name: Archive compressed build
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

3
.gitignore

@ -2,4 +2,5 @@ dist
node_modules node_modules
stats.html stats.html
.vercel .vercel
dev-dist .vite/deps
dev-dist

1
.npmrc

@ -1 +0,0 @@
@jsr:registry=https://npm.jsr.io

9
.vscode/settings.json

@ -1,7 +1,6 @@
{ {
"editor.defaultFormatter": "biomejs.biome", "deno.enable": true,
"editor.codeActionsOnSave": { "deno.suggest.imports.autoDiscover": true,
"quickfix.biome": "explicit" "editor.formatOnSave": true,
}, "editor.defaultFormatter": "denoland.vscode-deno"
"editor.formatOnSave": true
} }

71
README.md

@ -9,7 +9,8 @@
## Overview ## Overview
Official [Meshtastic](https://meshtastic.org) web interface, that can be hosted or served from a node Official [Meshtastic](https://meshtastic.org) web interface, that can be hosted
or served from a node
**[Hosted version](https://client.meshtastic.org)** **[Hosted version](https://client.meshtastic.org)**
@ -19,7 +20,8 @@ Official [Meshtastic](https://meshtastic.org) web interface, that can be hosted
## Progress Web App Support (PWA) ## Progress Web App Support (PWA)
Meshtastic Web Client now includes Progressive Web App (PWA) functionality, allowing users to: Meshtastic Web Client now includes Progressive Web App (PWA) functionality,
allowing users to:
- Install the app on desktop and mobile devices - Install the app on desktop and mobile devices
- Access the interface offline - Access the interface offline
@ -35,8 +37,10 @@ PWA functionality works with both the hosted version and self-hosted instances.
## Self-host ## Self-host
The client can be self hosted using the precompiled container images with an OCI compatible runtime such as [Docker](https://www.docker.com/) or [Podman](https://podman.io/). The client can be self hosted using the precompiled container images with an OCI
The base image used is [Nginx 1.27](https://hub.docker.com/_/nginx) compatible runtime such as [Docker](https://www.docker.com/) or
[Podman](https://podman.io/). The base image used is
[Nginx 1.27](https://hub.docker.com/_/nginx)
```bash ```bash
# With Docker # With Docker
@ -46,9 +50,11 @@ docker run -d -p 8080:8080 --restart always --name Meshtastic-Web ghcr.io/meshta
podman run -d -p 8080:8080 --restart always --name Meshtastic-Web ghcr.io/meshtastic/web podman run -d -p 8080:8080 --restart always --name Meshtastic-Web ghcr.io/meshtastic/web
``` ```
## Nightly releases ## Nightly releases
Our nightly releases provide the latest development builds with cutting-edge features and fixes. These builds are automatically generated from the latest main branch every night and are available for testing and early adoption. Our nightly releases provide the latest development builds with cutting-edge
features and fixes. These builds are automatically generated from the latest
main branch every night and are available for testing and early adoption.
```bash ```bash
# With Docker # With Docker
@ -57,38 +63,55 @@ docker run -d -p 8080:8080 --restart always --name Meshtastic-Web ghcr.io/meshta
podman run -d -p 8080:8080 --restart always --name Meshtastic-Web ghcr.io/meshtastic/web:nightly podman run -d -p 8080:8080 --restart always --name Meshtastic-Web ghcr.io/meshtastic/web:nightly
``` ```
> [!WARNING] > [!WARNING]
> - Nightly builds represent the latest development state and may contain breaking changes >
> - These builds undergo automated testing but may be less stable than tagged release versions > - Nightly builds represent the latest development state and may contain
> - Not recommended for production environments unless you are actively testing new features > breaking changes
> - These builds undergo automated testing but may be less stable than tagged
> release versions
> - Not recommended for production environments unless you are actively testing
> new features
> - No guarantee of backward compatibility between nightly builds > - No guarantee of backward compatibility between nightly builds
### Version Information ### Version Information
Each nightly build is tagged with: Each nightly build is tagged with:
- The nightly tag for the latest build - The nightly tag for the latest build
- A specific SHA for build reproducibility - A specific SHA for build reproducibility
### Feedback ### Feedback
If you encounter any issues with nightly builds, please report them in our [issues tracker](https://github.com/meshtastic/web/issues). Your feedback helps improve the stability of future releases
If you encounter any issues with nightly builds, please report them in our
[issues tracker](https://github.com/meshtastic/web/issues). Your feedback helps
improve the stability of future releases
## Development & Building ## Development & Building
You'll need to download the package manager used with this repo. You can install it by visiting [Bun.sh](https://bun.sh/) and following the installation instructions.
### Debugging You'll need to download the package manager used with this repo. You can install
it by visiting [deno.com](https://deno.com/) and following the installation
instructions listed on the home page.
### Debugging
#### Debugging with React Scan #### Debugging with React Scan
Meshtastic Web Client has included the library [React Scan](https://github.com/aidenybai/react-scan) to help you identify and resolve render performance issues during development.
React's comparison-by-reference approach to props makes it easy to inadvertently cause unnecessary re-renders, especially with: Meshtastic Web Client has included the library
[React Scan](https://github.com/aidenybai/react-scan) to help you identify and
resolve render performance issues during development.
React's comparison-by-reference approach to props makes it easy to inadvertently
cause unnecessary re-renders, especially with:
- Inline function callbacks (`onClick={() => handleClick()}`) - Inline function callbacks (`onClick={() => handleClick()}`)
- Object literals (`style={{ color: "purple" }}`) - Object literals (`style={{ color: "purple" }}`)
- Array literals (`items={[1, 2, 3]}`) - Array literals (`items={[1, 2, 3]}`)
These are recreated on every render, causing child components to re-render even when nothing has actually changed. These are recreated on every render, causing child components to re-render even
when nothing has actually changed.
Unlike React DevTools, React Scan specifically focuses on performance optimization by: Unlike React DevTools, React Scan specifically focuses on performance
optimization by:
- Clearly distinguishing between necessary and unnecessary renders - Clearly distinguishing between necessary and unnecessary renders
- Providing render counts for components - Providing render counts for components
@ -96,10 +119,11 @@ Unlike React DevTools, React Scan specifically focuses on performance optimizati
- Offering a dedicated performance debugging experience - Offering a dedicated performance debugging experience
#### Usage #### Usage
When experiencing slow renders, run: When experiencing slow renders, run:
```bash ```bash
bun run dev:scan deno task dev:scan
``` ```
This will allow you to discover the following about your components and pages: This will allow you to discover the following about your components and pages:
@ -109,20 +133,21 @@ This will allow you to discover the following about your components and pages:
- Expensive hook operations - Expensive hook operations
- Props that change reference on every render - Props that change reference on every render
Use these insights to apply targeted optimizations like `React.memo()`, `useCallback()`, or `useMemo()` where they'll have the most impact. Use these insights to apply targeted optimizations like `React.memo()`,
`useCallback()`, or `useMemo()` where they'll have the most impact.
### Building and Packaging ### Building and Packaging
Build the project: Build the project:
```bash ```bash
bun run build deno task build
``` ```
GZip the output: GZip the output:
```bash ```bash
bun run package deno task package
``` ```
### Development ### Development
@ -130,11 +155,11 @@ bun run package
Install the dependencies. Install the dependencies.
```bash ```bash
bun i deno i
``` ```
Start the development server: Start the development server:
```bash ```bash
bun run dev deno task dev
``` ```

27
biome.json

@ -1,27 +0,0 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"ignoreUnknown": true,
"ignore": ["vercel.json"]
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "master"
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}

6729
deno.lock

File diff suppressed because it is too large

36
package.json

@ -5,29 +5,20 @@
"description": "Meshtastic web client", "description": "Meshtastic web client",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {
"build": "vite build", "build": "deno run -A npm:vite build",
"build:analyze": "BUNDLE_ANALYZE=true vite build", "build:analyze": "BUNDLE_ANALYZE=true deno task build",
"check": "biome check src/", "lint": "deno lint src/",
"check:fix": "pnpm check --write src/", "lint:fix": "deno lint --write src/",
"format": "biome format --write src/", "format": "deno fmt --write src/",
"dev": "vite dev --open", "dev": "deno task dev:ui",
"dev:scan": "VITE_DEBUG_SCAN=true vite dev", "dev:ui": "deno run -A npm:vite dev",
"test": "vitest", "dev:scan": "VITE_DEBUG_SCAN=true deno task dev:ui",
"test:ui": "vitest --ui", "test": "deno run vitest",
"test:run": "vitest run", "test:ui": "deno task test --ui",
"preview": "vite preview", "preview": "deno run --allow-net npm:vite preview",
"package": "gzipper c -i html,js,css,png,ico,svg,webmanifest,txt dist dist/output && tar -cvf dist/build.tar -C ./dist/output/ $(ls ./dist/output/)", "package": "deno run -A npm:gzipper c -i html,js,css,png,ico,svg,webmanifest,txt dist dist/output && deno run -A --allow-run tar -cvf dist/build.tar -C ./dist/output/ ."
"postinstall": "npx simple-git-hooks"
},
"simple-git-hooks": {
"pre-commit": "bun run check:fix && bun run format"
},
"lint-staged": {
"*.{ts,tsx}": [
"bun run check:fix",
"bun run format"
]
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/meshtastic/web.git" "url": "git+https://github.com/meshtastic/web.git"
@ -79,7 +70,6 @@
"zustand": "5.0.3" "zustand": "5.0.3"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.9.4",
"@tailwindcss/postcss": "^4.0.9", "@tailwindcss/postcss": "^4.0.9",
"@testing-library/react": "^16.2.0", "@testing-library/react": "^16.2.0",
"@types/chrome": "^0.0.307", "@types/chrome": "^0.0.307",

24
tsconfig.json

@ -4,19 +4,24 @@
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"], "lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false, "composite": true,
"module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, /* Bundler mode */
"allowSyntheticDefaultImports": true, "moduleResolution": "bundler",
"strict": true, "allowImportingTsExtensions": true,
"forceConsistentCasingInFileNames": true,
"module": "NodeNext",
"moduleResolution": "nodenext",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"moduleDetection": "force",
"noEmit": true, "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"baseUrl": "./",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
/* Path Aliases */
"paths": { "paths": {
"@app/*": ["./src/*"], "@app/*": ["./src/*"],
"@pages/*": ["./src/pages/*"], "@pages/*": ["./src/pages/*"],
@ -34,7 +39,6 @@
"@types/w3c-web-serial" "@types/w3c-web-serial"
], ],
"strictPropertyInitialization": false, "strictPropertyInitialization": false,
"experimentalDecorators": true, "experimentalDecorators": true
"allowImportingTsExtensions": true
} }
} }

2
vite.config.ts

@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa'; import { VitePWA } from 'vite-plugin-pwa';
import { execSync } from 'node:child_process'; import { execSync } from 'node:child_process';
import path from 'path'; import path from 'node:path';
let hash = ''; let hash = '';
try { try {

Loading…
Cancel
Save