Merge remote-tracking branch 'origin/main' into dependabot/npm_and_yarn/tanstack-4e0cd3caa5
# Conflicts: # apps/web/package.json # packages/ui/package.json # pnpm-lock.yaml
This commit is contained in:
+26
-26
@@ -41,25 +41,25 @@
|
||||
"@meshtastic/transport-web-serial": "workspace:*",
|
||||
"@noble/curves": "^2.2.0",
|
||||
"@preact/signals-core": "^1.14.4",
|
||||
"@radix-ui/react-accordion": "^1.2.16",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.19",
|
||||
"@radix-ui/react-checkbox": "^1.3.7",
|
||||
"@radix-ui/react-dialog": "^1.1.19",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.20",
|
||||
"@radix-ui/react-label": "^2.1.11",
|
||||
"@radix-ui/react-menubar": "^1.1.20",
|
||||
"@radix-ui/react-popover": "^1.1.19",
|
||||
"@radix-ui/react-scroll-area": "^1.2.14",
|
||||
"@radix-ui/react-select": "^2.3.3",
|
||||
"@radix-ui/react-separator": "^1.1.11",
|
||||
"@radix-ui/react-slider": "^1.4.3",
|
||||
"@radix-ui/react-switch": "^1.3.3",
|
||||
"@radix-ui/react-tabs": "^1.1.17",
|
||||
"@radix-ui/react-toast": "^1.2.19",
|
||||
"@radix-ui/react-toggle-group": "^1.1.15",
|
||||
"@radix-ui/react-tooltip": "^1.2.12",
|
||||
"@radix-ui/react-visually-hidden": "^1.2.7",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
"@radix-ui/react-accordion": "^1.2.17",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.20",
|
||||
"@radix-ui/react-checkbox": "^1.3.8",
|
||||
"@radix-ui/react-dialog": "^1.1.20",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.21",
|
||||
"@radix-ui/react-label": "^2.1.12",
|
||||
"@radix-ui/react-menubar": "^1.1.21",
|
||||
"@radix-ui/react-popover": "^1.1.20",
|
||||
"@radix-ui/react-scroll-area": "^1.2.15",
|
||||
"@radix-ui/react-select": "^2.3.4",
|
||||
"@radix-ui/react-separator": "^1.1.12",
|
||||
"@radix-ui/react-slider": "^1.4.4",
|
||||
"@radix-ui/react-switch": "^1.3.4",
|
||||
"@radix-ui/react-tabs": "^1.1.18",
|
||||
"@radix-ui/react-toast": "^1.2.20",
|
||||
"@radix-ui/react-toggle-group": "^1.1.16",
|
||||
"@radix-ui/react-tooltip": "^1.2.13",
|
||||
"@radix-ui/react-visually-hidden": "^1.2.8",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@tanstack/react-router": "^1.170.18",
|
||||
"@tanstack/react-router-devtools": "^1.167.0",
|
||||
"@tanstack/router-cli": "^1.167.21",
|
||||
@@ -79,17 +79,17 @@
|
||||
"idb-keyval": "^6.3.0",
|
||||
"immer": "^11.1.15",
|
||||
"js-cookie": "^3.0.8",
|
||||
"lucide-react": "^1.24.0",
|
||||
"lucide-react": "^1.25.0",
|
||||
"maplibre-gl": "5.24.0",
|
||||
"react": "^19.2.7",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-error-boundary": "^6.1.2",
|
||||
"react-hook-form": "^7.81.0",
|
||||
"react-hook-form": "^7.82.0",
|
||||
"react-i18next": "^17.0.10",
|
||||
"react-map-gl": "8.1.1",
|
||||
"react-qrcode-logo": "^4.1.0",
|
||||
"rfc4648": "^1.5.4",
|
||||
"vite": "^8.1.4",
|
||||
"vite": "^8.1.5",
|
||||
"vite-plugin-html": "^3.2.2",
|
||||
"vite-plugin-pwa": "^1.3.0",
|
||||
"zod": "^4.1.12",
|
||||
@@ -105,19 +105,19 @@
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/serviceworker": "^0.0.199",
|
||||
"@types/serviceworker": "^0.0.200",
|
||||
"@types/w3c-web-serial": "^1.0.8",
|
||||
"@vitejs/plugin-basic-ssl": "^2.3.0",
|
||||
"@vitejs/plugin-react": "^6.0.3",
|
||||
"autoprefixer": "^10.5.2",
|
||||
"autoprefixer": "^10.5.4",
|
||||
"gzipper": "^8.3.0",
|
||||
"happy-dom": "^20.10.6",
|
||||
"happy-dom": "^20.11.0",
|
||||
"oxfmt": "^0.59.0",
|
||||
"oxlint": "^1.74.0",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"tar": "^7.5.20",
|
||||
"tar": "^7.5.21",
|
||||
"testing-library": "^0.0.2",
|
||||
"typescript": "^7.0.2",
|
||||
"vitest": "^4.1.10"
|
||||
|
||||
@@ -1,44 +1,25 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { randId } from "./randId.ts";
|
||||
|
||||
describe("randId", () => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("returns a number", () => {
|
||||
const result = randId();
|
||||
expect(typeof result).toBe("number");
|
||||
});
|
||||
|
||||
it("returns an integer", () => {
|
||||
const result = randId();
|
||||
expect(typeof result).toBe("number");
|
||||
expect(Number.isInteger(result)).toBe(true);
|
||||
});
|
||||
|
||||
it("uses Math.random to generate the number", () => {
|
||||
const mockRandom = vi.spyOn(Math, "random").mockReturnValue(0.5);
|
||||
const result = randId();
|
||||
|
||||
expect(mockRandom).toHaveBeenCalled();
|
||||
expect(result).toBe(Math.floor(0.5 * 1e9));
|
||||
});
|
||||
|
||||
it("returns a value between 0 and 1e9 (exclusive)", () => {
|
||||
it("returns a value within the uint32 range", () => {
|
||||
const result = randId();
|
||||
expect(result).toBeGreaterThanOrEqual(0);
|
||||
expect(result).toBeLessThan(1e9);
|
||||
expect(result).toBeLessThanOrEqual(0xffffffff);
|
||||
});
|
||||
|
||||
it("returns different values on subsequent calls", () => {
|
||||
vi.spyOn(Math, "random").mockRestore();
|
||||
|
||||
const results = new Set();
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
it("returns unique values across many calls", () => {
|
||||
const results = new Set<number>();
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
results.add(randId());
|
||||
}
|
||||
|
||||
expect(results.size).toBeGreaterThan(95);
|
||||
// With 32 bits of entropy over 1000 samples, collisions are vanishingly rare.
|
||||
expect(results.size).toBe(1000);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const randId = () => {
|
||||
return Math.floor(Math.random() * 1e9);
|
||||
export const randId = (): number => {
|
||||
const buf = new Uint32Array(1);
|
||||
crypto.getRandomValues(buf);
|
||||
return buf[0]!;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user