diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c9f6f60 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,24 @@ +--- +name: Bug report +about: Something isn't working right +title: "" +labels: bug +assignees: "" +--- + +**What happened** + + +**Steps to reproduce** +1. +2. +3. + +**Context** +- Browser / OS: +- Installed as a PWA or in a browser tab: +- Selected game (if relevant): +- Console errors (DevTools → Console): + +**Screenshot / clip** + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ba68201 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: Question or discussion + url: https://github.com/OWNER/pocketdex/discussions + about: Ask a question or float an idea before opening an issue. + - name: PokéAPI data looks wrong + url: https://github.com/PokeAPI/pokeapi/issues + about: Pocketdex reads its data from PokéAPI — report data errors upstream. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..4fa5af6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea +title: "" +labels: enhancement +assignees: "" +--- + +**The idea** + + +**Why** + + +**Notes** + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c620f95 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + groups: + workbox: + patterns: + - "workbox-*" + dev-dependencies: + dependency-type: development + open-pull-requests-limit: 5 + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: monthly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0852ec9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - run: npm ci + + # The build's `prebuild` step fetches a data snapshot from PokéAPI. + # Cache it so only the first run (or a change to the script) pays that + # cost; CI only needs *a* snapshot to prove the build compiles. + - name: Cache PokéAPI snapshot + uses: actions/cache@v4 + with: + path: src/data/snapshot.json + key: pokeapi-snapshot-${{ hashFiles('scripts/build-snapshot.mjs') }} + + - run: npm run build diff --git a/.gitignore b/.gitignore index 615230a..4f26ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,10 @@ dev-dist *.local .vite +# Local editor / tool state +.claude/ +.idea/ +.vscode/ + # Generated at build time from PokéAPI. Run `npm run snapshot` to (re)create. src/data/snapshot.json diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..9362ff7 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,97 @@ +# AGENTS.md + +Guidance for AI coding agents working in this repo. Humans: see +[CONTRIBUTING.md](CONTRIBUTING.md) — this file is the short, machine-facing +version of the same rules. + +## What this is + +Pocketdex — an offline-first Pokédex / team builder / save-file tracker. +**Vanilla JS, no UI framework.** Vite 5 + `vite-plugin-pwa` (Workbox, +injectManifest). All data comes from [PokéAPI](https://pokeapi.co/). + +## Setup & commands + +```bash +npm install +npm run snapshot # build src/data/snapshot.json from PokéAPI (git-ignored; required before first build/dev) +npm run dev # dev server, http://localhost:5173 +npm run build # runs `snapshot` (prebuild) then builds to dist/ +npm run preview # serve the production build — REQUIRED to test the service worker / offline / install +``` + +- Node **20+**. +- There is **no lint or test command** and **no test suite**. The build + (`npm run build`) is the only automated check — it must pass. It runs + esbuild over every module, so it catches syntax and import errors. +- `npm run snapshot -- --force` rebuilds the snapshot even if it's fresh. + +## Project structure + +| Path | What | +| --- | --- | +| `src/main.js` | boot: theme, nav, router, SW registration, install prompt | +| `src/router.js` | hash router; `routes` array; each view is `() => Promise` | +| `src/views/*.js` | one file per route (`DexGrid`, `PokemonDetail`, `TeamView`, …) | +| `src/components/*.js` | reusable DOM pieces (`Card`, `Sprite`, `TypeChip`, `CompareTable`, …) | +| `src/store/*.js` | `createStore()` state, persisted to `localStorage` under `pdx.*` | +| `src/data/*.js` | snapshot loader, pokedex resolver, lazy PokéAPI client, type chart, natures | +| `src/lib/*.js` | app-agnostic helpers (`dom`, `anim`, `damage-calc`, `savedex`, `swipe`, …) | +| `scripts/build-snapshot.mjs` | the only thing that calls PokéAPI at build time | +| `src/styles/tokens.css` | palette, type colours, the five themes | +| `src/styles/layout.css` | everything else | + +## Conventions + +- **Build DOM with `el()`** from `src/lib/dom.js` — `el(tag, props, ...children)`. + No template-string HTML, no `innerHTML`, except the deliberate `html:` prop + for trusted inline SVG. +- **Stores**: `createStore(key, initial)` → `{ get, set, subscribe, replace }`. + `set(fn)` **replaces** state (it does not merge) — spread `...s` yourself. + In views, `subscribe()` and call the returned unsub in + `onTeardown(viewNode, off)`. +- **Everything is game-aware.** The selected game lives in + `settings.get().versionGroup`. If you touch typings, effectiveness, + learnsets or evolution, honour that game's generation: `typesForGen()`, + `multiplier(atk, def, gen)`, PokéAPI `past_values`. +- **Tracking is per game.** `src/store/selection.js`: `entry(id)` / + `toggle(id, field)` / `stats(ids)` default to the selected game; + `favorite` and `note` are global. Don't reintroduce a single global + caught set. +- Respect `prefersReducedMotion()` (from `src/store/settings.js`) for any + animation. +- 2-space indent, semicolons, single quotes, trailing commas in multi-line + literals. Match the surrounding file; keep comments about *why*. +- No new runtime dependencies. Prefer adding to the snapshot over a new + runtime fetch. + +## Adding things + +- **Route** — new `src/views/Foo.js` exporting `async function Foo()` + returning a node; add one entry to `routes` in `src/router.js`. Add a + `skeleton` if it does async work before first paint. +- **Setting** — key + default in `src/store/settings.js` (and `applyTheme()` + if it affects the document), a field in `src/views/SettingsView.js`, and + add it to the export payload in `exportData()` if it should survive a + backup. +- **Snapshot field** — add it in `scripts/build-snapshot.mjs`, run + `npm run snapshot -- --force`, read it via `loadSnapshot()`. Keep the + snapshot small; it's precached on every install. + +## Do not + +- Commit `dist/` or `src/data/snapshot.json` (both git-ignored). +- Commit Pokémon sprites, artwork, audio, ROMs or save files. All imagery + is fetched at runtime from PokéAPI. +- Add analytics, telemetry, ads, tracking, or "sign in" flows. +- Add a framework or a build step that isn't Vite. +- Break offline-first: the grid, search, filters and game switching must + work with no network. + +## Verifying a change + +`npm run build` must pass. Then sanity-check by hand: the dex grid +(filters, sort, catching from a card), switching games (numbers + typings +update), a detail page (all tabs, form switch), and `npm run preview` +offline (DevTools → Network → Offline → reload). Check light and dark +theme and a mobile-width viewport. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..295ae6b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for +moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/README.md b/README.md index 419fd40..d010522 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,13 @@ runtime dependencies in the app bundle. > **Not affiliated with Nintendo, Game Freak or The Pokémon Company.** This > is a non-commercial fan reference tool. See [Legal](#legal). +

