Skip to content

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

World Generator

World Generator is a React + Vite application for generating procedural island and terrain-inspired worlds.

For instructions on configuring and exploring a world, see the User Guide.

Local development

Requirements

  • Node.js 22
  • pnpm 10.13.1

Install

corepack enable
pnpm install

Run locally

pnpm dev

Production build

pnpm build

Quality checks

pnpm typecheck
pnpm lint
pnpm lint:scss
pnpm format
pnpm test
pnpm check:all

Stylelint validates all SCSS files using the rules in tooling/stylelint.config.json. Use pnpm lint:scss:fix to apply safe automatic fixes.

Architecture

The application separates configuration, world generation, and map presentation.

Generation and data flow

  • The React forms build a typed MapConfig. Generation starts explicitly from the settings panel; changing a control does not automatically regenerate.
  • src/utils/map-generator runs in a Web Worker and contains five stages: World Shape, Macro Regions, BaseClimate, Geology, and Heightmap. Each stage declares the data it reads and writes. The execution order is derived from those dependencies; the presentation order is not itself a dependency graph.
  • The worker streams stage lifecycle, progress, and output data. postMessage copies stage output to the main thread; the sample budget accounts for that copy. The final result contains generation statistics, while map outputs are collected from stage events.
  • Non-raster metadata travels through MapInfo. MAP_INFO_CATALOG derives entries such as heat-zone descriptions, macro-region labels, and world dimensions from the generation config.

Map rendering

  • src/utils/map-layers declares the raster and vector layer catalog.
  • src/utils/map-renderer builds the preview from generator outputs using progressive, screen-resolution Canvas2D rendering, overlays, a layer cache, and render metrics.
  • World dimensions use physical units independently of sample-grid resolution. The generation sample budget is derived from an 864 MB data budget and accounts for stage rasters plus their main-thread copy; renderer canvases are measured separately.

For local visual testing, an optional delay can be enabled between stages:

VITE_GENERATION_STAGE_DELAY_MS=500

The value is in milliseconds. Restart the Vite server after changing the value. Leave it unset, or set it to 0, for normal generation speed.

Statistics

The progress indicator below the map shows the current stage and percentage during generation. Finished runs keep their map configuration, per-stage generation statistics and render statistics (layer timings, tiles, source and buffer resolutions, buffer sizes, first-tile time and presentation/overlay time); the /statistics page presents them together. All of it lives in memory for the session, so a full page refresh clears it. The page also exports the statistics snapshot as JSON.

Project structure

  • src/utils/map-generator contains the stage pipeline, stages, stage events and worker transport.
  • src/features/world-generator owns the generator UI: the screen, settings, forms, map preview and generation progress.
  • src/components contains shared UI components used across features.
  • src/utils/map-renderer renders layers and overlays (scene, view, layer cache, metrics and persistence).
  • src/stores holds global UI state: form values per settings tab, generation progress and statistics, map config, preview selection and render statistics.
  • src/features/world-generator/generation-progress renders the current stage and progress.
  • tooling/ contains shared tool configuration for Vite, Vitest, ESLint, Stylelint, commitlint, lint-staged and release-it.
  • VS Code extension settings point at the tooling/ configs: eslint.options.overrideConfigFile, stylelint.configFile and vitest.rootConfig.
  • docs/roadmap.md describes the pipeline, the current and planned stages, and future layer contracts, with per-section status markers.

Branching strategy

The repository uses a simplified GitHub Flow:

  • master — the single long-lived branch (protected)
  • <type>/<issue>-<name> — working branches, e.g. feat/163-stage-indicator
  • release/vX.Y.Z — release branches created by the release script

