worldorbit 2.5.6 → 2.5.8

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/README.md CHANGED
@@ -1,21 +1,32 @@
1
1
  # WorldOrbit
2
2
 
3
- **WorldOrbit is a text-first DSL, atlas viewer, and editor platform for fictional orbital systems.**
3
+ WorldOrbit is a text-first DSL, viewer, and optional editor platform for fictional orbital systems.
4
4
 
5
- Built for worldbuilders, sci-fi authors, game designers, and hobbyists, WorldOrbit makes it easy to design, visualize, and share complex stellar systems without getting tangled in node-spaghetti or hard math.
5
+ It is designed as a specialized Mermaid-like alternative for worldbuilding: you can describe stellar systems in plain text, embed them in Markdown, render them as static diagrams, or explore them interactively with pan, rotate, zoom, and object tooltips.
6
6
 
7
- With `v2.5`, WorldOrbit provides a production-ready authoring baseline that turns simple text into interactive, beautiful system atlases.
7
+ WorldOrbit is built for:
8
+
9
+ - worldbuilding projects
10
+ - Markdown-based lore repositories and CMS setups
11
+ - fictional atlases and codices
12
+ - interactive setting documentation
13
+ - browser-based orbital diagram tooling
8
14
 
9
15
  ## Why WorldOrbit?
10
16
 
11
- - **Text-First & Git-Friendly**: Write your systems in a simple, human-readable Domain Specific Language (DSL). Perfect for version control and Markdown integration.
12
- - **Relational by Position**: No complex edge types or manual graph drawing. You define where an object is (`orbit`, `at`, `surface`, `free`), and the relationships emerge naturally.
13
- - **Lore Meets Data**: An intuitive `info` block allows you to attach narrative metadata (factions, population, climate) directly to the physical bodies.
14
- - **Beautiful Results**: The built-in viewer renders your text into interactive SVG atlases with themes, viewpoints, and rich tooltips.
17
+ Generic diagram tools can show relationships, but they are not built for fictional orbital systems.
18
+
19
+ WorldOrbit is designed specifically for:
20
+
21
+ - stars, planets, moons, belts, structures, and phenomena
22
+ - orbit-aware layouts instead of generic node graphs
23
+ - Markdown-native embedding
24
+ - optional interactivity
25
+ - optional visual authoring through Studio
15
26
 
16
- ## Quick Example
27
+ WorldOrbit is not intended to be a real-world astronomy simulator or a high-precision astrophysics engine. Its goal is clear, expressive orbital worldbuilding that works well in content workflows.
17
28
 
18
- Here is how simple it is to build a star system:
29
+ ## Quick Example
19
30
 
20
31
  ```worldorbit
21
32
  schema 2.0
@@ -29,103 +40,213 @@ defaults
29
40
  preset atlas-card
30
41
  theme atlas
31
42
 
32
- star Iyath
43
+ object star Iyath
33
44
 
34
- planet Naar
45
+ object planet Naar
35
46
  orbit Iyath
36
47
  semiMajor 1.18au
37
- period 412d
38
-
39
- info
40
- faction "Veyrathische Republik"
41
- population "8.4 billion"
42
- description "Heimatwelt der Enari."
48
+ eccentricity 0.08
49
+ angle 28deg
50
+ inclination 24deg
51
+ phase 42deg
52
+ atmosphere nitrogen-oxygen
53
+ ````
54
+
55
+ ## Installation
56
+
57
+ ### npm
58
+
59
+ ```bash
60
+ npm install worldorbit
43
61
  ```
44
62
 
45
- ## The Studio Editor
63
+ ### What the `worldorbit` package contains
64
+
65
+ The published `worldorbit` package is the public entry point.
46
66
 
47
- The easiest way to get started is the **WorldOrbit Studio**, our browser-based authoring environment.
67
+ It includes:
48
68
 
49
- Capabilities include:
50
- - Interactive 2D stage with themes (`atlas`, `nightglass`, `ember`).
51
- - Live inspector editing for system defaults, viewpoints, annotations, and object properties.
52
- - Direct manipulation handles for `orbit`, `at`, `surface`, and `free` placements.
53
- - Split-pane view with live source synchronization.
54
- - Export to static SVG or interactive Embeds.
69
+ * the browser bundles
70
+ * subpath exports for core modules
71
+ * the packages used by the viewer, Markdown integration, and editor tooling
55
72
 
56
- **[Try the browser demo](/demo/index.html)**
57
- **[Open Studio Editor](/studio/index.html)**
73
+ So for most users, this is enough:
58
74
 
59
- ---
75
+ ```bash
76
+ npm install worldorbit
77
+ ```
78
+
79
+ And then:
60
80
 
61
- ## Quick Setup (Browser/CDN)
81
+ ```ts
82
+ import { parse, loadWorldOrbitSource } from "worldorbit";
83
+ import * as Viewer from "worldorbit/viewer";
84
+ ```
62
85
 
63
- You don't need a Node.js project to use WorldOrbit. You can drop it directly into any HTML file using our pre-built bundles! Let WorldOrbit parse your data and initialize an interactive atlas directly from a single script block.
86
+ ## Browser / CDN Quick Setup
87
+
88
+ For direct browser usage, use the browser bundle:
64
89
 
65
90
  ```html
66
91
  <!DOCTYPE html>
67
92
  <html>
68
93
  <head>
94
+ <meta charset="utf-8" />
95
+ <script src="https://unpkg.com/worldorbit@2.5.4/dist/unpkg/worldorbit.min.js"></script>
69
96
  <style>
70
- #view { width: 100vw; height: 100vh; }
97
+ html, body {
98
+ margin: 0;
99
+ width: 100%;
100
+ height: 100%;
101
+ }
102
+
103
+ #view {
104
+ width: 100vw;
105
+ height: 100vh;
106
+ }
71
107
  </style>
72
- <!-- Include WorldOrbit pre-bundled library -->
73
- <script src="https://unpkg.com/worldorbit@2.5.2/dist/unpkg/worldorbit.min.js"></script>
74
108
  </head>
75
109
  <body>
76
110
  <div id="view"></div>
111
+
77
112
  <script>
78
113
  const source = `
79
- system Iyath
80
- star Iyath
81
- planet Naar orbit Iyath distance 1.18au period 412d
82
- `;
83
-
84
- const parsed = WorldOrbit.loadWorldOrbitSource(source);
85
- WorldOrbit.createInteractiveViewer(document.getElementById('view'), {
86
- document: parsed.document
114
+ schema 2.0
115
+
116
+ system Iyath
117
+
118
+ object star Iyath
119
+ object planet Naar
120
+ orbit Iyath
121
+ semiMajor 1.18au
122
+ `.trim();
123
+
124
+ const loaded = WorldOrbit.loadWorldOrbitSource(source);
125
+
126
+ WorldOrbit.createInteractiveViewer(document.getElementById("view"), {
127
+ document: loaded.document
87
128
  });
88
129
  </script>
89
130
  </body>
90
131
  </html>
91
132
  ```
92
133
 
93
- ---
134
+ For browser usage, `worldorbit.min.js` is the recommended public entry point.
135
+
136
+ ## Static and Interactive Rendering
137
+
138
+ WorldOrbit can be used in different ways from the same source:
139
+
140
+ * as a static diagram
141
+ * as an interactive SVG viewer
142
+ * inside Markdown pipelines
143
+ * inside the optional Studio editor
94
144
 
95
- ## For Developers: The Ecosystem
145
+ This means the same WorldOrbit document can be:
96
146
 
97
- Under the hood, WorldOrbit is a monorepo offering several packages to integrate orbital worldbuilding into your own tools, games, or sites.
147
+ * written in plain text
148
+ * embedded in Markdown
149
+ * rendered in a documentation page
150
+ * explored interactively
151
+ * edited visually if needed
98
152
 
99
- ### `@worldorbit/core`
100
- The engine room. Use `core` when you need language tooling, schema conversion, diagnostics, or scene generation.
101
- - Parsing, normalization, validation, and AST generation.
102
- - Turn WorldOrbit source into a structured document and stable render scene.
153
+ ## Studio Editor
103
154
 
104
- <details>
105
- <summary><b>Show Example Usage</b></summary>
155
+ WorldOrbit includes an optional Studio editor for easier authoring and exploration.
156
+
157
+ Studio is useful when you want:
158
+
159
+ * visual placement editing
160
+ * source and preview side by side
161
+ * inspector-based editing
162
+ * faster onboarding for non-technical users
163
+
164
+ The editor is optional. The core format remains text-first.
165
+
166
+ ## Canonical Schema
167
+
168
+ The stable schema starts with:
169
+
170
+ ```worldorbit
171
+ schema 2.0
172
+ ```
173
+
174
+ Example:
175
+
176
+ ```worldorbit
177
+ schema 2.0
178
+
179
+ system Iyath
180
+ title "Iyath System"
181
+
182
+ defaults
183
+ view isometric
184
+ scale presentation
185
+ preset atlas-card
186
+ theme atlas
187
+
188
+ viewpoint overview
189
+ label "Atlas Overview"
190
+ summary "Fit the whole system."
191
+ projection isometric
192
+
193
+ annotation naar-notes
194
+ label "Naar Notes"
195
+ target Naar
196
+ body "Heimatwelt der Enari."
197
+
198
+ object star Iyath
199
+
200
+ object planet Naar
201
+ orbit Iyath
202
+ semiMajor 1.18au
203
+ eccentricity 0.08
204
+ angle 28deg
205
+ inclination 24deg
206
+ phase 42deg
207
+ image /demo/assets/naar-map.png
208
+ atmosphere nitrogen-oxygen
209
+ ```
210
+
211
+ Stable `1.0` source is still accepted, and legacy `schema 2.0-draft` files remain readable as a compatibility path with a deprecation diagnostic.
212
+
213
+ ## Basic Usage
214
+
215
+ ### Parse and load source
106
216
 
107
217
  ```ts
108
218
  import {
109
- formatDocument,
110
219
  loadWorldOrbitSource,
111
220
  parse,
112
- parseWorldOrbitAtlas,
113
- renderDocumentToScene,
114
- upgradeDocumentToV2,
115
- } from "@worldorbit/core";
221
+ } from "worldorbit";
116
222
 
117
- const stable = parse(`
223
+ const parsed = parse(`
118
224
  system Iyath
119
225
  star Iyath
120
226
  planet Naar orbit Iyath distance 1.18au
121
227
  `.trim());
122
228
 
123
- // Upgrade and format
124
- const atlasDocument = upgradeDocumentToV2(stable.document, { preset: "atlas-card" });
125
- const atlasSource = formatDocument(atlasDocument, { schema: "2.0" });
229
+ const loaded = loadWorldOrbitSource(`
230
+ schema 2.0
231
+
232
+ system Iyath
233
+ object star Iyath
234
+ object planet Naar
235
+ orbit Iyath
236
+ semiMajor 1.18au
237
+ `.trim());
238
+ ```
239
+
240
+ ### Render a scene
241
+
242
+ ```ts
243
+ import {
244
+ loadWorldOrbitSource,
245
+ renderDocumentToScene,
246
+ } from "worldorbit";
247
+
248
+ const loaded = loadWorldOrbitSource(source);
126
249
 
127
- // Load and render
128
- const loaded = loadWorldOrbitSource(atlasSource);
129
250
  const scene = renderDocumentToScene(loaded.document, {
130
251
  projection: "isometric",
131
252
  scaleModel: {
@@ -134,56 +255,118 @@ const scene = renderDocumentToScene(loaded.document, {
134
255
  },
135
256
  });
136
257
  ```
137
- </details>
138
-
139
- ### `@worldorbit/viewer`
140
- The presentation layer. Use `viewer` for SVG output, atlas navigation, embeds, and browser interactivity.
141
- - Scene-based SVG rendering with theme presets (`atlas`, `nightglass`, `ember`).
142
- - Rich tooltip cards, layers, projections, and serialized state for embeds.
143
258
 
144
- <details>
145
- <summary><b>Show Example Usage</b></summary>
259
+ ### Create an interactive viewer
146
260
 
147
261
  ```ts
148
- import { loadWorldOrbitSource } from "@worldorbit/core";
149
- import {
150
- createAtlasViewer,
151
- createInteractiveViewer,
152
- renderSceneToSvg,
153
- } from "@worldorbit/viewer";
262
+ import { loadWorldOrbitSource } from "worldorbit";
263
+ import { createInteractiveViewer } from "worldorbit/viewer";
154
264
 
155
265
  const loaded = loadWorldOrbitSource(source);
156
- const scene = renderDocumentToScene(loaded.document, {
266
+
267
+ createInteractiveViewer(document.getElementById("preview"), {
268
+ document: loaded.document,
157
269
  projection: "isometric",
270
+ theme: "atlas",
158
271
  });
272
+ ```
159
273
 
160
- const svg = renderSceneToSvg(scene, {
161
- theme: "atlas",
274
+ ## Package Overview
275
+
276
+ WorldOrbit is organized internally as a small ecosystem.
277
+
278
+ ### `worldorbit`
279
+
280
+ Public package entry point with browser bundles and main exports.
281
+
282
+ ### `worldorbit/core`
283
+
284
+ Use this when you need:
285
+
286
+ * parsing
287
+ * normalization
288
+ * validation
289
+ * diagnostics
290
+ * schema loading
291
+ * canonical formatting
292
+ * scene generation
293
+
294
+ ### `worldorbit/viewer`
295
+
296
+ Use this when you need:
297
+
298
+ * static SVG rendering
299
+ * interactive viewing
300
+ * atlas-style exploration
301
+ * themes and embeds
302
+
303
+ ### `worldorbit/markdown`
304
+
305
+ Use this when you want to transform fenced `worldorbit` blocks inside Markdown pipelines.
306
+
307
+ ### `worldorbit/editor`
308
+
309
+ Use this when you want browser-based visual authoring on top of the text format.
310
+
311
+ ## Core Example
312
+
313
+ ```ts
314
+ import {
315
+ formatDocument,
316
+ loadWorldOrbitSource,
317
+ parse,
318
+ parseWorldOrbitAtlas,
319
+ renderDocumentToScene,
320
+ upgradeDocumentToV2,
321
+ } from "worldorbit/core";
322
+
323
+ const stable = parse(`
324
+ system Iyath
325
+ star Iyath
326
+ planet Naar orbit Iyath distance 1.18au
327
+ `.trim());
328
+
329
+ const atlasDocument = upgradeDocumentToV2(stable.document, {
162
330
  preset: "atlas-card",
163
331
  });
164
332
 
165
- // High-level atlas with search, filters, and viewpoints
166
- const atlasViewer = createAtlasViewer(document.getElementById("atlas"), {
167
- source,
168
- theme: "atlas",
333
+ const atlasSource = formatDocument(atlasDocument, { schema: "2.0" });
334
+ const loaded = loadWorldOrbitSource(atlasSource);
335
+ const parsedAtlas = parseWorldOrbitAtlas(atlasSource);
336
+ const scene = renderDocumentToScene(loaded.document, {
337
+ projection: "isometric",
338
+ scaleModel: {
339
+ orbitDistanceMultiplier: 1.1,
340
+ bodyRadiusMultiplier: 1.15,
341
+ },
169
342
  });
170
343
  ```
171
- </details>
172
344
 
173
- ### `@worldorbit/markdown`
174
- The publishing bridge. Use `markdown` to transform fenced `worldorbit` blocks into static or hydrated atlas output.
175
- - Remark/Rehype plugins to parse and render `.md` files.
176
- - Modes for inline static SVGs or fully interactive serialised embeds.
345
+ ## Viewer Capabilities
346
+
347
+ Viewer features in `v2.5` include:
348
+
349
+ * scene-based SVG rendering
350
+ * projections: `topdown` and `isometric`
351
+ * theme presets: `atlas`, `nightglass`, `ember`
352
+ * layer controls for background, guides, orbits, objects, labels, and metadata
353
+ * selection, hover, focus, fit, pan, zoom, and rotate
354
+ * tooltip cards and object detail payloads
355
+ * viewpoints, filters, search, and bookmark capture
356
+ * deep-linkable atlas state
357
+ * embeddable viewer custom elements
177
358
 
178
- <details>
179
- <summary><b>Show Example Usage</b></summary>
359
+ ## Markdown Integration
360
+
361
+ Use `worldorbit/markdown` to transform fenced `worldorbit` blocks into static or interactive output.
180
362
 
181
363
  ```ts
182
364
  import rehypeStringify from "rehype-stringify";
183
365
  import remarkParse from "remark-parse";
184
366
  import remarkRehype from "remark-rehype";
185
367
  import { unified } from "unified";
186
- import { remarkWorldOrbit } from "@worldorbit/markdown";
368
+
369
+ import { remarkWorldOrbit } from "worldorbit/markdown";
187
370
 
188
371
  const html = String(
189
372
  await unified()
@@ -194,57 +377,66 @@ const html = String(
194
377
  .process(markdownSource),
195
378
  );
196
379
  ```
197
- </details>
198
380
 
199
- ### `@worldorbit/editor`
200
- The authoring component. Use `editor` when you want a browser-based authoring surface that roundtrips to canonical `schema 2.0`.
201
- - The foundation of the Studio app, exposing `createWorldOrbitEditor(...)`.
202
-
203
- <details>
204
- <summary><b>Show Example Usage</b></summary>
381
+ In the browser:
205
382
 
206
383
  ```ts
207
- import { createWorldOrbitEditor } from "@worldorbit/editor";
384
+ import { mountWorldOrbitEmbeds } from "worldorbit/viewer";
208
385
 
209
- const editor = createWorldOrbitEditor(document.getElementById("studio"), {
210
- source,
211
- showInspector: true,
212
- showTextPane: true,
213
- showPreview: true,
386
+ mountWorldOrbitEmbeds(document, {
387
+ mode: "interactive",
214
388
  });
215
389
  ```
216
- </details>
217
390
 
218
- ---
391
+ ## Examples
392
+
393
+ Examples live in:
219
394
 
220
- ## Installation & Build
395
+ * [examples/minimal.worldorbit](./examples/minimal.worldorbit)
396
+ * [examples/iyath.worldorbit](./examples/iyath.worldorbit)
397
+ * [examples/iyath.schema2.worldorbit](./examples/iyath.schema2.worldorbit)
398
+ * [examples/iyath.schema2-draft.worldorbit](./examples/iyath.schema2-draft.worldorbit)
399
+ * [examples/markdown/static.md](./examples/markdown/static.md)
400
+ * [examples/markdown/interactive.md](./examples/markdown/interactive.md)
401
+ * [examples/markdown/build.mjs](./examples/markdown/build.mjs)
221
402
 
222
- Want to build WorldOrbit locally or contribute to the packages?
403
+ Browser-facing examples and demos live in the repository under `demo/`, `studio/`, and `examples/`.
404
+
405
+ ## Documentation
406
+
407
+ * [migration guide: v0.8 to v1.0](./docs/migration-v0.8-to-v1.0.md)
408
+ * [migration guide: v1 to v2](./docs/migration-v1-to-v2.md)
409
+ * [API inventory](./docs/api-inventory.md)
410
+ * [changelog](./docs/changelog.md)
411
+
412
+ ## Development
223
413
 
224
414
  ```bash
225
- # Install dependencies
226
415
  npm install
227
-
228
- # Build all packages locally
229
416
  npm run build
230
-
231
- # Run tests
232
417
  npm test
233
418
  ```
234
419
 
235
- The workspace builds package outputs into `packages/*/dist` and refreshes local package shims in `node_modules/@worldorbit/...` for seamless package-style development.
420
+ The workspace builds outputs into package-specific distribution folders and browser bundles.
421
+
422
+ Useful notes:
423
+
424
+ * `npm run build` compiles all packages and refreshes local package shims
425
+ * `npm test` rebuilds first, then runs the regression suite
426
+ * the repository remains parser-first: rendering and atlas interaction stay downstream of parse, normalize, and validate
427
+
428
+ ## Project Direction
236
429
 
237
- ### Development Notes
238
- - `npm run build` compiles all packages and refreshes local package shims.
239
- - `npm test` rebuilds first, then runs the Node and jsdom-based regression suite.
240
- - **Parser-first**: The repository guarantees that rendering and atlas interaction always stay downstream of parse, normalize, and validate.
430
+ WorldOrbit is intended as a specialized Mermaid-like solution for fictional orbital systems.
241
431
 
242
- ---
432
+ The long-term focus is:
243
433
 
244
- ## Documentation & Resources
434
+ * strong text-first authoring
435
+ * clean Markdown embedding
436
+ * rich static and interactive rendering
437
+ * optional visual editing
438
+ * stable schema evolution over time
245
439
 
246
- - API inventory: [docs/api-inventory.md](docs/api-inventory.md)
247
- - Changelog: [docs/changelog.md](docs/changelog.md)
440
+ ## License
248
441
 
249
- ### Examples
250
- You can find various example atlases and markdown files in the [`examples/`](examples/) directory, showcasing minimal setups, complex systems, and markdown integrations.
442
+ MIT