worldorbit 2.6.0 → 3.0.1

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.
Files changed (196) hide show
  1. package/README.md +20 -9
  2. package/dist/browser/core/dist/atlas-edit.d.ts +11 -0
  3. package/dist/browser/core/dist/atlas-edit.js +347 -0
  4. package/dist/browser/core/dist/atlas-utils.d.ts +22 -0
  5. package/dist/browser/core/dist/atlas-utils.js +189 -0
  6. package/dist/browser/core/dist/atlas-validate.d.ts +2 -0
  7. package/dist/browser/core/dist/atlas-validate.js +488 -0
  8. package/dist/browser/core/dist/diagnostics.d.ts +10 -0
  9. package/dist/browser/core/dist/diagnostics.js +109 -0
  10. package/dist/browser/core/dist/draft-parse.d.ts +3 -0
  11. package/dist/browser/core/dist/draft-parse.js +1654 -0
  12. package/dist/browser/core/dist/draft.d.ts +21 -0
  13. package/dist/browser/core/dist/draft.js +482 -0
  14. package/dist/browser/core/dist/errors.d.ts +7 -0
  15. package/dist/browser/core/dist/errors.js +16 -0
  16. package/dist/browser/core/dist/format.d.ts +4 -0
  17. package/dist/browser/core/dist/format.js +613 -0
  18. package/dist/browser/core/dist/index.d.ts +29 -0
  19. package/dist/browser/core/dist/index.js +35 -6542
  20. package/dist/browser/core/dist/load.d.ts +4 -0
  21. package/dist/browser/core/dist/load.js +182 -0
  22. package/dist/browser/core/dist/markdown.d.ts +2 -0
  23. package/dist/browser/core/dist/markdown.js +37 -0
  24. package/dist/browser/core/dist/normalize.d.ts +2 -0
  25. package/dist/browser/core/dist/normalize.js +312 -0
  26. package/dist/browser/core/dist/parse.d.ts +2 -0
  27. package/dist/browser/core/dist/parse.js +133 -0
  28. package/dist/browser/core/dist/scene.d.ts +3 -0
  29. package/dist/browser/core/dist/scene.js +1901 -0
  30. package/dist/browser/core/dist/schema.d.ts +8 -0
  31. package/dist/browser/core/dist/schema.js +298 -0
  32. package/dist/browser/core/dist/spatial-scene.d.ts +3 -0
  33. package/dist/browser/core/dist/spatial-scene.js +420 -0
  34. package/dist/browser/core/dist/tokenize.d.ts +4 -0
  35. package/dist/browser/core/dist/tokenize.js +68 -0
  36. package/dist/browser/core/dist/types.d.ts +637 -0
  37. package/dist/browser/core/dist/types.js +1 -0
  38. package/dist/browser/core/dist/validate.d.ts +2 -0
  39. package/dist/browser/core/dist/validate.js +56 -0
  40. package/dist/browser/editor/dist/editor.d.ts +2 -0
  41. package/dist/browser/editor/dist/editor.js +3700 -0
  42. package/dist/browser/editor/dist/index.d.ts +2 -0
  43. package/dist/browser/editor/dist/index.js +1 -12250
  44. package/dist/browser/editor/dist/types.d.ts +59 -0
  45. package/dist/browser/editor/dist/types.js +1 -0
  46. package/dist/browser/markdown/dist/html.d.ts +3 -0
  47. package/dist/browser/markdown/dist/html.js +64 -0
  48. package/dist/browser/markdown/dist/index.d.ts +4 -0
  49. package/dist/browser/markdown/dist/index.js +3 -6179
  50. package/dist/browser/markdown/dist/rehype.d.ts +10 -0
  51. package/dist/browser/markdown/dist/rehype.js +49 -0
  52. package/dist/browser/markdown/dist/remark.d.ts +9 -0
  53. package/dist/browser/markdown/dist/remark.js +28 -0
  54. package/dist/browser/markdown/dist/types.d.ts +11 -0
  55. package/dist/browser/markdown/dist/types.js +1 -0
  56. package/dist/browser/viewer/dist/atlas-state.d.ts +12 -0
  57. package/dist/browser/viewer/dist/atlas-state.js +269 -0
  58. package/dist/browser/viewer/dist/atlas-viewer.d.ts +2 -0
  59. package/dist/browser/viewer/dist/atlas-viewer.js +495 -0
  60. package/dist/browser/viewer/dist/custom-element.d.ts +1 -0
  61. package/dist/browser/viewer/dist/custom-element.js +78 -0
  62. package/dist/browser/viewer/dist/embed.d.ts +24 -0
  63. package/dist/browser/viewer/dist/embed.js +172 -0
  64. package/dist/browser/viewer/dist/errors.d.ts +6 -0
  65. package/dist/browser/viewer/dist/errors.js +12 -0
  66. package/dist/browser/viewer/dist/index.d.ts +10 -0
  67. package/dist/browser/viewer/dist/index.js +9 -8334
  68. package/dist/browser/viewer/dist/minimap.d.ts +3 -0
  69. package/dist/browser/viewer/dist/minimap.js +63 -0
  70. package/dist/browser/viewer/dist/render.d.ts +6 -0
  71. package/dist/browser/viewer/dist/render.js +670 -0
  72. package/dist/browser/viewer/dist/runtime-3d.d.ts +19 -0
  73. package/dist/browser/viewer/dist/runtime-3d.js +494 -0
  74. package/dist/browser/viewer/dist/theme.d.ts +4 -0
  75. package/dist/browser/viewer/dist/theme.js +103 -0
  76. package/dist/browser/viewer/dist/tooltip.d.ts +3 -0
  77. package/dist/browser/viewer/dist/tooltip.js +198 -0
  78. package/dist/browser/viewer/dist/types.d.ts +292 -0
  79. package/dist/browser/viewer/dist/types.js +1 -0
  80. package/dist/browser/viewer/dist/vendor/three.module.js +53032 -0
  81. package/dist/browser/viewer/dist/viewer-state.d.ts +19 -0
  82. package/dist/browser/viewer/dist/viewer-state.js +162 -0
  83. package/dist/browser/viewer/dist/viewer.d.ts +2 -0
  84. package/dist/browser/viewer/dist/viewer.js +1662 -0
  85. package/dist/unpkg/core/dist/atlas-edit.d.ts +11 -0
  86. package/dist/unpkg/core/dist/atlas-edit.js +347 -0
  87. package/dist/unpkg/core/dist/atlas-utils.d.ts +22 -0
  88. package/dist/unpkg/core/dist/atlas-utils.js +189 -0
  89. package/dist/unpkg/core/dist/atlas-validate.d.ts +2 -0
  90. package/dist/unpkg/core/dist/atlas-validate.js +488 -0
  91. package/dist/unpkg/core/dist/diagnostics.d.ts +10 -0
  92. package/dist/unpkg/core/dist/diagnostics.js +109 -0
  93. package/dist/unpkg/core/dist/draft-parse.d.ts +3 -0
  94. package/dist/unpkg/core/dist/draft-parse.js +1654 -0
  95. package/dist/unpkg/core/dist/draft.d.ts +21 -0
  96. package/dist/unpkg/core/dist/draft.js +482 -0
  97. package/dist/unpkg/core/dist/errors.d.ts +7 -0
  98. package/dist/unpkg/core/dist/errors.js +16 -0
  99. package/dist/unpkg/core/dist/format.d.ts +4 -0
  100. package/dist/unpkg/core/dist/format.js +613 -0
  101. package/dist/unpkg/core/dist/index.d.ts +29 -0
  102. package/dist/unpkg/core/dist/index.js +35 -6614
  103. package/dist/unpkg/core/dist/load.d.ts +4 -0
  104. package/dist/unpkg/core/dist/load.js +182 -0
  105. package/dist/unpkg/core/dist/markdown.d.ts +2 -0
  106. package/dist/unpkg/core/dist/markdown.js +37 -0
  107. package/dist/unpkg/core/dist/normalize.d.ts +2 -0
  108. package/dist/unpkg/core/dist/normalize.js +312 -0
  109. package/dist/unpkg/core/dist/parse.d.ts +2 -0
  110. package/dist/unpkg/core/dist/parse.js +133 -0
  111. package/dist/unpkg/core/dist/scene.d.ts +3 -0
  112. package/dist/unpkg/core/dist/scene.js +1901 -0
  113. package/dist/unpkg/core/dist/schema.d.ts +8 -0
  114. package/dist/unpkg/core/dist/schema.js +298 -0
  115. package/dist/unpkg/core/dist/spatial-scene.d.ts +3 -0
  116. package/dist/unpkg/core/dist/spatial-scene.js +420 -0
  117. package/dist/unpkg/core/dist/tokenize.d.ts +4 -0
  118. package/dist/unpkg/core/dist/tokenize.js +68 -0
  119. package/dist/unpkg/core/dist/types.d.ts +637 -0
  120. package/dist/unpkg/core/dist/types.js +1 -0
  121. package/dist/unpkg/core/dist/validate.d.ts +2 -0
  122. package/dist/unpkg/core/dist/validate.js +56 -0
  123. package/dist/unpkg/editor/dist/editor.d.ts +2 -0
  124. package/dist/unpkg/editor/dist/editor.js +3700 -0
  125. package/dist/unpkg/editor/dist/index.d.ts +2 -0
  126. package/dist/unpkg/editor/dist/index.js +1 -12275
  127. package/dist/unpkg/editor/dist/types.d.ts +59 -0
  128. package/dist/unpkg/editor/dist/types.js +1 -0
  129. package/dist/unpkg/markdown/dist/html.d.ts +3 -0
  130. package/dist/unpkg/markdown/dist/html.js +64 -0
  131. package/dist/unpkg/markdown/dist/index.d.ts +4 -0
  132. package/dist/unpkg/markdown/dist/index.js +3 -6207
  133. package/dist/unpkg/markdown/dist/rehype.d.ts +10 -0
  134. package/dist/unpkg/markdown/dist/rehype.js +49 -0
  135. package/dist/unpkg/markdown/dist/remark.d.ts +9 -0
  136. package/dist/unpkg/markdown/dist/remark.js +28 -0
  137. package/dist/unpkg/markdown/dist/types.d.ts +11 -0
  138. package/dist/unpkg/markdown/dist/types.js +1 -0
  139. package/dist/unpkg/viewer/dist/atlas-state.d.ts +12 -0
  140. package/dist/unpkg/viewer/dist/atlas-state.js +269 -0
  141. package/dist/unpkg/viewer/dist/atlas-viewer.d.ts +2 -0
  142. package/dist/unpkg/viewer/dist/atlas-viewer.js +495 -0
  143. package/dist/unpkg/viewer/dist/custom-element.d.ts +1 -0
  144. package/dist/unpkg/viewer/dist/custom-element.js +78 -0
  145. package/dist/unpkg/viewer/dist/embed.d.ts +24 -0
  146. package/dist/unpkg/viewer/dist/embed.js +172 -0
  147. package/dist/unpkg/viewer/dist/errors.d.ts +6 -0
  148. package/dist/unpkg/viewer/dist/errors.js +12 -0
  149. package/dist/unpkg/viewer/dist/index.d.ts +10 -0
  150. package/dist/unpkg/viewer/dist/index.js +9 -8391
  151. package/dist/unpkg/viewer/dist/minimap.d.ts +3 -0
  152. package/dist/unpkg/viewer/dist/minimap.js +63 -0
  153. package/dist/unpkg/viewer/dist/render.d.ts +6 -0
  154. package/dist/unpkg/viewer/dist/render.js +670 -0
  155. package/dist/unpkg/viewer/dist/runtime-3d.d.ts +19 -0
  156. package/dist/unpkg/viewer/dist/runtime-3d.js +494 -0
  157. package/dist/unpkg/viewer/dist/theme.d.ts +4 -0
  158. package/dist/unpkg/viewer/dist/theme.js +103 -0
  159. package/dist/unpkg/viewer/dist/tooltip.d.ts +3 -0
  160. package/dist/unpkg/viewer/dist/tooltip.js +198 -0
  161. package/dist/unpkg/viewer/dist/types.d.ts +292 -0
  162. package/dist/unpkg/viewer/dist/types.js +1 -0
  163. package/dist/unpkg/viewer/dist/vendor/three.module.js +53032 -0
  164. package/dist/unpkg/viewer/dist/viewer-state.d.ts +19 -0
  165. package/dist/unpkg/viewer/dist/viewer-state.js +162 -0
  166. package/dist/unpkg/viewer/dist/viewer.d.ts +2 -0
  167. package/dist/unpkg/viewer/dist/viewer.js +1662 -0
  168. package/dist/unpkg/worldorbit-core.min.js +10 -10
  169. package/dist/unpkg/worldorbit-editor.min.js +4109 -256
  170. package/dist/unpkg/worldorbit-markdown.min.js +26 -26
  171. package/dist/unpkg/worldorbit-viewer.min.js +3945 -92
  172. package/dist/unpkg/worldorbit.js +32219 -199
  173. package/dist/unpkg/worldorbit.min.js +3949 -96
  174. package/package.json +1 -1
  175. package/packages/core/dist/index.d.ts +1 -0
  176. package/packages/core/dist/index.js +1 -0
  177. package/packages/core/dist/spatial-scene.d.ts +3 -0
  178. package/packages/core/dist/spatial-scene.js +420 -0
  179. package/packages/core/dist/types.d.ts +105 -0
  180. package/packages/editor/dist/editor.js +25 -4
  181. package/packages/editor/dist/types.d.ts +4 -0
  182. package/packages/markdown/dist/html.js +10 -3
  183. package/packages/viewer/dist/atlas-state.js +3 -0
  184. package/packages/viewer/dist/atlas-viewer.js +1 -0
  185. package/packages/viewer/dist/custom-element.js +18 -4
  186. package/packages/viewer/dist/embed.d.ts +5 -1
  187. package/packages/viewer/dist/embed.js +58 -24
  188. package/packages/viewer/dist/errors.d.ts +6 -0
  189. package/packages/viewer/dist/errors.js +12 -0
  190. package/packages/viewer/dist/index.d.ts +1 -0
  191. package/packages/viewer/dist/index.js +1 -0
  192. package/packages/viewer/dist/runtime-3d.d.ts +19 -0
  193. package/packages/viewer/dist/runtime-3d.js +494 -0
  194. package/packages/viewer/dist/types.d.ts +21 -2
  195. package/packages/viewer/dist/vendor/three.module.js +53032 -0
  196. package/packages/viewer/dist/viewer.js +501 -41
@@ -0,0 +1,21 @@
1
+ import type { SceneRenderOptions, WorldOrbitAtlasDocument, WorldOrbitEvent, WorldOrbitAtlasSystem, WorldOrbitDiagnostic, WorldOrbitDocument, WorldOrbitObject } from "./types.js";
2
+ interface UpgradeOptions extends Pick<SceneRenderOptions, "preset" | "projection"> {
3
+ }
4
+ export declare function upgradeDocumentToV2(document: WorldOrbitDocument, options?: UpgradeOptions): WorldOrbitAtlasDocument;
5
+ export declare function upgradeDocumentToDraftV2(document: WorldOrbitDocument, options?: UpgradeOptions): {
6
+ version: "2.0-draft";
7
+ schemaVersion: "2.0-draft";
8
+ format: "worldorbit";
9
+ sourceVersion: import("./types.js").WorldOrbitDocumentVersion;
10
+ system: WorldOrbitAtlasSystem | null;
11
+ groups: import("./types.js").WorldOrbitGroup[];
12
+ relations: import("./types.js").WorldOrbitRelation[];
13
+ events: WorldOrbitEvent[];
14
+ objects: WorldOrbitObject[];
15
+ diagnostics: WorldOrbitDiagnostic[];
16
+ };
17
+ export declare function materializeAtlasDocument(document: WorldOrbitAtlasDocument, options?: {
18
+ activeEventId?: string | null;
19
+ }): WorldOrbitDocument;
20
+ export declare function materializeDraftDocument(document: WorldOrbitAtlasDocument): WorldOrbitDocument;
21
+ export {};
@@ -0,0 +1,482 @@
1
+ import { renderDocumentToScene } from "./scene.js";
2
+ export function upgradeDocumentToV2(document, options = {}) {
3
+ const scene = renderDocumentToScene(document, options);
4
+ const diagnostics = [];
5
+ const atlasMetadata = collectAtlasMetadata(document, diagnostics);
6
+ const annotations = collectDraftAnnotations(document, diagnostics);
7
+ const defaults = createDraftDefaults(document, scene.renderPreset ?? options.preset ?? null, scene.projection);
8
+ const system = document.system
9
+ ? createDraftSystem(document, defaults, atlasMetadata, annotations, diagnostics, scene.renderPreset ?? options.preset ?? null)
10
+ : null;
11
+ if (scene.viewpoints.some((viewpoint) => !viewpoint.generated)) {
12
+ diagnostics.push({
13
+ code: "upgrade.viewpoints.structured",
14
+ severity: "info",
15
+ source: "upgrade",
16
+ message: `Promoted ${scene.viewpoints.filter((viewpoint) => !viewpoint.generated).length} document-defined viewpoint(s) into the 2.0 atlas section.`,
17
+ });
18
+ }
19
+ return {
20
+ format: "worldorbit",
21
+ version: "2.5",
22
+ schemaVersion: "2.5",
23
+ sourceVersion: document.version,
24
+ system,
25
+ groups: structuredClone(document.groups ?? []),
26
+ relations: structuredClone(document.relations ?? []),
27
+ events: structuredClone(document.events ?? []),
28
+ objects: document.objects.map(cloneWorldOrbitObject),
29
+ diagnostics,
30
+ };
31
+ }
32
+ export function upgradeDocumentToDraftV2(document, options = {}) {
33
+ return convertAtlasDocumentToLegacyDraft(upgradeDocumentToV2(document, options));
34
+ }
35
+ export function materializeAtlasDocument(document, options = {}) {
36
+ const system = document.system
37
+ ? {
38
+ type: "system",
39
+ id: document.system.id,
40
+ title: document.system.title,
41
+ description: document.system.description,
42
+ epoch: document.system.epoch,
43
+ referencePlane: document.system.referencePlane,
44
+ properties: materializeDraftSystemProperties(document.system),
45
+ info: materializeDraftSystemInfo(document.system),
46
+ }
47
+ : null;
48
+ const objects = document.objects.map(cloneWorldOrbitObject);
49
+ applyEventPoseOverrides(objects, document.events ?? [], options.activeEventId ?? null);
50
+ return {
51
+ format: "worldorbit",
52
+ version: "1.0",
53
+ schemaVersion: document.version,
54
+ system,
55
+ groups: structuredClone(document.groups ?? []),
56
+ relations: structuredClone(document.relations ?? []),
57
+ events: document.events.map(cloneWorldOrbitEvent),
58
+ objects,
59
+ };
60
+ }
61
+ export function materializeDraftDocument(document) {
62
+ return materializeAtlasDocument(document);
63
+ }
64
+ function createDraftSystem(document, defaults, atlasMetadata, annotations, diagnostics, preset) {
65
+ const scene = renderDocumentToScene(document, {
66
+ preset: preset ?? undefined,
67
+ projection: defaults.view,
68
+ });
69
+ return {
70
+ type: "system",
71
+ id: document.system?.id ?? "WorldOrbit",
72
+ title: document.system?.title ?? (typeof document.system?.properties.title === "string"
73
+ ? document.system.properties.title
74
+ : null),
75
+ description: document.system?.description ?? null,
76
+ epoch: document.system?.epoch ?? null,
77
+ referencePlane: document.system?.referencePlane ?? null,
78
+ defaults,
79
+ atlasMetadata,
80
+ viewpoints: scene.viewpoints.map(mapSceneViewpointToDraftViewpoint),
81
+ annotations,
82
+ };
83
+ }
84
+ function createDraftDefaults(document, preset, projection) {
85
+ const rawView = typeof document.system?.properties.view === "string"
86
+ ? document.system.properties.view.toLowerCase()
87
+ : null;
88
+ return {
89
+ view: rawView === "topdown" ||
90
+ rawView === "isometric" ||
91
+ rawView === "orthographic" ||
92
+ rawView === "perspective"
93
+ ? rawView
94
+ : projection,
95
+ scale: typeof document.system?.properties.scale === "string"
96
+ ? document.system.properties.scale
97
+ : null,
98
+ units: typeof document.system?.properties.units === "string"
99
+ ? document.system.properties.units
100
+ : null,
101
+ preset,
102
+ theme: typeof document.system?.info["atlas.theme"] === "string"
103
+ ? document.system.info["atlas.theme"]
104
+ : null,
105
+ };
106
+ }
107
+ function collectAtlasMetadata(document, diagnostics) {
108
+ const metadata = {};
109
+ for (const [key, value] of Object.entries(document.system?.info ?? {})) {
110
+ if (key.startsWith("viewpoint.") || key.startsWith("annotation.")) {
111
+ continue;
112
+ }
113
+ metadata[key] = value;
114
+ }
115
+ const metadataKeys = Object.keys(metadata);
116
+ if (metadataKeys.length > 0) {
117
+ diagnostics.push({
118
+ code: "upgrade.atlasMetadata.preserved",
119
+ severity: "warning",
120
+ source: "upgrade",
121
+ message: `Preserved ${metadataKeys.length} system info entr${metadataKeys.length === 1 ? "y" : "ies"} as atlas metadata in the 2.0 atlas document.`,
122
+ });
123
+ }
124
+ return metadata;
125
+ }
126
+ function collectDraftAnnotations(document, diagnostics) {
127
+ const drafts = new Map();
128
+ for (const [key, value] of Object.entries(document.system?.info ?? {})) {
129
+ if (!key.startsWith("annotation.")) {
130
+ continue;
131
+ }
132
+ const [, rawId, ...fieldParts] = key.split(".");
133
+ if (!rawId || fieldParts.length === 0) {
134
+ continue;
135
+ }
136
+ const id = normalizeIdentifier(rawId);
137
+ if (!id) {
138
+ continue;
139
+ }
140
+ const draft = drafts.get(id) ?? { id };
141
+ const field = fieldParts.join(".").toLowerCase();
142
+ switch (field) {
143
+ case "label":
144
+ draft.label = value;
145
+ break;
146
+ case "target":
147
+ case "object":
148
+ draft.targetObjectId = value.trim() || null;
149
+ break;
150
+ case "body":
151
+ case "text":
152
+ case "description":
153
+ draft.body = value;
154
+ break;
155
+ case "tags":
156
+ draft.tags = splitList(value);
157
+ break;
158
+ }
159
+ drafts.set(id, draft);
160
+ }
161
+ for (const object of document.objects) {
162
+ const description = object.info.description;
163
+ if (!description) {
164
+ continue;
165
+ }
166
+ const annotationId = normalizeIdentifier(`${object.id}-notes`);
167
+ if (drafts.has(annotationId)) {
168
+ continue;
169
+ }
170
+ drafts.set(annotationId, {
171
+ id: annotationId,
172
+ label: `${object.id} Notes`,
173
+ targetObjectId: object.id,
174
+ body: description,
175
+ tags: Array.isArray(object.properties.tags)
176
+ ? object.properties.tags.filter((entry) => typeof entry === "string")
177
+ : [],
178
+ });
179
+ diagnostics.push({
180
+ code: "upgrade.annotation.objectDescription",
181
+ severity: "info",
182
+ source: "upgrade",
183
+ message: `Lifted ${object.id}.info.description into structured atlas annotation "${annotationId}".`,
184
+ objectId: object.id,
185
+ field: "description",
186
+ });
187
+ }
188
+ return [...drafts.values()]
189
+ .filter((draft) => draft.body || draft.label)
190
+ .map((draft) => ({
191
+ id: draft.id,
192
+ label: draft.label ?? humanizeIdentifier(draft.id),
193
+ targetObjectId: draft.targetObjectId ?? null,
194
+ body: draft.body ?? "",
195
+ tags: draft.tags ?? [],
196
+ sourceObjectId: draft.targetObjectId ?? null,
197
+ }))
198
+ .sort((left, right) => left.label.localeCompare(right.label));
199
+ }
200
+ function mapSceneViewpointToDraftViewpoint(viewpoint) {
201
+ return {
202
+ id: viewpoint.id,
203
+ label: viewpoint.label,
204
+ summary: viewpoint.summary,
205
+ focusObjectId: viewpoint.objectId,
206
+ selectedObjectId: viewpoint.selectedObjectId,
207
+ events: [...viewpoint.eventIds],
208
+ projection: viewpoint.projection,
209
+ preset: viewpoint.preset,
210
+ zoom: viewpoint.scale,
211
+ rotationDeg: viewpoint.rotationDeg,
212
+ camera: viewpoint.camera ? { ...viewpoint.camera } : null,
213
+ layers: { ...viewpoint.layers },
214
+ filter: viewpoint.filter
215
+ ? {
216
+ query: viewpoint.filter.query,
217
+ objectTypes: [...viewpoint.filter.objectTypes],
218
+ tags: [...viewpoint.filter.tags],
219
+ groupIds: [...viewpoint.filter.groupIds],
220
+ }
221
+ : null,
222
+ };
223
+ }
224
+ function cloneWorldOrbitObject(object) {
225
+ return {
226
+ ...object,
227
+ groups: object.groups ? [...object.groups] : undefined,
228
+ resonance: object.resonance ? { ...object.resonance } : object.resonance,
229
+ renderHints: object.renderHints ? { ...object.renderHints } : object.renderHints,
230
+ deriveRules: object.deriveRules ? object.deriveRules.map((rule) => ({ ...rule })) : undefined,
231
+ validationRules: object.validationRules
232
+ ? object.validationRules.map((rule) => ({ ...rule }))
233
+ : undefined,
234
+ lockedFields: object.lockedFields ? [...object.lockedFields] : undefined,
235
+ tolerances: object.tolerances
236
+ ? object.tolerances.map((entry) => ({
237
+ field: entry.field,
238
+ value: entry.value && typeof entry.value === "object" && "value" in entry.value
239
+ ? { value: entry.value.value, unit: entry.value.unit }
240
+ : Array.isArray(entry.value)
241
+ ? [...entry.value]
242
+ : entry.value,
243
+ }))
244
+ : undefined,
245
+ typedBlocks: object.typedBlocks
246
+ ? Object.fromEntries(Object.entries(object.typedBlocks).map(([key, block]) => [key, { ...(block ?? {}) }]))
247
+ : undefined,
248
+ properties: cloneProperties(object.properties),
249
+ placement: object.placement ? structuredClone(object.placement) : null,
250
+ info: { ...object.info },
251
+ };
252
+ }
253
+ function cloneWorldOrbitEvent(event) {
254
+ return {
255
+ ...event,
256
+ participantObjectIds: [...event.participantObjectIds],
257
+ tags: [...event.tags],
258
+ positions: event.positions.map(cloneWorldOrbitEventPose),
259
+ };
260
+ }
261
+ function cloneWorldOrbitEventPose(pose) {
262
+ return {
263
+ objectId: pose.objectId,
264
+ placement: clonePlacement(pose.placement),
265
+ inner: pose.inner ? { ...pose.inner } : undefined,
266
+ outer: pose.outer ? { ...pose.outer } : undefined,
267
+ epoch: pose.epoch ?? null,
268
+ referencePlane: pose.referencePlane ?? null,
269
+ };
270
+ }
271
+ function clonePlacement(placement) {
272
+ return placement ? structuredClone(placement) : null;
273
+ }
274
+ function applyEventPoseOverrides(objects, events, activeEventId) {
275
+ if (!activeEventId) {
276
+ return;
277
+ }
278
+ const event = events.find((entry) => entry.id === activeEventId);
279
+ if (!event) {
280
+ return;
281
+ }
282
+ const objectMap = new Map(objects.map((object) => [object.id, object]));
283
+ const referencedIds = new Set([
284
+ ...(event.targetObjectId ? [event.targetObjectId] : []),
285
+ ...event.participantObjectIds,
286
+ ...event.positions.map((pose) => pose.objectId),
287
+ ]);
288
+ for (const objectId of referencedIds) {
289
+ const object = objectMap.get(objectId);
290
+ if (!object) {
291
+ continue;
292
+ }
293
+ if (event.epoch) {
294
+ object.epoch = event.epoch;
295
+ }
296
+ if (event.referencePlane) {
297
+ object.referencePlane = event.referencePlane;
298
+ }
299
+ }
300
+ for (const pose of event.positions) {
301
+ const object = objectMap.get(pose.objectId);
302
+ if (!object) {
303
+ continue;
304
+ }
305
+ if (pose.placement) {
306
+ object.placement = clonePlacement(pose.placement);
307
+ }
308
+ if (pose.inner) {
309
+ object.properties.inner = { ...pose.inner };
310
+ }
311
+ if (pose.outer) {
312
+ object.properties.outer = { ...pose.outer };
313
+ }
314
+ if (pose.epoch) {
315
+ object.epoch = pose.epoch;
316
+ }
317
+ if (pose.referencePlane) {
318
+ object.referencePlane = pose.referencePlane;
319
+ }
320
+ }
321
+ }
322
+ function cloneProperties(properties) {
323
+ const next = {};
324
+ for (const [key, value] of Object.entries(properties)) {
325
+ if (Array.isArray(value)) {
326
+ next[key] = [...value];
327
+ continue;
328
+ }
329
+ if (value && typeof value === "object" && "value" in value) {
330
+ next[key] = {
331
+ value: value.value,
332
+ unit: value.unit,
333
+ };
334
+ continue;
335
+ }
336
+ next[key] = value;
337
+ }
338
+ return next;
339
+ }
340
+ function splitList(value) {
341
+ return value
342
+ .split(/[\s,]+/)
343
+ .map((entry) => entry.trim())
344
+ .filter(Boolean);
345
+ }
346
+ function normalizeIdentifier(value) {
347
+ return value
348
+ .trim()
349
+ .toLowerCase()
350
+ .replace(/[^a-z0-9_-]+/g, "-")
351
+ .replace(/^-+|-+$/g, "");
352
+ }
353
+ function humanizeIdentifier(value) {
354
+ return value
355
+ .split(/[-_]+/)
356
+ .filter(Boolean)
357
+ .map((segment) => segment[0].toUpperCase() + segment.slice(1))
358
+ .join(" ");
359
+ }
360
+ function materializeDraftSystemProperties(system) {
361
+ const properties = {};
362
+ if (system.title) {
363
+ properties.title = system.title;
364
+ }
365
+ properties.view = system.defaults.view;
366
+ if (system.defaults.scale) {
367
+ properties.scale = system.defaults.scale;
368
+ }
369
+ if (system.defaults.units) {
370
+ properties.units = system.defaults.units;
371
+ }
372
+ if (system.description) {
373
+ properties.description = system.description;
374
+ }
375
+ if (system.epoch) {
376
+ properties.epoch = system.epoch;
377
+ }
378
+ if (system.referencePlane) {
379
+ properties.referencePlane = system.referencePlane;
380
+ }
381
+ return properties;
382
+ }
383
+ function materializeDraftSystemInfo(system) {
384
+ const info = {
385
+ ...system.atlasMetadata,
386
+ };
387
+ if (system.defaults.theme) {
388
+ info["atlas.theme"] = system.defaults.theme;
389
+ }
390
+ for (const viewpoint of system.viewpoints) {
391
+ const prefix = `viewpoint.${viewpoint.id}`;
392
+ info[`${prefix}.label`] = viewpoint.label;
393
+ if (viewpoint.summary) {
394
+ info[`${prefix}.summary`] = viewpoint.summary;
395
+ }
396
+ if (viewpoint.focusObjectId) {
397
+ info[`${prefix}.focus`] = viewpoint.focusObjectId;
398
+ }
399
+ if (viewpoint.selectedObjectId) {
400
+ info[`${prefix}.select`] = viewpoint.selectedObjectId;
401
+ }
402
+ if (viewpoint.projection) {
403
+ info[`${prefix}.projection`] = viewpoint.projection;
404
+ }
405
+ if (viewpoint.preset) {
406
+ info[`${prefix}.preset`] = viewpoint.preset;
407
+ }
408
+ if (viewpoint.zoom !== null) {
409
+ info[`${prefix}.zoom`] = String(viewpoint.zoom);
410
+ }
411
+ if (viewpoint.rotationDeg !== 0) {
412
+ info[`${prefix}.rotation`] = String(viewpoint.rotationDeg);
413
+ }
414
+ if (viewpoint.camera?.azimuth !== null) {
415
+ info[`${prefix}.camera.azimuth`] = String(viewpoint.camera?.azimuth);
416
+ }
417
+ if (viewpoint.camera?.elevation !== null) {
418
+ info[`${prefix}.camera.elevation`] = String(viewpoint.camera?.elevation);
419
+ }
420
+ if (viewpoint.camera?.roll !== null) {
421
+ info[`${prefix}.camera.roll`] = String(viewpoint.camera?.roll);
422
+ }
423
+ if (viewpoint.camera?.distance !== null) {
424
+ info[`${prefix}.camera.distance`] = String(viewpoint.camera?.distance);
425
+ }
426
+ const serializedLayers = serializeViewpointLayers(viewpoint.layers);
427
+ if (serializedLayers) {
428
+ info[`${prefix}.layers`] = serializedLayers;
429
+ }
430
+ if (viewpoint.filter?.query) {
431
+ info[`${prefix}.query`] = viewpoint.filter.query;
432
+ }
433
+ if ((viewpoint.filter?.objectTypes.length ?? 0) > 0) {
434
+ info[`${prefix}.types`] = viewpoint.filter?.objectTypes.join(" ") ?? "";
435
+ }
436
+ if ((viewpoint.filter?.tags.length ?? 0) > 0) {
437
+ info[`${prefix}.tags`] = viewpoint.filter?.tags.join(" ") ?? "";
438
+ }
439
+ if ((viewpoint.filter?.groupIds.length ?? 0) > 0) {
440
+ info[`${prefix}.groups`] = viewpoint.filter?.groupIds.join(" ") ?? "";
441
+ }
442
+ if (viewpoint.events.length > 0) {
443
+ info[`${prefix}.events`] = viewpoint.events.join(" ");
444
+ }
445
+ }
446
+ for (const annotation of system.annotations) {
447
+ const prefix = `annotation.${annotation.id}`;
448
+ info[`${prefix}.label`] = annotation.label;
449
+ if (annotation.targetObjectId) {
450
+ info[`${prefix}.target`] = annotation.targetObjectId;
451
+ }
452
+ info[`${prefix}.body`] = annotation.body;
453
+ if (annotation.tags.length > 0) {
454
+ info[`${prefix}.tags`] = annotation.tags.join(" ");
455
+ }
456
+ if (annotation.sourceObjectId) {
457
+ info[`${prefix}.source`] = annotation.sourceObjectId;
458
+ }
459
+ }
460
+ return info;
461
+ }
462
+ function serializeViewpointLayers(layers) {
463
+ const tokens = [];
464
+ const orbitFront = layers["orbits-front"];
465
+ const orbitBack = layers["orbits-back"];
466
+ if (orbitFront !== undefined || orbitBack !== undefined) {
467
+ tokens.push(orbitFront !== false || orbitBack !== false ? "orbits" : "-orbits");
468
+ }
469
+ for (const key of ["background", "guides", "relations", "events", "objects", "labels", "metadata"]) {
470
+ if (layers[key] !== undefined) {
471
+ tokens.push(layers[key] ? key : `-${key}`);
472
+ }
473
+ }
474
+ return tokens.join(" ");
475
+ }
476
+ function convertAtlasDocumentToLegacyDraft(document) {
477
+ return {
478
+ ...document,
479
+ version: "2.0-draft",
480
+ schemaVersion: "2.0-draft",
481
+ };
482
+ }
@@ -0,0 +1,7 @@
1
+ import type { AstSourceLocation } from "./types.js";
2
+ export declare class WorldOrbitError extends Error {
3
+ readonly line?: number;
4
+ readonly column?: number;
5
+ constructor(message: string, line?: number, column?: number);
6
+ static fromLocation(message: string, location?: AstSourceLocation): WorldOrbitError;
7
+ }
@@ -0,0 +1,16 @@
1
+ export class WorldOrbitError extends Error {
2
+ line;
3
+ column;
4
+ constructor(message, line, column) {
5
+ const locationSuffix = line === undefined
6
+ ? ""
7
+ : ` (line ${line}${column === undefined ? "" : `, column ${column}`})`;
8
+ super(`${message}${locationSuffix}`);
9
+ this.name = "WorldOrbitError";
10
+ this.line = line;
11
+ this.column = column;
12
+ }
13
+ static fromLocation(message, location) {
14
+ return new WorldOrbitError(message, location?.line, location?.column);
15
+ }
16
+ }
@@ -0,0 +1,4 @@
1
+ import type { FormattableWorldOrbitDocument, FormatDocumentOptions, WorldOrbitAtlasDocument, WorldOrbitDraftDocument } from "./types.js";
2
+ export declare function formatDocument(document: FormattableWorldOrbitDocument, options?: FormatDocumentOptions): string;
3
+ export declare function formatAtlasDocument(document: WorldOrbitAtlasDocument): string;
4
+ export declare function formatDraftDocument(document: WorldOrbitAtlasDocument | WorldOrbitDraftDocument): string;