From b89d99807d9784423a7a49acb9241f3ef9ef5935 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Sun, 14 Jun 2026 14:49:26 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20error=20pages,=20consent=20gate,=20inst?= =?UTF-8?q?aller=20license=20+=20web=20code-splitting=20=E2=80=94=20v1.6.0?= =?UTF-8?q?=20(#65)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See PR #65 for full details. --- CHANGELOG.md | 19 ++++ PRIVACY.md | 1 + README.md | 1 + README.vi.md | 1 + docs/ROADMAP.md | 14 +++ index.html | 21 ++++ package-lock.json | 4 +- package.json | 2 +- public/404.html | 41 +++++++ src-tauri/license.rtf | 19 ++++ src-tauri/tauri.conf.json | 3 +- src/app/App.tsx | 29 +++-- src/components/common/ChunkErrorBoundary.tsx | 43 +++++++ src/components/common/ChunkErrorFallback.tsx | 24 ++++ src/components/common/ConsentGate.tsx | 89 +++++++++++++++ src/components/common/ErrorBoundary.tsx | 20 ++-- src/components/common/ErrorState.tsx | 45 ++++++++ src/components/common/OfflineBanner.tsx | 23 ++++ src/components/common/RouteFallback.tsx | 13 +++ .../common/__tests__/ErrorState.test.tsx | 26 +++++ src/components/converter/CodeEditor.tsx | 2 +- src/components/converter/CodeEditorLazy.tsx | 47 ++++++++ src/components/converter/InputPanel.tsx | 4 +- src/components/converter/OutputPanel.tsx | 2 +- src/components/layout/Layout.tsx | 13 ++- src/components/ui/dialog.tsx | 106 ++++++++++++++++++ src/converters/bson.ts | 36 +----- src/converters/cbor.ts | 4 +- src/converters/msgpack.ts | 4 +- src/hooks/__tests__/useOnlineStatus.test.ts | 35 ++++++ src/hooks/useOnlineStatus.ts | 25 +++++ src/i18n/locales/en.json | 47 ++++++++ src/i18n/locales/vi.json | 47 ++++++++ src/lib/__tests__/bytes.test.ts | 23 ++++ src/lib/__tests__/chunk-error.test.ts | 19 ++++ src/lib/__tests__/consent-storage.test.ts | 42 +++++++ src/lib/bytes.ts | 41 +++++++ src/lib/chunk-error.ts | 11 ++ src/lib/consent-storage.ts | 39 +++++++ src/pages/errors/ErrorRoute.tsx | 45 ++++++++ src/pages/errors/NotFound.tsx | 21 ++++ src/stores/__tests__/consentStore.test.ts | 30 +++++ src/stores/consentStore.ts | 22 ++++ vite.config.ts | 45 +++++--- 44 files changed, 1065 insertions(+), 83 deletions(-) create mode 100644 public/404.html create mode 100644 src-tauri/license.rtf create mode 100644 src/components/common/ChunkErrorBoundary.tsx create mode 100644 src/components/common/ChunkErrorFallback.tsx create mode 100644 src/components/common/ConsentGate.tsx create mode 100644 src/components/common/ErrorState.tsx create mode 100644 src/components/common/OfflineBanner.tsx create mode 100644 src/components/common/RouteFallback.tsx create mode 100644 src/components/common/__tests__/ErrorState.test.tsx create mode 100644 src/components/converter/CodeEditorLazy.tsx create mode 100644 src/components/ui/dialog.tsx create mode 100644 src/hooks/__tests__/useOnlineStatus.test.ts create mode 100644 src/hooks/useOnlineStatus.ts create mode 100644 src/lib/__tests__/bytes.test.ts create mode 100644 src/lib/__tests__/chunk-error.test.ts create mode 100644 src/lib/__tests__/consent-storage.test.ts create mode 100644 src/lib/bytes.ts create mode 100644 src/lib/chunk-error.ts create mode 100644 src/lib/consent-storage.ts create mode 100644 src/pages/errors/ErrorRoute.tsx create mode 100644 src/pages/errors/NotFound.tsx create mode 100644 src/stores/__tests__/consentStore.test.ts create mode 100644 src/stores/consentStore.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index f53f8da..2e00c03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,25 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and No unreleased changes at this time. Future work tracked in `docs/ROADMAP.md` under "Beyond". +## [1.6.0] — 2026-06-14 + +### Added + +- **Custom error pages.** A reusable presentational `ErrorState` component (`src/components/common/ErrorState.tsx`) backs a 404 catch-all route (`src/pages/errors/NotFound.tsx`) and a generic `/error/:code` route (`src/pages/errors/ErrorRoute.tsx`) with dedicated copy for 403 / 404 / 419 / 500 and a fallback for anything else. JSONPrism is a static client-side SPA and never emits these from a server itself — the route exists so any code (a future backend, a Tauri IPC failure) can render a polished, consistent page. New `error_page.*` i18n group in EN + VI. +- **First-launch legal consent gate (web only).** A non-dismissible modal (`src/components/common/ConsentGate.tsx`, built on a new `src/components/ui/dialog.tsx` Radix wrapper) blocks the app on first launch / incognito until the user ticks agreement to the License, Terms (EULA), Privacy Policy, and Disclaimer (linked to GitHub). Acceptance persists to `localStorage` (`jsonprism.consent` — flag + version + timestamp) via `src/lib/consent-storage.ts` and a Zustand store (`src/stores/consentStore.ts`); bump `CONSENT_VERSION` to re-prompt when terms change. Skipped in desktop builds (gated by the installer instead) with zero runtime branching, via the build-time `__IS_TAURI_BUILD__` flag. New `consent.*` i18n group in EN + VI; `PRIVACY.md` documents the new key. +- **Windows installer license-acceptance page.** `bundle.licenseFile` in `tauri.conf.json` now points at `src-tauri/license.rtf` (a short EULA referencing Apache-2.0 + TERMS / PRIVACY / DISCLAIMER). Both the NSIS `.exe` and the WiX `.msi` show an accept-to-continue license page — RTF satisfies both, so `targets: "all"` is preserved. +- **Offline indicator.** `useOnlineStatus` hook + a non-blocking `OfflineBanner` strip between the header and content. Informational only — JSONPrism keeps working offline. +- **GitHub Pages deep-link support.** `public/404.html` (spa-github-pages redirect, `pathSegmentsToKeep = 1` for the `/jsonPrism/` base) plus a tiny decoder in `index.html` make refreshing a deep link (e.g. `/jsonPrism/about`) resolve to the right route instead of GitHub's 404. No-op under Tauri. + +### Changed + +- **Lazy-loading + finer code-splitting (web).** Routes (`Home`, `About`, error pages) and the CodeMirror editor are now `React.lazy` + `Suspense` (the editor degrades to a real `