universe-generator 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - The whole public API of the C# UniverseGenerator 1.0.0, ported to TypeScript: universes, clusters, galaxies with extras and constraints, star systems, planets, moons, belts, star names, presets and options codes, addresses (`generateAt`, `linkTo`, `Address.tryParse`), JSON export, hooks and custom fields, units and distances, editable tables.
6
+ - Bit-exact with all 18 C# golden files, on the ES module and CommonJS builds.
7
+ - Published to npm as `universe-generator` and to JSR as `@m4bwav/universe-generator`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Mark Rogers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
- # Temporary Holding Version
1
+ # universe-generator
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ![A spiral galaxy seen from above, blue and gold arms, with a few star systems joined by thin cyan lines like a star map](https://raw.githubusercontent.com/m4bwav/universe-generator-ts/master/.github/images/banner.jpg)
4
+
5
+ [![CI](https://github.com/m4bwav/universe-generator-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/m4bwav/universe-generator-ts/actions/workflows/ci.yml)
6
+
7
+ Seeded universes, galaxy clusters, galaxies, star systems, planets and moons for games and fiction, in TypeScript. The same seed gives the same universe here as in the C# and Unity [UniverseGenerator](https://github.com/m4bwav/UniverseGenerator), bit for bit: every one of that project's 18 golden files passes on both builds of this package.
8
+
9
+ Zero dependencies. ES module and CommonJS builds with types, Node 20 or later, Bun, Deno and browsers.
10
+
11
+ **Status: the port is complete; not on npm or JSR yet.**
12
+
13
+ **[Try the galaxy demo](https://m4bwav.github.io/universe-generator-ts/)**: type a seed, pan and zoom the map, click a star for its planets, moons and stories, and copy a link that rebuilds the same galaxy.
14
+
15
+ ![The demo: a barred galaxy for seed my-seed with lanes, faction rings and hazard clouds, and the panel for system LHS 1589 listing its planets, belt and landmarks](https://raw.githubusercontent.com/m4bwav/universe-generator-ts/master/docs/images/demo-desktop.png)
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ npm install universe-generator
21
+ ```
22
+
23
+ Deno and JSR: `deno add jsr:@m4bwav/universe-generator`.
24
+
25
+ ## First example
26
+
27
+ ```ts
28
+ import {generateGalaxy} from 'universe-generator';
29
+
30
+ const galaxy = generateGalaxy('my-seed');
31
+ for (let i = 0; i < 3; i++) {
32
+ const system = galaxy.system(i);
33
+ console.log(`${system.name}: ${system.star.class} star, ${system.planets.length} planets, danger ${system.danger}`);
34
+ }
35
+ ```
36
+
37
+ ```text
38
+ HD 147927: K star, 6 planets, danger 9
39
+ HD 165595: M star, 1 planets, danger 6
40
+ HD 28101: K star, 6 planets, danger 6
41
+ ```
42
+
43
+ These are the lines the C# README prints for the same seed. Any text up to 200 characters, a number or a bigint is a seed. Sixty systems is the default.
44
+
45
+ ## Presets, options and addresses
46
+
47
+ ```ts
48
+ import {generateGalaxy, generateAt, Preset} from 'universe-generator';
49
+
50
+ const options = {...Preset.spaceOpera, systems: 120, shape: 'Barred'} as const;
51
+ const galaxy = generateGalaxy('my-seed', options);
52
+ const planet = galaxy.system(31).planets[1]; // generated on request; same result as full generation
53
+ console.log(planet.descriptor); // a ringed ice giant far from a red dwarf
54
+ console.log(planet.address.toString()); // v1-my-seed/galaxy/system/31/planet/1
55
+ const same = generateAt(planet.address.toString(), options); // any object regenerates alone from its address
56
+ console.log(same.summary === planet.summary); // true
57
+ ```
58
+
59
+ The presets are `default`, `spaceOpera`, `plausible`, `pocket`, `roguelike`, `cozy` and `epic`. The options are the C# ones in camelCase: `systems` (1 to 2000), `shape`, `arms`, `extraLanes`, `dangerShift`, `names`, `starMix`, `weirdness`, `maxPlanetsPerSystem`, `clusterKind`, `epoch` and `require` (a `Guarantee` bit set). Bad options throw a `RangeError` that says what to change, before anything is generated. `checkOptions(options)` lists settings that are valid but read badly, and `galaxy.warnings` says what generation had to change.
60
+
61
+ `optionsToCode(options)` writes options as a short query string (`systems=120&shape=barred&weirdness=10`) and `optionsFromCode` reads it back, so a seed and its options fit in a link. `linkTo(address, options)` builds that link and `generateAt` reads it.
62
+
63
+ ## What it makes
64
+
65
+ | Call | Returns |
66
+ | --- | --- |
67
+ | `generateUniverse(seed, options?, hooks?)` | a cosmic web of nodes, filaments, voids and landmarks; `universe.cluster(i)` |
68
+ | `generateCluster(seed, options?, hooks?)` | a galaxy cluster with gates and wormholes; `cluster.galaxy(i)` |
69
+ | `generateGalaxy(seed, options?, hooks?)` | the map, lanes, regions, factions, points of interest, hazards, monuments, beacons; `galaxy.system(i)` |
70
+ | `generateSystem(seed, options?, hooks?)` | a star system: star and companions, planets, moons, belts, stations, landmarks |
71
+ | `generatePlanet(seed, options?, hooks?)` | one planet with its physics, air, climate, life, resources, hazards and story |
72
+ | `generateStarName(seed)`, `generateStarNames(seed, count)` | catalogue-style star names |
73
+ | `generateAt(address, options?, hooks?)` | whatever an address names, from a universe down to a moon |
74
+ | `toJson(type, value, {indented, children})` | the same JSON as the C# `ToJson()` |
75
+
76
+ Lists that can be large are opened on request (`galaxy.system(i)`, `cluster.galaxy(i)`, `universe.cluster(i)`), so a 2,000-system galaxy costs little until you look.
77
+
78
+ `Units` converts lengths, masses, times and temperatures; `Distances` and `Units.map` give map distances per level. `GeneratorTables` loads editable weight tables from JSON. Hooks (`{onPlanet, onSystem, onGalaxy, onCluster, onUniverse}`) can change each object as it is made, and `withCustom` adds your own fields that `toJson` exports.
79
+
80
+ ## From C# to TypeScript
81
+
82
+ | C# | TypeScript |
83
+ | --- | --- |
84
+ | `Galaxy.Generate(seed, options)` | `generateGalaxy(seed, options)` |
85
+ | `Preset.SpaceOpera with { Systems = 120 }` | `{...Preset.spaceOpera, systems: 120}` |
86
+ | `galaxy.Systems[i]`, `galaxy.System(i)` | `galaxy.system(i)` |
87
+ | `Universe.At(address, options)` | `generateAt(address, options)` |
88
+ | `Universe.Link(address, options)` | `linkTo(address, options)` |
89
+ | `Address.TryParse(text, out a, out error)` | `Address.tryParse(text)` returns `{address}` or `{error}` |
90
+ | `options.ToCode()`, `GeneratorOptions.FromCode(code)`, `options.Check()` | `optionsToCode`, `optionsFromCode`, `checkOptions` |
91
+ | `obj.ToJson()` | `toJson('galaxy', obj)` |
92
+ | `ArgumentException` | `RangeError` (or `SyntaxError` for unreadable text) with the same message |
93
+ | enums | string unions with the C# member names (`'Barred'`, `'K'`) |
94
+
95
+ ## The seed promise
96
+
97
+ A seed, its options and the generator version give the same universe in C#, Unity and TypeScript, on every platform. The randomness is PCG32 with SplitMix64 and FNV-1a seeding, and the maths that feeds generation uses no platform floating-point functions. CI runs every C# golden file against both builds on Node 20 to 26, Windows and macOS, and the consumer fixtures under Bun and Deno. A change that would alter output for an existing seed gets a new generator version, so old addresses keep meaning what they meant.
98
+
99
+ ## License
100
+
101
+ MIT