Recommended flow:

  1. Create a branch from master (feat/*, fix/*, refactor/*, chore/*, ...)
  2. Open a PR to master
  3. After review and green CI, squash and merge into master

Every push to master is automatically deployed to the dev environment (see Deployment). Production is promoted manually.

Commit naming convention

Use Conventional Commits. Subjects start with a lowercase letter; acronyms and module names keep their case.

Examples:

git commit -m "feat: add procedural island generator"
git commit -m "fix: repair noise offset calculation"
git commit -m "docs: update setup instructions"
git commit -m "chore(release): prepare v0.0.1"

Common types:

  • feat: — new feature
  • fix: — bug fix
  • docs: — docs only
  • refactor: — internal cleanup
  • test: — test changes
  • chore: — maintenance and release preparation

CI workflow

CI runs on pull requests and pushes to master (ci.yml) with two jobs:

Code Quality — typecheck, ESLint, Stylelint, format and production build.

Tests — the full Vitest suite.

A separate workflow (pr-title-check.yml) validates that PR titles follow Conventional Commits (type prefix, subject starting with a lowercase letter). These checks are the main safety gate before merge.

Versioning and releases

Versioning and changelog generation use release-it with the @release-it/conventional-changelog plugin (Conventional Commits):

pnpm release        # detects the bump and creates release/vX.Y.Z
pnpm release:patch  # force patch
pnpm release:minor  # force minor
pnpm release:major  # force major

pnpm release looks at the commits since the last tag: feat: bumps minor, while fixes, refactors, chores and docs bump patch. A breaking change (feat!: or a BREAKING CHANGE: footer) bumps major — or minor while the project is still on 0.x. The script creates a release/vX.Y.Z branch, updates package.json and CHANGELOG.md, and commits the result; no git tag or push is done locally. Changelog entries keep the commit subject and the commit body, so multi-line descriptions are preserved. Add --dry-run to preview the detected bump without changing anything.

Flow: run the release on a clean master, push the release/* branch and merge it through a PR. Merging ships the build to dev. The git tag and GitHub release are created later, when the tested build is promoted to production. The Promote to Production workflow calls Create GitHub Release (create-release.yml) as its final step, which tags the current package.json version and publishes the matching section of CHANGELOG.md.

A GitHub release therefore always corresponds to something live in production, rollbacks do not create releases, and promoting the same version twice is a no-op.

Every promoted release also gets a permanent alias in the form wg-<version with dashes>.vercel.app (for example wg-0-6-0.vercel.app), and the release notes link both the deployment URL and its alias. Aliased deployments are kept outside the retention policy, so any past release can be opened straight from its GitHub release page.

Deployment

Deployment is decoupled from merging: every push to master ships to dev, and production is promoted manually from a dev deployment that has been tested. No rebuild happens on promotion — the exact artifact tested on dev is the one that goes live.

Environments:

Workflows (.github/workflows/):

  • Deploy to Dev (deploy-dev.yml) — runs automatically on every push to master. Deploys a Vercel preview with the Vercel CLI (vercel deploy), aliases it to the dev URL, and posts a commit comment with the dev URL and the unique deployment URL.
  • Promote to Production (deploy-production.yml) — manual (workflow_dispatch). Promotes a tested dev deployment to production via vercel promote (no rebuild). Leave the deployment URL empty to promote the current dev deployment, or pass a specific dev deployment URL to promote that one. Requires typing deploy to confirm. After a successful promotion it creates the git tag and GitHub release for the current version (see Versioning and releases).
  • Rollback Production (rollback.yml) — manual (workflow_dispatch). Promotes a previous good deployment URL back to production via vercel promote. Requires typing rollback to confirm.

Promote and rollback share their resolve-and-promote logic through a composite action (.github/actions/vercel-promote): it resolves the target deployment (explicit URL, or the current dev deployment when none is given), promotes it, and exposes both a friendly URL and the deployment id. Both workflows post a commit comment linking to the promoted deployment.

Deployment auth is provided by the VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID repository secrets.

Feature flags

Feature flags are local to the current browser. They are read once at startup from the feature-flags localStorage entry; there is no remote store, server endpoint, or shared deployment rollout.

How it works:

  • src/feature-flags/flags.ts is the typed registry. FLAG_DEFAULTS holds each flag's default and is also the fallback for missing or invalid stored data. Flags can be booleans or strings; string flags declare their allowed values in FLAG_OPTIONS, which becomes the flag's TypeScript union type.
  • FeatureFlagsProvider resolves the stored JSON against the registry; unknown keys, wrong types, and string values outside FLAG_OPTIONS fall back to the defaults. Consume flags with useFlag('breadcrumbs').
  • Breadcrumbs are disabled by default.

To change flags in this browser, set the entry and refresh the page. On the first load, a missing entry is created with the defaults so it can be edited in the browser dev tools:

localStorage.setItem('feature-flags', JSON.stringify({ breadcrumbs: true }));

Remove the entry with localStorage.removeItem('feature-flags') to restore the defaults. This affects only the current browser profile; it is not a way to roll out flags to all users or a replacement for deployment configuration.

Notes

This project includes:

  • commitlint with conventional commit rules
  • husky for git hooks
  • eslint, stylelint, and prettier
  • vitest for testing
  • GitHub Actions CI
  • Vercel deployment for production

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages