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.
- package/README.md +20 -9
- package/dist/browser/core/dist/atlas-edit.d.ts +11 -0
- package/dist/browser/core/dist/atlas-edit.js +347 -0
- package/dist/browser/core/dist/atlas-utils.d.ts +22 -0
- package/dist/browser/core/dist/atlas-utils.js +189 -0
- package/dist/browser/core/dist/atlas-validate.d.ts +2 -0
- package/dist/browser/core/dist/atlas-validate.js +488 -0
- package/dist/browser/core/dist/diagnostics.d.ts +10 -0
- package/dist/browser/core/dist/diagnostics.js +109 -0
- package/dist/browser/core/dist/draft-parse.d.ts +3 -0
- package/dist/browser/core/dist/draft-parse.js +1654 -0
- package/dist/browser/core/dist/draft.d.ts +21 -0
- package/dist/browser/core/dist/draft.js +482 -0
- package/dist/browser/core/dist/errors.d.ts +7 -0
- package/dist/browser/core/dist/errors.js +16 -0
- package/dist/browser/core/dist/format.d.ts +4 -0
- package/dist/browser/core/dist/format.js +613 -0
- package/dist/browser/core/dist/index.d.ts +29 -0
- package/dist/browser/core/dist/index.js +35 -6542
- package/dist/browser/core/dist/load.d.ts +4 -0
- package/dist/browser/core/dist/load.js +182 -0
- package/dist/browser/core/dist/markdown.d.ts +2 -0
- package/dist/browser/core/dist/markdown.js +37 -0
- package/dist/browser/core/dist/normalize.d.ts +2 -0
- package/dist/browser/core/dist/normalize.js +312 -0
- package/dist/browser/core/dist/parse.d.ts +2 -0
- package/dist/browser/core/dist/parse.js +133 -0
- package/dist/browser/core/dist/scene.d.ts +3 -0
- package/dist/browser/core/dist/scene.js +1901 -0
- package/dist/browser/core/dist/schema.d.ts +8 -0
- package/dist/browser/core/dist/schema.js +298 -0
- package/dist/browser/core/dist/spatial-scene.d.ts +3 -0
- package/dist/browser/core/dist/spatial-scene.js +420 -0
- package/dist/browser/core/dist/tokenize.d.ts +4 -0
- package/dist/browser/core/dist/tokenize.js +68 -0
- package/dist/browser/core/dist/types.d.ts +637 -0
- package/dist/browser/core/dist/types.js +1 -0
- package/dist/browser/core/dist/validate.d.ts +2 -0
- package/dist/browser/core/dist/validate.js +56 -0
- package/dist/browser/editor/dist/editor.d.ts +2 -0
- package/dist/browser/editor/dist/editor.js +3700 -0
- package/dist/browser/editor/dist/index.d.ts +2 -0
- package/dist/browser/editor/dist/index.js +1 -12250
- package/dist/browser/editor/dist/types.d.ts +59 -0
- package/dist/browser/editor/dist/types.js +1 -0
- package/dist/browser/markdown/dist/html.d.ts +3 -0
- package/dist/browser/markdown/dist/html.js +64 -0
- package/dist/browser/markdown/dist/index.d.ts +4 -0
- package/dist/browser/markdown/dist/index.js +3 -6179
- package/dist/browser/markdown/dist/rehype.d.ts +10 -0
- package/dist/browser/markdown/dist/rehype.js +49 -0
- package/dist/browser/markdown/dist/remark.d.ts +9 -0
- package/dist/browser/markdown/dist/remark.js +28 -0
- package/dist/browser/markdown/dist/types.d.ts +11 -0
- package/dist/browser/markdown/dist/types.js +1 -0
- package/dist/browser/viewer/dist/atlas-state.d.ts +12 -0
- package/dist/browser/viewer/dist/atlas-state.js +269 -0
- package/dist/browser/viewer/dist/atlas-viewer.d.ts +2 -0
- package/dist/browser/viewer/dist/atlas-viewer.js +495 -0
- package/dist/browser/viewer/dist/custom-element.d.ts +1 -0
- package/dist/browser/viewer/dist/custom-element.js +78 -0
- package/dist/browser/viewer/dist/embed.d.ts +24 -0
- package/dist/browser/viewer/dist/embed.js +172 -0
- package/dist/browser/viewer/dist/errors.d.ts +6 -0
- package/dist/browser/viewer/dist/errors.js +12 -0
- package/dist/browser/viewer/dist/index.d.ts +10 -0
- package/dist/browser/viewer/dist/index.js +9 -8334
- package/dist/browser/viewer/dist/minimap.d.ts +3 -0
- package/dist/browser/viewer/dist/minimap.js +63 -0
- package/dist/browser/viewer/dist/render.d.ts +6 -0
- package/dist/browser/viewer/dist/render.js +670 -0
- package/dist/browser/viewer/dist/runtime-3d.d.ts +19 -0
- package/dist/browser/viewer/dist/runtime-3d.js +494 -0
- package/dist/browser/viewer/dist/theme.d.ts +4 -0
- package/dist/browser/viewer/dist/theme.js +103 -0
- package/dist/browser/viewer/dist/tooltip.d.ts +3 -0
- package/dist/browser/viewer/dist/tooltip.js +198 -0
- package/dist/browser/viewer/dist/types.d.ts +292 -0
- package/dist/browser/viewer/dist/types.js +1 -0
- package/dist/browser/viewer/dist/vendor/three.module.js +53032 -0
- package/dist/browser/viewer/dist/viewer-state.d.ts +19 -0
- package/dist/browser/viewer/dist/viewer-state.js +162 -0
- package/dist/browser/viewer/dist/viewer.d.ts +2 -0
- package/dist/browser/viewer/dist/viewer.js +1662 -0
- package/dist/unpkg/core/dist/atlas-edit.d.ts +11 -0
- package/dist/unpkg/core/dist/atlas-edit.js +347 -0
- package/dist/unpkg/core/dist/atlas-utils.d.ts +22 -0
- package/dist/unpkg/core/dist/atlas-utils.js +189 -0
- package/dist/unpkg/core/dist/atlas-validate.d.ts +2 -0
- package/dist/unpkg/core/dist/atlas-validate.js +488 -0
- package/dist/unpkg/core/dist/diagnostics.d.ts +10 -0
- package/dist/unpkg/core/dist/diagnostics.js +109 -0
- package/dist/unpkg/core/dist/draft-parse.d.ts +3 -0
- package/dist/unpkg/core/dist/draft-parse.js +1654 -0
- package/dist/unpkg/core/dist/draft.d.ts +21 -0
- package/dist/unpkg/core/dist/draft.js +482 -0
- package/dist/unpkg/core/dist/errors.d.ts +7 -0
- package/dist/unpkg/core/dist/errors.js +16 -0
- package/dist/unpkg/core/dist/format.d.ts +4 -0
- package/dist/unpkg/core/dist/format.js +613 -0
- package/dist/unpkg/core/dist/index.d.ts +29 -0
- package/dist/unpkg/core/dist/index.js +35 -6614
- package/dist/unpkg/core/dist/load.d.ts +4 -0
- package/dist/unpkg/core/dist/load.js +182 -0
- package/dist/unpkg/core/dist/markdown.d.ts +2 -0
- package/dist/unpkg/core/dist/markdown.js +37 -0
- package/dist/unpkg/core/dist/normalize.d.ts +2 -0
- package/dist/unpkg/core/dist/normalize.js +312 -0
- package/dist/unpkg/core/dist/parse.d.ts +2 -0
- package/dist/unpkg/core/dist/parse.js +133 -0
- package/dist/unpkg/core/dist/scene.d.ts +3 -0
- package/dist/unpkg/core/dist/scene.js +1901 -0
- package/dist/unpkg/core/dist/schema.d.ts +8 -0
- package/dist/unpkg/core/dist/schema.js +298 -0
- package/dist/unpkg/core/dist/spatial-scene.d.ts +3 -0
- package/dist/unpkg/core/dist/spatial-scene.js +420 -0
- package/dist/unpkg/core/dist/tokenize.d.ts +4 -0
- package/dist/unpkg/core/dist/tokenize.js +68 -0
- package/dist/unpkg/core/dist/types.d.ts +637 -0
- package/dist/unpkg/core/dist/types.js +1 -0
- package/dist/unpkg/core/dist/validate.d.ts +2 -0
- package/dist/unpkg/core/dist/validate.js +56 -0
- package/dist/unpkg/editor/dist/editor.d.ts +2 -0
- package/dist/unpkg/editor/dist/editor.js +3700 -0
- package/dist/unpkg/editor/dist/index.d.ts +2 -0
- package/dist/unpkg/editor/dist/index.js +1 -12275
- package/dist/unpkg/editor/dist/types.d.ts +59 -0
- package/dist/unpkg/editor/dist/types.js +1 -0
- package/dist/unpkg/markdown/dist/html.d.ts +3 -0
- package/dist/unpkg/markdown/dist/html.js +64 -0
- package/dist/unpkg/markdown/dist/index.d.ts +4 -0
- package/dist/unpkg/markdown/dist/index.js +3 -6207
- package/dist/unpkg/markdown/dist/rehype.d.ts +10 -0
- package/dist/unpkg/markdown/dist/rehype.js +49 -0
- package/dist/unpkg/markdown/dist/remark.d.ts +9 -0
- package/dist/unpkg/markdown/dist/remark.js +28 -0
- package/dist/unpkg/markdown/dist/types.d.ts +11 -0
- package/dist/unpkg/markdown/dist/types.js +1 -0
- package/dist/unpkg/viewer/dist/atlas-state.d.ts +12 -0
- package/dist/unpkg/viewer/dist/atlas-state.js +269 -0
- package/dist/unpkg/viewer/dist/atlas-viewer.d.ts +2 -0
- package/dist/unpkg/viewer/dist/atlas-viewer.js +495 -0
- package/dist/unpkg/viewer/dist/custom-element.d.ts +1 -0
- package/dist/unpkg/viewer/dist/custom-element.js +78 -0
- package/dist/unpkg/viewer/dist/embed.d.ts +24 -0
- package/dist/unpkg/viewer/dist/embed.js +172 -0
- package/dist/unpkg/viewer/dist/errors.d.ts +6 -0
- package/dist/unpkg/viewer/dist/errors.js +12 -0
- package/dist/unpkg/viewer/dist/index.d.ts +10 -0
- package/dist/unpkg/viewer/dist/index.js +9 -8391
- package/dist/unpkg/viewer/dist/minimap.d.ts +3 -0
- package/dist/unpkg/viewer/dist/minimap.js +63 -0
- package/dist/unpkg/viewer/dist/render.d.ts +6 -0
- package/dist/unpkg/viewer/dist/render.js +670 -0
- package/dist/unpkg/viewer/dist/runtime-3d.d.ts +19 -0
- package/dist/unpkg/viewer/dist/runtime-3d.js +494 -0
- package/dist/unpkg/viewer/dist/theme.d.ts +4 -0
- package/dist/unpkg/viewer/dist/theme.js +103 -0
- package/dist/unpkg/viewer/dist/tooltip.d.ts +3 -0
- package/dist/unpkg/viewer/dist/tooltip.js +198 -0
- package/dist/unpkg/viewer/dist/types.d.ts +292 -0
- package/dist/unpkg/viewer/dist/types.js +1 -0
- package/dist/unpkg/viewer/dist/vendor/three.module.js +53032 -0
- package/dist/unpkg/viewer/dist/viewer-state.d.ts +19 -0
- package/dist/unpkg/viewer/dist/viewer-state.js +162 -0
- package/dist/unpkg/viewer/dist/viewer.d.ts +2 -0
- package/dist/unpkg/viewer/dist/viewer.js +1662 -0
- package/dist/unpkg/worldorbit-core.min.js +10 -10
- package/dist/unpkg/worldorbit-editor.min.js +4109 -256
- package/dist/unpkg/worldorbit-markdown.min.js +26 -26
- package/dist/unpkg/worldorbit-viewer.min.js +3945 -92
- package/dist/unpkg/worldorbit.js +32219 -199
- package/dist/unpkg/worldorbit.min.js +3949 -96
- package/package.json +1 -1
- package/packages/core/dist/index.d.ts +1 -0
- package/packages/core/dist/index.js +1 -0
- package/packages/core/dist/spatial-scene.d.ts +3 -0
- package/packages/core/dist/spatial-scene.js +420 -0
- package/packages/core/dist/types.d.ts +105 -0
- package/packages/editor/dist/editor.js +25 -4
- package/packages/editor/dist/types.d.ts +4 -0
- package/packages/markdown/dist/html.js +10 -3
- package/packages/viewer/dist/atlas-state.js +3 -0
- package/packages/viewer/dist/atlas-viewer.js +1 -0
- package/packages/viewer/dist/custom-element.js +18 -4
- package/packages/viewer/dist/embed.d.ts +5 -1
- package/packages/viewer/dist/embed.js +58 -24
- package/packages/viewer/dist/errors.d.ts +6 -0
- package/packages/viewer/dist/errors.js +12 -0
- package/packages/viewer/dist/index.d.ts +1 -0
- package/packages/viewer/dist/index.js +1 -0
- package/packages/viewer/dist/runtime-3d.d.ts +19 -0
- package/packages/viewer/dist/runtime-3d.js +494 -0
- package/packages/viewer/dist/types.d.ts +21 -2
- package/packages/viewer/dist/vendor/three.module.js +53032 -0
- 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;
|