+ Dex grid + Pokémon detail + Team coverage analysis + Per-game progress +

+ --- ## Quick start @@ -251,7 +258,8 @@ SPA fallback and long-cache headers for `/assets/*` while keeping Issues and pull requests are welcome — see **[CONTRIBUTING.md](CONTRIBUTING.md)** for setup, project conventions, and -what's in and out of scope. +what's in and out of scope. AI coding agents: there's an +**[AGENTS.md](AGENTS.md)**. Known gaps: no interactive region map (PokéAPI has no map imagery or coordinates), no automated test suite yet, and no formal Lighthouse pass. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..1d5cfc9 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,31 @@ +# Security Policy + +## Supported versions + +Pocketdex is a rolling static web app — only the current `main` (and +whatever is deployed from it) is supported. There are no maintenance +branches. + +## Reporting a vulnerability + +Please **don't** open a public issue for a security problem. + +Use GitHub's **private vulnerability reporting** (the *Report a +vulnerability* button under the repository's *Security* tab). Include what +you found, how to reproduce it, and the impact you think it has. You'll get +an acknowledgement as soon as possible. + +Since Pocketdex has no backend and stores everything in the visitor's own +browser, the realistic surface is: the service worker / caching, the +save-file parser (`src/lib/savedex.js`) operating on untrusted binary +input, and the JSON backup import. + +## Known issues + +- **`npm audit` reports a moderate advisory for `esbuild` via Vite 5** + (GHSA-67mh-4wv8-2f99). It affects the **local dev server only** — a + malicious website could read responses from `npm run dev`. It is **not** + present in the production build (`dist/`), which ships no dev server. + Mitigation: don't expose the Vite dev server to untrusted networks. + Upgrading past Vite 5 needs a newer Node baseline and is tracked as a + follow-up. diff --git a/docs/screenshots/detail.png b/docs/screenshots/detail.png new file mode 100644 index 0000000..9187327 Binary files /dev/null and b/docs/screenshots/detail.png differ diff --git a/docs/screenshots/dex-grid.png b/docs/screenshots/dex-grid.png new file mode 100644 index 0000000..b88a190 Binary files /dev/null and b/docs/screenshots/dex-grid.png differ diff --git a/docs/screenshots/progress.png b/docs/screenshots/progress.png new file mode 100644 index 0000000..3bba59f Binary files /dev/null and b/docs/screenshots/progress.png differ diff --git a/docs/screenshots/search.png b/docs/screenshots/search.png new file mode 100644 index 0000000..7857d6c Binary files /dev/null and b/docs/screenshots/search.png differ diff --git a/docs/screenshots/team-coverage.png b/docs/screenshots/team-coverage.png new file mode 100644 index 0000000..37d73a0 Binary files /dev/null and b/docs/screenshots/team-coverage.png differ diff --git a/index.html b/index.html index 1ef8e60..521c3fd 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,23 @@ + + + + + + + + + + + Pocketdex diff --git a/public/og.png b/public/og.png new file mode 100644 index 0000000..a0a8296 Binary files /dev/null and b/public/og.png differ