diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 344c8aa..1ed992c 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -25,16 +25,21 @@ jobs: uses: actions/checkout@v4 with: submodules: true - - name: Make dist directory - run: | - mkdir dist - rsync --relative --recursive index.html meshmon.js meshmon.css assets/ protobufs/meshtastic/*.proto dist/ + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Build + run: npm run build - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: dist + path: './dist' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f06235c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist diff --git a/index.html b/index.html index 03feb6a..a270b78 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ - + diff --git a/meshmon.js b/meshmon.js index 1bd6f41..50eaeb6 100644 --- a/meshmon.js +++ b/meshmon.js @@ -458,10 +458,9 @@ function onFilterEnter() { filterInput.classList.remove('filter-ok'); filterInput.classList.remove('filter-error'); } else { - const newFilterExpr = eval?.(`(h) => { - with (h) { - return ${filterInput.value}; - } + const newFilterExpr = new Function('h', `{ + const { ${fields.join(', ')} } = h; + return ${filterInput.value}; }`); try { newFilterExpr(dummyHeader); diff --git a/package.json b/package.json new file mode 100644 index 0000000..6343ca2 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "meshmon", + "private": true, + "version": "1.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "vite": "^5.2.0", + "vite-plugin-static-copy": "^1.0.2" + } +} diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..f0c4785 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,15 @@ +import { viteStaticCopy } from 'vite-plugin-static-copy' + +export default { + base: '/meshmon/', + plugins: [ + viteStaticCopy({ + targets: [ + { + src: 'protobufs/meshtastic/*.proto', + dest: 'protobufs/meshtastic/' + } + ] + }) + ] +}