Web application generating interactive and highly customizable maps
Find a file
Claude 20458e39e2
Add external API integration for wiki/web UI synchronization
This commit adds a comprehensive external API system that allows external tools
(wikis, web UIs, etc.) to control and synchronize with Fantasy Map Generator.

New Features:
- External API Bridge (modules/external-api.js)
  - Event-driven architecture with EventEmitter
  - Map lifecycle control (create, load, save)
  - Data access methods (rivers, cultures, states, burgs)
  - Data mutation methods with auto-redraw
  - Export support (SVG, PNG, JSON)
  - Change detection with automatic event emission

- PostMessage Communication Layer
  - Auto-enables when FMG is embedded in iframe
  - Bidirectional message passing
  - Request/response pattern with promise support
  - Automatic event forwarding to parent window

- REST API Server (api-server/)
  - Express.js server with full CRUD operations
  - WebSocket support via Socket.IO for real-time updates
  - File upload support for map and CSV import
  - In-memory storage (can be replaced with database)
  - CORS enabled for cross-origin requests
  - Comprehensive endpoints for all map data

- Client Library (api-server/client.js)
  - Simple JavaScript client for REST API
  - Promise-based async methods
  - Works in browser and Node.js

- Demo Pages (demos/)
  - PostMessage integration demo with full UI
  - REST API demo with interactive testing
  - WebSocket demo for real-time events

- Documentation
  - Comprehensive integration guide (EXTERNAL_API_INTEGRATION.md)
  - API reference with TypeScript interfaces
  - Multiple integration examples
  - Troubleshooting guide

Integration Methods:
1. PostMessage Bridge - For iframe embedding
2. REST API - For server-side integration
3. Direct JavaScript API - For same-origin apps

Use Cases:
- Wiki pages that need to display and control maps
- Web UIs that want to edit map data
- External tools that need to sync with FMG
- Real-time collaborative map editing
- Batch operations and automation

Technical Details:
- Zero dependencies for external-api.js (pure JS)
- Auto-initializes on DOMContentLoaded
- Throttled change detection (500ms debounce)
- Deep cloning for data access (prevents mutations)
- Error handling throughout
- Version tagged (v1.0.0)

Updated Files:
- index.html: Added script tag to load external-api module

All APIs are backward compatible and don't affect existing functionality.
2025-11-04 21:43:06 +00:00
.docker Containerized version (#639) 2021-07-13 18:42:28 +03:00
.github docs: pull request template 2022-06-02 00:39:34 +03:00
.vscode v1.3.03a 2020-03-27 17:52:23 +03:00
api-server Add external API integration for wiki/web UI synchronization 2025-11-04 21:43:06 +00:00
charges feat: add new emblem charges 2023-10-30 22:27:25 +04:00
components annotate template strings for syntax hightlight and format 2022-05-08 19:22:15 +03:00
config central store for heightmap configs 2022-05-29 01:03:21 +03:00
demos Add external API integration for wiki/web UI synchronization 2025-11-04 21:43:06 +00:00
heightmaps doc: update readme 2023-02-09 13:12:37 -08:00
images Fix: rework texture data format (#1017) 2023-11-19 14:43:56 +04:00
libs Fix: rework texture data format (#1017) 2023-11-19 14:43:56 +04:00
modules Add external API integration for wiki/web UI synchronization 2025-11-04 21:43:06 +00:00
styles Vignette layer (#1021) 2023-11-28 02:26:55 +04:00
utils chore: polyfill Array.at for old browsers 2023-12-05 02:38:37 +04:00
.gitignore fix: image conversion UI, restrict namebase chars 2022-09-17 14:36:32 +03:00
CODE_OF_CONDUCT.md docs: code of conduct 2022-06-01 15:08:20 -07:00
Dockerfile Containerized version (#639) 2021-07-13 18:42:28 +03:00
dropbox.html dropbox - load script dynamically 2022-02-08 00:47:17 +03:00
EXTERNAL_API_INTEGRATION.md Add external API integration for wiki/web UI synchronization 2025-11-04 21:43:06 +00:00
icons.css Added OBJ exporter for 3D. (#609) 2021-03-24 22:08:20 +03:00
index.css Vignette layer (#1021) 2023-11-28 02:26:55 +04:00
index.html Add external API integration for wiki/web UI synchronization 2025-11-04 21:43:06 +00:00
ISSUE_TEMPLATE.md Update ISSUE_TEMPLATE.md 2018-06-11 21:36:07 +03:00
LICENSE restore river cells of load 2021-07-28 19:46:42 +03:00
main.js Vignette layer (#1021) 2023-11-28 02:26:55 +04:00
manifest.webmanifest Correct name and shortname in web manifest (#912) 2023-01-09 01:03:23 -08:00
README.md doc: improve readme 2023-01-22 23:39:24 +04:00
run_python_server.bat v1.5.02 - COA rendering + editor basic UI 2021-02-04 15:56:27 +03:00
sw.js fix: culture data change must not ignore lock status 2023-01-22 22:37:18 +04:00
versioning.js update versioning.js 2024-01-16 00:31:05 +01:00

Stand With Ukraine

Fantasy Map Generator

Azgaar's Fantasy Map Generator is a free web application that helps fantasy writers, game masters, and cartographers create and edit fantasy maps.

Link: azgaar.github.io/Fantasy-Map-Generator.

Refer to the project wiki for guidance. The current progress is tracked in Trello. Some details are covered in my old blog Fantasy Maps for fun and glory.

preview

preview

preview

Join our Discord server and Reddit community to share your creations, discuss the Generator, suggest ideas and get the most recent updates.

Contact me via email if you have non-public suggestions. For bug reports please use GitHub issues or #bugs channel on Discord. If you are facing performance issues, please read the tips.

Electron desktop application is available in releases. Download archive for your architecture, unzip and run.

Pull requests are highly welcomed. The codebase is messy and requires re-design, but I will appreciate if you start with minor changes. Check out the data model before contributing.

You can support the project on Patreon.

Inspiration: