chore: add biome for linting/formatting + CI action for linting in SRC folder (#1284)
Some checks are pending
Deploy static content to Pages / deploy (push) Waiting to run
Code quality / quality (push) Waiting to run

* chore: add npm + vite for progressive enhancement

* fix: update Dockerfile to copy only the dist folder contents

* fix: update Dockerfile to use multi-stage build for optimized production image

* fix: correct nginx config file copy command in Dockerfile

* chore: add netlify configuration for build and redirects

* fix: add NODE_VERSION to environment in Netlify configuration

* remove wrong dist folder

* Update package.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: split public and src

* migrating all util files from js to ts

* feat: Implement HeightmapGenerator and Voronoi module

- Added HeightmapGenerator class for generating heightmaps with various tools (Hill, Pit, Range, Trough, Strait, etc.).
- Introduced Voronoi class for creating Voronoi diagrams using Delaunator.
- Updated index.html to include new modules.
- Created index.ts to manage module imports.
- Enhanced arrayUtils and graphUtils with type definitions and improved functionality.
- Added utility functions for generating grids and calculating Voronoi cells.

* chore: add GitHub Actions workflow for deploying to GitHub Pages

* fix: update branch name in GitHub Actions workflow from 'main' to 'master'

* chore: update package.json to specify Node.js engine version and remove unused launch.json

* Initial plan

* Update copilot guidelines to reflect NPM/Vite/TypeScript migration

Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>

* Update src/modules/heightmap-generator.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/utils/graphUtils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/modules/heightmap-generator.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* feat: Add TIME and ERROR variables to global scope in HeightmapGenerator

* fix: Update base path in vite.config.ts for Netlify deployment

* refactor: Migrate features to a new module and remove legacy script reference

* refactor: Update feature interfaces and improve type safety in FeatureModule

* refactor: Add documentation for markupPack and defineGroups methods in FeatureModule

* refactor: Remove legacy ocean-layers.js and migrate functionality to ocean-layers.ts

* refactor: Remove river-generator.js script reference and migrate river generation logic to river-generator.ts

* refactor: Remove river-generator.js reference and add biomes module

* refactor: Migrate lakes functionality to lakes.ts and update related interfaces

* refactor: clean up global variable declarations and improve type definitions

* refactor: update shoreline calculation and improve type imports in PackedGraph

* fix: e2e tests

* chore: add biome for linting/formatting

* chore: add linting workflow using Biome

* refactor: improve code readability by standardizing string quotes and simplifying function calls

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Azgaar <maxganiev@yandex.com>
Co-authored-by: Azgaar <azgaar.fmg@yandex.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
This commit is contained in:
Marc Emmanuel 2026-01-26 22:30:28 +01:00 committed by GitHub
parent e37fce1eed
commit 9db40a5230
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 2001 additions and 782 deletions

View file

@ -1,6 +1,6 @@
import { line, curveBasisClosed } from 'd3';
import type { Selection } from 'd3';
import { clipPoly,P,rn,round } from '../utils';
import type { Selection } from "d3";
import { curveBasisClosed, line } from "d3";
import { clipPoly, P, rn, round } from "../utils";
declare global {
var OceanLayers: typeof OceanModule.prototype.draw;
@ -13,7 +13,6 @@ class OceanModule {
private lineGen = line().curve(curveBasisClosed);
private oceanLayers: Selection<SVGGElement, unknown, null, undefined>;
constructor(oceanLayers: Selection<SVGGElement, unknown, null, undefined>) {
this.oceanLayers = oceanLayers;
}
@ -35,11 +34,17 @@ class OceanModule {
// connect vertices to chain
connectVertices(start: number, t: number) {
const chain = []; // vertices chain to form a path
for (let i = 0, current = start; i === 0 || (current !== start && i < 10000); i++) {
for (
let i = 0, current = start;
i === 0 || (current !== start && i < 10000);
i++
) {
const prev = chain[chain.length - 1]; // previous vertex in chain
chain.push(current); // add current vertex to sequence
const c = this.vertices.c[current]; // cells adjacent to vertex
c.filter((c: number) => this.cells.t[c] === t).forEach((c: number) => (this.used[c] = 1));
c.filter((c: number) => this.cells.t[c] === t).forEach((c: number) => {
this.used[c] = 1;
});
const v = this.vertices.v[current]; // neighboring vertices
const c0 = !this.cells.t[c[0]] || this.cells.t[c[0]] === t - 1;
const c1 = !this.cells.t[c[1]] || this.cells.t[c[1]] === t - 1;
@ -58,9 +63,16 @@ class OceanModule {
// find eligible cell vertex to start path detection
findStart(i: number, t: number) {
if (this.cells.b[i]) return this.cells.v[i].find((v: number) => this.vertices.c[v].some((c: number) => c >= this.pointsN)); // map border cell
return this.cells.v[i][this.cells.c[i].findIndex((c: number)=> this.cells.t[c] < t || !this.cells.t[c])];
}
if (this.cells.b[i])
return this.cells.v[i].find((v: number) =>
this.vertices.c[v].some((c: number) => c >= this.pointsN),
); // map border cell
return this.cells.v[i][
this.cells.c[i].findIndex(
(c: number) => this.cells.t[c] < t || !this.cells.t[c],
)
];
}
draw() {
const outline = this.oceanLayers.attr("layers");
@ -69,8 +81,11 @@ class OceanModule {
this.cells = grid.cells;
this.pointsN = grid.cells.i.length;
this.vertices = grid.vertices;
const limits = outline === "random" ? this.randomizeOutline() : outline.split(",").map((s: string) => +s);
const limits =
outline === "random"
? this.randomizeOutline()
: outline.split(",").map((s: string) => +s);
const chains: [number, any[]][] = [];
const opacity = rn(0.4 / limits.length, 2);
this.used = new Uint8Array(this.pointsN); // to detect already passed cells
@ -85,22 +100,33 @@ class OceanModule {
const chain = this.connectVertices(start, t); // vertices chain to form a path
if (chain.length < 4) continue;
const relax = 1 + t * -2; // select only n-th point
const relaxed = chain.filter((v, i) => !(i % relax) || this.vertices.c[v].some((c: number) => c >= this.pointsN));
const relaxed = chain.filter(
(v, i) =>
!(i % relax) ||
this.vertices.c[v].some((c: number) => c >= this.pointsN),
);
if (relaxed.length < 4) continue;
const points = clipPoly(
relaxed.map(v => this.vertices.p[v]),
relaxed.map((v) => this.vertices.p[v]),
graphWidth,
graphHeight,
1
1,
);
chains.push([t, points]);
}
for (const t of limits) {
const layer = chains.filter((c: [number, any[]]) => c[0] === t);
let path = layer.map((c: [number, any[]]) => round(this.lineGen(c[1]) || "")).join("");
if (path) this.oceanLayers.append("path").attr("d", path).attr("fill", "#ecf2f9").attr("fill-opacity", opacity);
const path = layer
.map((c: [number, any[]]) => round(this.lineGen(c[1]) || ""))
.join("");
if (path)
this.oceanLayers
.append("path")
.attr("d", path)
.attr("fill", "#ecf2f9")
.attr("fill-opacity", opacity);
}
TIME && console.timeEnd("drawOceanLayers");