worldorbit 2.5.8 → 2.5.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worldorbit",
3
- "version": "2.5.8",
3
+ "version": "2.5.9",
4
4
  "description": "A text-based DSL and parser pipeline for orbital worldbuilding",
5
5
  "type": "module",
6
6
  "main": "./dist/unpkg/worldorbit.esm.js",
@@ -1,6 +1,6 @@
1
1
  import { WorldOrbitError } from "./errors.js";
2
2
  import { getFieldSchema, supportsObjectType, unitFamilyAllowsUnit, } from "./schema.js";
3
- const UNIT_PATTERN = /^(-?\d+(?:\.\d+)?)(au|km|re|sol|me|d|y|h|deg)?$/;
3
+ const UNIT_PATTERN = /^(-?\d+(?:\.\d+)?)(kpc|min|mj|rj|ky|my|gy|au|km|me|re|pc|ly|deg|sol|K|m|s|h|d|y)?$/;
4
4
  const BOOLEAN_VALUES = new Map([
5
5
  ["true", true],
6
6
  ["false", false],
@@ -1,6 +1,10 @@
1
1
  const AU_IN_KM = 149_597_870.7;
2
2
  const EARTH_RADIUS_IN_KM = 6_371;
3
+ const JUPITER_RADIUS_IN_KM = 71_492;
3
4
  const SOLAR_RADIUS_IN_KM = 695_700;
5
+ const LY_IN_AU = 63_241.077;
6
+ const PC_IN_AU = 206_264.806;
7
+ const KPC_IN_AU = 206_264_806;
4
8
  const ISO_FLATTENING = 0.68;
5
9
  const MIN_ISO_MINOR_SCALE = 0.2;
6
10
  const ARC_SAMPLE_COUNT = 28;
@@ -1340,11 +1344,23 @@ function toDistanceMetric(value) {
1340
1344
  return value.value;
1341
1345
  case "km":
1342
1346
  return value.value / AU_IN_KM;
1347
+ case "m":
1348
+ return (value.value / 1_000) / AU_IN_KM;
1349
+ case "ly":
1350
+ return value.value * LY_IN_AU;
1351
+ case "pc":
1352
+ return value.value * PC_IN_AU;
1353
+ case "kpc":
1354
+ return value.value * KPC_IN_AU;
1343
1355
  case "re":
1344
1356
  return (value.value * EARTH_RADIUS_IN_KM) / AU_IN_KM;
1357
+ case "rj":
1358
+ return (value.value * JUPITER_RADIUS_IN_KM) / AU_IN_KM;
1345
1359
  case "sol":
1346
1360
  return (value.value * SOLAR_RADIUS_IN_KM) / AU_IN_KM;
1347
1361
  default:
1362
+ // Unitless or non-distance units (me, mj, s, min, h, d, y, ky, my, gy, K, deg):
1363
+ // return raw value — renderer treats it as an abstract metric
1348
1364
  return value.value;
1349
1365
  }
1350
1366
  }
@@ -283,13 +283,13 @@ export function supportsObjectType(schema, objectType) {
283
283
  export function unitFamilyAllowsUnit(family, unit) {
284
284
  switch (family) {
285
285
  case "distance":
286
- return unit === null || ["au", "km", "re", "sol"].includes(unit);
286
+ return unit === null || ["au", "km", "m", "ly", "pc", "kpc", "re", "sol"].includes(unit);
287
287
  case "radius":
288
- return unit === null || ["km", "re", "sol"].includes(unit);
288
+ return unit === null || ["km", "m", "re", "rj", "sol"].includes(unit);
289
289
  case "mass":
290
- return unit === null || ["me", "sol"].includes(unit);
290
+ return unit === null || ["me", "mj", "sol"].includes(unit);
291
291
  case "duration":
292
- return unit === null || ["h", "d", "y"].includes(unit);
292
+ return unit === null || ["s", "min", "h", "d", "y", "ky", "my", "gy"].includes(unit);
293
293
  case "angle":
294
294
  return unit === null || unit === "deg";
295
295
  case "generic":
@@ -1,6 +1,6 @@
1
1
  export type WorldOrbitObjectType = "system" | "star" | "planet" | "moon" | "belt" | "asteroid" | "comet" | "ring" | "structure" | "phenomenon";
2
2
  export type PlacementMode = "orbit" | "at" | "surface" | "free";
3
- export type Unit = "au" | "km" | "re" | "sol" | "me" | "d" | "y" | "h" | "deg";
3
+ export type Unit = "au" | "km" | "m" | "ly" | "pc" | "kpc" | "re" | "rj" | "sol" | "me" | "mj" | "s" | "min" | "h" | "d" | "y" | "ky" | "my" | "gy" | "K" | "deg";
4
4
  export type WorldOrbitDocumentVersion = "1.0";
5
5
  export type WorldOrbitAtlasDocumentVersion = "2.0";
6
6
  export type WorldOrbitDraftDocumentVersion = "2.0-draft";