worldorbit 2.5.2
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/LICENSE.md +5 -0
- package/README.md +250 -0
- package/dist/browser/core/dist/index.js +4009 -0
- package/dist/browser/markdown/dist/index.js +3951 -0
- package/dist/browser/viewer/dist/index.js +5981 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +84 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +16 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +25 -0
- package/dist/normalize.d.ts +2 -0
- package/dist/normalize.js +243 -0
- package/dist/parse.d.ts +2 -0
- package/dist/parse.js +126 -0
- package/dist/render.d.ts +6 -0
- package/dist/render.js +683 -0
- package/dist/tokenize.d.ts +4 -0
- package/dist/tokenize.js +68 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.js +1 -0
- package/dist/unpkg/core/dist/index.js +4081 -0
- package/dist/unpkg/markdown/dist/index.js +3979 -0
- package/dist/unpkg/test.html +1 -0
- package/dist/unpkg/viewer/dist/index.js +6038 -0
- package/dist/unpkg/worldorbit-core.min.js +5 -0
- package/dist/unpkg/worldorbit-markdown.min.js +81 -0
- package/dist/unpkg/worldorbit-viewer.min.js +232 -0
- package/dist/unpkg/worldorbit.d.ts +2 -0
- package/dist/unpkg/worldorbit.js +2 -0
- package/dist/unpkg/worldorbit.min.js +236 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +31 -0
- package/dist/viewer-state.d.ts +16 -0
- package/dist/viewer-state.js +130 -0
- package/dist/viewer.d.ts +2 -0
- package/dist/viewer.js +434 -0
- package/package.json +64 -0
- package/packages/core/README.md +13 -0
- package/packages/core/dist/atlas-edit.d.ts +11 -0
- package/packages/core/dist/atlas-edit.js +210 -0
- package/packages/core/dist/diagnostics.d.ts +10 -0
- package/packages/core/dist/diagnostics.js +109 -0
- package/packages/core/dist/draft-parse.d.ts +3 -0
- package/packages/core/dist/draft-parse.js +642 -0
- package/packages/core/dist/draft.d.ts +15 -0
- package/packages/core/dist/draft.js +343 -0
- package/packages/core/dist/errors.d.ts +7 -0
- package/packages/core/dist/errors.js +16 -0
- package/packages/core/dist/format.d.ts +4 -0
- package/packages/core/dist/format.js +364 -0
- package/packages/core/dist/index.d.ts +28 -0
- package/packages/core/dist/index.js +44 -0
- package/packages/core/dist/load.d.ts +4 -0
- package/packages/core/dist/load.js +130 -0
- package/packages/core/dist/markdown.d.ts +2 -0
- package/packages/core/dist/markdown.js +37 -0
- package/packages/core/dist/normalize.d.ts +2 -0
- package/packages/core/dist/normalize.js +304 -0
- package/packages/core/dist/parse.d.ts +2 -0
- package/packages/core/dist/parse.js +133 -0
- package/packages/core/dist/scene.d.ts +3 -0
- package/packages/core/dist/scene.js +1484 -0
- package/packages/core/dist/schema.d.ts +8 -0
- package/packages/core/dist/schema.js +298 -0
- package/packages/core/dist/tokenize.d.ts +4 -0
- package/packages/core/dist/tokenize.js +68 -0
- package/packages/core/dist/types.d.ts +382 -0
- package/packages/core/dist/types.js +1 -0
- package/packages/core/dist/validate.d.ts +2 -0
- package/packages/core/dist/validate.js +56 -0
- package/packages/editor/dist/editor.d.ts +2 -0
- package/packages/editor/dist/editor.js +2620 -0
- package/packages/editor/dist/index.d.ts +2 -0
- package/packages/editor/dist/index.js +1 -0
- package/packages/editor/dist/types.d.ts +53 -0
- package/packages/editor/dist/types.js +1 -0
- package/packages/markdown/README.md +9 -0
- package/packages/markdown/dist/html.d.ts +3 -0
- package/packages/markdown/dist/html.js +57 -0
- package/packages/markdown/dist/index.d.ts +4 -0
- package/packages/markdown/dist/index.js +3 -0
- package/packages/markdown/dist/rehype.d.ts +10 -0
- package/packages/markdown/dist/rehype.js +49 -0
- package/packages/markdown/dist/remark.d.ts +9 -0
- package/packages/markdown/dist/remark.js +28 -0
- package/packages/markdown/dist/types.d.ts +11 -0
- package/packages/markdown/dist/types.js +1 -0
- package/packages/viewer/README.md +12 -0
- package/packages/viewer/dist/atlas-state.d.ts +12 -0
- package/packages/viewer/dist/atlas-state.js +251 -0
- package/packages/viewer/dist/atlas-viewer.d.ts +2 -0
- package/packages/viewer/dist/atlas-viewer.js +448 -0
- package/packages/viewer/dist/custom-element.d.ts +1 -0
- package/packages/viewer/dist/custom-element.js +64 -0
- package/packages/viewer/dist/embed.d.ts +20 -0
- package/packages/viewer/dist/embed.js +138 -0
- package/packages/viewer/dist/index.d.ts +9 -0
- package/packages/viewer/dist/index.js +8 -0
- package/packages/viewer/dist/minimap.d.ts +3 -0
- package/packages/viewer/dist/minimap.js +63 -0
- package/packages/viewer/dist/render.d.ts +6 -0
- package/packages/viewer/dist/render.js +585 -0
- package/packages/viewer/dist/theme.d.ts +4 -0
- package/packages/viewer/dist/theme.js +98 -0
- package/packages/viewer/dist/tooltip.d.ts +3 -0
- package/packages/viewer/dist/tooltip.js +154 -0
- package/packages/viewer/dist/types.d.ts +256 -0
- package/packages/viewer/dist/types.js +1 -0
- package/packages/viewer/dist/viewer-state.d.ts +19 -0
- package/packages/viewer/dist/viewer-state.js +162 -0
- package/packages/viewer/dist/viewer.d.ts +2 -0
- package/packages/viewer/dist/viewer.js +1156 -0
|
@@ -0,0 +1,343 @@
|
|
|
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.0",
|
|
22
|
+
sourceVersion: document.version,
|
|
23
|
+
system,
|
|
24
|
+
objects: document.objects.map(cloneWorldOrbitObject),
|
|
25
|
+
diagnostics,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function upgradeDocumentToDraftV2(document, options = {}) {
|
|
29
|
+
return convertAtlasDocumentToLegacyDraft(upgradeDocumentToV2(document, options));
|
|
30
|
+
}
|
|
31
|
+
export function materializeAtlasDocument(document) {
|
|
32
|
+
const system = document.system
|
|
33
|
+
? {
|
|
34
|
+
type: "system",
|
|
35
|
+
id: document.system.id,
|
|
36
|
+
properties: materializeDraftSystemProperties(document.system),
|
|
37
|
+
info: materializeDraftSystemInfo(document.system),
|
|
38
|
+
}
|
|
39
|
+
: null;
|
|
40
|
+
return {
|
|
41
|
+
format: "worldorbit",
|
|
42
|
+
version: "1.0",
|
|
43
|
+
system,
|
|
44
|
+
objects: document.objects.map(cloneWorldOrbitObject),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function materializeDraftDocument(document) {
|
|
48
|
+
return materializeAtlasDocument(document);
|
|
49
|
+
}
|
|
50
|
+
function createDraftSystem(document, defaults, atlasMetadata, annotations, diagnostics, preset) {
|
|
51
|
+
const scene = renderDocumentToScene(document, {
|
|
52
|
+
preset: preset ?? undefined,
|
|
53
|
+
projection: defaults.view,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
type: "system",
|
|
57
|
+
id: document.system?.id ?? "WorldOrbit",
|
|
58
|
+
title: typeof document.system?.properties.title === "string"
|
|
59
|
+
? document.system.properties.title
|
|
60
|
+
: null,
|
|
61
|
+
defaults,
|
|
62
|
+
atlasMetadata,
|
|
63
|
+
viewpoints: scene.viewpoints.map(mapSceneViewpointToDraftViewpoint),
|
|
64
|
+
annotations,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function createDraftDefaults(document, preset, projection) {
|
|
68
|
+
return {
|
|
69
|
+
view: typeof document.system?.properties.view === "string" &&
|
|
70
|
+
document.system.properties.view.toLowerCase() === "topdown"
|
|
71
|
+
? "topdown"
|
|
72
|
+
: projection,
|
|
73
|
+
scale: typeof document.system?.properties.scale === "string"
|
|
74
|
+
? document.system.properties.scale
|
|
75
|
+
: null,
|
|
76
|
+
units: typeof document.system?.properties.units === "string"
|
|
77
|
+
? document.system.properties.units
|
|
78
|
+
: null,
|
|
79
|
+
preset,
|
|
80
|
+
theme: typeof document.system?.info["atlas.theme"] === "string"
|
|
81
|
+
? document.system.info["atlas.theme"]
|
|
82
|
+
: null,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function collectAtlasMetadata(document, diagnostics) {
|
|
86
|
+
const metadata = {};
|
|
87
|
+
for (const [key, value] of Object.entries(document.system?.info ?? {})) {
|
|
88
|
+
if (key.startsWith("viewpoint.") || key.startsWith("annotation.")) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
metadata[key] = value;
|
|
92
|
+
}
|
|
93
|
+
const metadataKeys = Object.keys(metadata);
|
|
94
|
+
if (metadataKeys.length > 0) {
|
|
95
|
+
diagnostics.push({
|
|
96
|
+
code: "upgrade.atlasMetadata.preserved",
|
|
97
|
+
severity: "warning",
|
|
98
|
+
source: "upgrade",
|
|
99
|
+
message: `Preserved ${metadataKeys.length} system info entr${metadataKeys.length === 1 ? "y" : "ies"} as atlas metadata in the 2.0 atlas document.`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return metadata;
|
|
103
|
+
}
|
|
104
|
+
function collectDraftAnnotations(document, diagnostics) {
|
|
105
|
+
const drafts = new Map();
|
|
106
|
+
for (const [key, value] of Object.entries(document.system?.info ?? {})) {
|
|
107
|
+
if (!key.startsWith("annotation.")) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const [, rawId, ...fieldParts] = key.split(".");
|
|
111
|
+
if (!rawId || fieldParts.length === 0) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const id = normalizeIdentifier(rawId);
|
|
115
|
+
if (!id) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const draft = drafts.get(id) ?? { id };
|
|
119
|
+
const field = fieldParts.join(".").toLowerCase();
|
|
120
|
+
switch (field) {
|
|
121
|
+
case "label":
|
|
122
|
+
draft.label = value;
|
|
123
|
+
break;
|
|
124
|
+
case "target":
|
|
125
|
+
case "object":
|
|
126
|
+
draft.targetObjectId = value.trim() || null;
|
|
127
|
+
break;
|
|
128
|
+
case "body":
|
|
129
|
+
case "text":
|
|
130
|
+
case "description":
|
|
131
|
+
draft.body = value;
|
|
132
|
+
break;
|
|
133
|
+
case "tags":
|
|
134
|
+
draft.tags = splitList(value);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
drafts.set(id, draft);
|
|
138
|
+
}
|
|
139
|
+
for (const object of document.objects) {
|
|
140
|
+
const description = object.info.description;
|
|
141
|
+
if (!description) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const annotationId = normalizeIdentifier(`${object.id}-notes`);
|
|
145
|
+
if (drafts.has(annotationId)) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
drafts.set(annotationId, {
|
|
149
|
+
id: annotationId,
|
|
150
|
+
label: `${object.id} Notes`,
|
|
151
|
+
targetObjectId: object.id,
|
|
152
|
+
body: description,
|
|
153
|
+
tags: Array.isArray(object.properties.tags)
|
|
154
|
+
? object.properties.tags.filter((entry) => typeof entry === "string")
|
|
155
|
+
: [],
|
|
156
|
+
});
|
|
157
|
+
diagnostics.push({
|
|
158
|
+
code: "upgrade.annotation.objectDescription",
|
|
159
|
+
severity: "info",
|
|
160
|
+
source: "upgrade",
|
|
161
|
+
message: `Lifted ${object.id}.info.description into structured atlas annotation "${annotationId}".`,
|
|
162
|
+
objectId: object.id,
|
|
163
|
+
field: "description",
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return [...drafts.values()]
|
|
167
|
+
.filter((draft) => draft.body || draft.label)
|
|
168
|
+
.map((draft) => ({
|
|
169
|
+
id: draft.id,
|
|
170
|
+
label: draft.label ?? humanizeIdentifier(draft.id),
|
|
171
|
+
targetObjectId: draft.targetObjectId ?? null,
|
|
172
|
+
body: draft.body ?? "",
|
|
173
|
+
tags: draft.tags ?? [],
|
|
174
|
+
sourceObjectId: draft.targetObjectId ?? null,
|
|
175
|
+
}))
|
|
176
|
+
.sort((left, right) => left.label.localeCompare(right.label));
|
|
177
|
+
}
|
|
178
|
+
function mapSceneViewpointToDraftViewpoint(viewpoint) {
|
|
179
|
+
return {
|
|
180
|
+
id: viewpoint.id,
|
|
181
|
+
label: viewpoint.label,
|
|
182
|
+
summary: viewpoint.summary,
|
|
183
|
+
focusObjectId: viewpoint.objectId,
|
|
184
|
+
selectedObjectId: viewpoint.selectedObjectId,
|
|
185
|
+
projection: viewpoint.projection,
|
|
186
|
+
preset: viewpoint.preset,
|
|
187
|
+
zoom: viewpoint.scale,
|
|
188
|
+
rotationDeg: viewpoint.rotationDeg,
|
|
189
|
+
layers: { ...viewpoint.layers },
|
|
190
|
+
filter: viewpoint.filter
|
|
191
|
+
? {
|
|
192
|
+
query: viewpoint.filter.query,
|
|
193
|
+
objectTypes: [...viewpoint.filter.objectTypes],
|
|
194
|
+
tags: [...viewpoint.filter.tags],
|
|
195
|
+
groupIds: [...viewpoint.filter.groupIds],
|
|
196
|
+
}
|
|
197
|
+
: null,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function cloneWorldOrbitObject(object) {
|
|
201
|
+
return {
|
|
202
|
+
...object,
|
|
203
|
+
properties: cloneProperties(object.properties),
|
|
204
|
+
placement: object.placement ? structuredClone(object.placement) : null,
|
|
205
|
+
info: { ...object.info },
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function cloneProperties(properties) {
|
|
209
|
+
const next = {};
|
|
210
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
211
|
+
if (Array.isArray(value)) {
|
|
212
|
+
next[key] = [...value];
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (value && typeof value === "object" && "value" in value) {
|
|
216
|
+
next[key] = {
|
|
217
|
+
value: value.value,
|
|
218
|
+
unit: value.unit,
|
|
219
|
+
};
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
next[key] = value;
|
|
223
|
+
}
|
|
224
|
+
return next;
|
|
225
|
+
}
|
|
226
|
+
function splitList(value) {
|
|
227
|
+
return value
|
|
228
|
+
.split(/[\s,]+/)
|
|
229
|
+
.map((entry) => entry.trim())
|
|
230
|
+
.filter(Boolean);
|
|
231
|
+
}
|
|
232
|
+
function normalizeIdentifier(value) {
|
|
233
|
+
return value
|
|
234
|
+
.trim()
|
|
235
|
+
.toLowerCase()
|
|
236
|
+
.replace(/[^a-z0-9_-]+/g, "-")
|
|
237
|
+
.replace(/^-+|-+$/g, "");
|
|
238
|
+
}
|
|
239
|
+
function humanizeIdentifier(value) {
|
|
240
|
+
return value
|
|
241
|
+
.split(/[-_]+/)
|
|
242
|
+
.filter(Boolean)
|
|
243
|
+
.map((segment) => segment[0].toUpperCase() + segment.slice(1))
|
|
244
|
+
.join(" ");
|
|
245
|
+
}
|
|
246
|
+
function materializeDraftSystemProperties(system) {
|
|
247
|
+
const properties = {};
|
|
248
|
+
if (system.title) {
|
|
249
|
+
properties.title = system.title;
|
|
250
|
+
}
|
|
251
|
+
properties.view = system.defaults.view;
|
|
252
|
+
if (system.defaults.scale) {
|
|
253
|
+
properties.scale = system.defaults.scale;
|
|
254
|
+
}
|
|
255
|
+
if (system.defaults.units) {
|
|
256
|
+
properties.units = system.defaults.units;
|
|
257
|
+
}
|
|
258
|
+
return properties;
|
|
259
|
+
}
|
|
260
|
+
function materializeDraftSystemInfo(system) {
|
|
261
|
+
const info = {
|
|
262
|
+
...system.atlasMetadata,
|
|
263
|
+
};
|
|
264
|
+
if (system.defaults.theme) {
|
|
265
|
+
info["atlas.theme"] = system.defaults.theme;
|
|
266
|
+
}
|
|
267
|
+
for (const viewpoint of system.viewpoints) {
|
|
268
|
+
const prefix = `viewpoint.${viewpoint.id}`;
|
|
269
|
+
info[`${prefix}.label`] = viewpoint.label;
|
|
270
|
+
if (viewpoint.summary) {
|
|
271
|
+
info[`${prefix}.summary`] = viewpoint.summary;
|
|
272
|
+
}
|
|
273
|
+
if (viewpoint.focusObjectId) {
|
|
274
|
+
info[`${prefix}.focus`] = viewpoint.focusObjectId;
|
|
275
|
+
}
|
|
276
|
+
if (viewpoint.selectedObjectId) {
|
|
277
|
+
info[`${prefix}.select`] = viewpoint.selectedObjectId;
|
|
278
|
+
}
|
|
279
|
+
if (viewpoint.projection) {
|
|
280
|
+
info[`${prefix}.projection`] = viewpoint.projection;
|
|
281
|
+
}
|
|
282
|
+
if (viewpoint.preset) {
|
|
283
|
+
info[`${prefix}.preset`] = viewpoint.preset;
|
|
284
|
+
}
|
|
285
|
+
if (viewpoint.zoom !== null) {
|
|
286
|
+
info[`${prefix}.zoom`] = String(viewpoint.zoom);
|
|
287
|
+
}
|
|
288
|
+
if (viewpoint.rotationDeg !== 0) {
|
|
289
|
+
info[`${prefix}.rotation`] = String(viewpoint.rotationDeg);
|
|
290
|
+
}
|
|
291
|
+
const serializedLayers = serializeViewpointLayers(viewpoint.layers);
|
|
292
|
+
if (serializedLayers) {
|
|
293
|
+
info[`${prefix}.layers`] = serializedLayers;
|
|
294
|
+
}
|
|
295
|
+
if (viewpoint.filter?.query) {
|
|
296
|
+
info[`${prefix}.query`] = viewpoint.filter.query;
|
|
297
|
+
}
|
|
298
|
+
if ((viewpoint.filter?.objectTypes.length ?? 0) > 0) {
|
|
299
|
+
info[`${prefix}.types`] = viewpoint.filter?.objectTypes.join(" ") ?? "";
|
|
300
|
+
}
|
|
301
|
+
if ((viewpoint.filter?.tags.length ?? 0) > 0) {
|
|
302
|
+
info[`${prefix}.tags`] = viewpoint.filter?.tags.join(" ") ?? "";
|
|
303
|
+
}
|
|
304
|
+
if ((viewpoint.filter?.groupIds.length ?? 0) > 0) {
|
|
305
|
+
info[`${prefix}.groups`] = viewpoint.filter?.groupIds.join(" ") ?? "";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
for (const annotation of system.annotations) {
|
|
309
|
+
const prefix = `annotation.${annotation.id}`;
|
|
310
|
+
info[`${prefix}.label`] = annotation.label;
|
|
311
|
+
if (annotation.targetObjectId) {
|
|
312
|
+
info[`${prefix}.target`] = annotation.targetObjectId;
|
|
313
|
+
}
|
|
314
|
+
info[`${prefix}.body`] = annotation.body;
|
|
315
|
+
if (annotation.tags.length > 0) {
|
|
316
|
+
info[`${prefix}.tags`] = annotation.tags.join(" ");
|
|
317
|
+
}
|
|
318
|
+
if (annotation.sourceObjectId) {
|
|
319
|
+
info[`${prefix}.source`] = annotation.sourceObjectId;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return info;
|
|
323
|
+
}
|
|
324
|
+
function serializeViewpointLayers(layers) {
|
|
325
|
+
const tokens = [];
|
|
326
|
+
const orbitFront = layers["orbits-front"];
|
|
327
|
+
const orbitBack = layers["orbits-back"];
|
|
328
|
+
if (orbitFront !== undefined || orbitBack !== undefined) {
|
|
329
|
+
tokens.push(orbitFront !== false || orbitBack !== false ? "orbits" : "-orbits");
|
|
330
|
+
}
|
|
331
|
+
for (const key of ["background", "guides", "objects", "labels", "metadata"]) {
|
|
332
|
+
if (layers[key] !== undefined) {
|
|
333
|
+
tokens.push(layers[key] ? key : `-${key}`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return tokens.join(" ");
|
|
337
|
+
}
|
|
338
|
+
function convertAtlasDocumentToLegacyDraft(document) {
|
|
339
|
+
return {
|
|
340
|
+
...document,
|
|
341
|
+
version: "2.0-draft",
|
|
342
|
+
};
|
|
343
|
+
}
|
|
@@ -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;
|