Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 2.67 KB

File metadata and controls

62 lines (42 loc) · 2.67 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

WaspScripts Web Map — an interactive Old School RuneScape (OSRS) map built on Leaflet.js with a minimal Hono/Bun backend. Forked from mejrs/mejrs.github.io.

Commands

# Install dependencies (first-time setup includes submodule tile generation)
git submodule update --init --recursive
bun install
cd static/layers-osrs/ && bun install && bun start && cd ../..

# Development server (localhost:3000, hot-reload)
bun dev

# Production
bun start

# Build
bun build

# Tests
bun test

# Formatting
bunx prettier --write .

# Update map tiles (when OSRS map updates are available)
cd static/layers-osrs && git pull origin master && rm -rf map/ && bun start && cd ../..

Architecture

Backend (src/main.ts): A single Hono app that serves everything from ./static/ as static files. All logic lives on the frontend.

Frontend (static/): Leaflet.js-based map application with no build step — ES6 modules loaded directly by the browser.

  • Entry point: static/index.htmlstatic/js/main/main.js
  • Core map engine: static/js/leaflet.js (~2,200 lines) — extends Leaflet with L.GameMap, L.TileLayer.Main, L.Grid, L.Heatmap, L.DynamicIcons, L.Teleports, L.CrowdSourceMovement, L.Varbit
  • Plugins: static/js/plugins/ — each plugin is a self-contained ES6 module extending Leaflet (fullscreen, zoom, plane switching, position display, NPC/object search, URL state sync, rectangle tool, etc.)
  • Layer definitions: static/js/layers.js
  • Game data: static/data_osrs/ — large JSON files (NPCs, teleports, transports, locations) plus ~94k individual data files in subdirectories

Map tiles are generated by the static/layers-osrs git submodule (wasp-map-layers). Tile URL pattern: layers-osrs/map/{zoom}/{plane}/{x}-{y}.png.

Key Concepts

  • Planes: OSRS has 4 vertical levels (0-3), controlled by L.Control.Plane
  • Coordinates: Game uses a grid system; map bounds are 0-12800. Chunks are 64×64 units.
  • URL state: Zoom, plane, x, y, and map ID are encoded in query parameters for shareable links
  • External APIs: Google Sheets (teleport data), Chisel/weirdgloop.org (varbit data), RuneScape Wiki (sprite icons via MD5 hash URLs)

Code Style

  • Prettier: tabs, double quotes, no semicolons, no trailing commas, 100 char width
  • ESLint configured for ES2020 browser environment
  • L (Leaflet) is a global — plugins extend it via L.extend() / class inheritance
  • Frontend JS uses UMD-compatible module pattern (AMD/CommonJS/global fallback)