Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 98 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"globals": "^15.14.0",
"jest": "^29.7.0",
"vite": "^6.0.5",
"vite-plugin-mkcert": "^1.17.8",
"vite-plugin-singlefile": "^2.1.0"
}
}
9 changes: 8 additions & 1 deletion src/hooks/useSerial/useSerial.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ const useSerial = () => {

useEffect(() => {
// check if browser compatible
// Note: this check will fail in other cases too:
// - URL must be secure or localhost
// - Must run after the DOM has been loaded
// - Must be in the main thread.
if (!navigator.serial) {
console.error("Web Serial API not supported");
const isMainThread = typeof window !== "undefined" && typeof document !== "undefined";
const isLoading = document.readyState === "loading";
const isSecure = window.location.protocol === "https:";
console.error(`Web Serial API not supported: isSecure: ${isSecure}, isMainThread: ${isMainThread}, isLoading: ${isLoading}`);
}

// setup callback to get full history
Expand Down
6 changes: 6 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteSingleFile } from "vite-plugin-singlefile";
import mkcert from 'vite-plugin-mkcert';

// https://vite.dev/config/
export default defineConfig({
Expand All @@ -16,6 +17,7 @@ export default defineConfig({
}
},
},
mkcert(),
],
optimizeDeps: {
include: [
Expand All @@ -27,4 +29,8 @@ export default defineConfig({
build: {
outDir: "./docs",
},
server: {
https: true,
host: true, // or specify a hostname like 'localhost'
},
});