worldorbit 3.0.7 → 3.1.0
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/dist/browser/core/dist/atlas-edit.js +5 -1
- package/dist/browser/core/dist/atlas-validate.js +1 -1
- package/dist/browser/core/dist/draft-parse.js +14 -9
- package/dist/browser/core/dist/draft.d.ts +1 -0
- package/dist/browser/core/dist/draft.js +4 -2
- package/dist/browser/core/dist/format.js +5 -3
- package/dist/browser/core/dist/load.js +3 -2
- package/dist/browser/core/dist/normalize.js +36 -0
- package/dist/browser/core/dist/parse.js +54 -0
- package/dist/browser/core/dist/scene.js +1 -0
- package/dist/browser/core/dist/types.d.ts +21 -1
- package/dist/unpkg/core/dist/atlas-edit.js +5 -1
- package/dist/unpkg/core/dist/atlas-validate.js +1 -1
- package/dist/unpkg/core/dist/draft-parse.js +14 -9
- package/dist/unpkg/core/dist/draft.d.ts +1 -0
- package/dist/unpkg/core/dist/draft.js +4 -2
- package/dist/unpkg/core/dist/format.js +5 -3
- package/dist/unpkg/core/dist/load.js +3 -2
- package/dist/unpkg/core/dist/normalize.js +36 -0
- package/dist/unpkg/core/dist/parse.js +54 -0
- package/dist/unpkg/core/dist/scene.js +1 -0
- package/dist/unpkg/core/dist/types.d.ts +21 -1
- package/dist/unpkg/worldorbit-core.min.js +9 -9
- package/dist/unpkg/worldorbit-editor.min.js +206 -206
- package/dist/unpkg/worldorbit-markdown.min.js +19 -19
- package/dist/unpkg/worldorbit-viewer.min.js +203 -203
- package/dist/unpkg/worldorbit.js +112 -14
- package/dist/unpkg/worldorbit.min.js +191 -191
- package/package.json +1 -1
- package/packages/core/dist/atlas-edit.js +5 -1
- package/packages/core/dist/atlas-validate.js +1 -1
- package/packages/core/dist/draft-parse.js +14 -9
- package/packages/core/dist/draft.d.ts +1 -0
- package/packages/core/dist/draft.js +4 -2
- package/packages/core/dist/format.js +5 -3
- package/packages/core/dist/load.js +3 -2
- package/packages/core/dist/normalize.js +36 -0
- package/packages/core/dist/parse.js +54 -0
- package/packages/core/dist/scene.js +1 -0
- package/packages/core/dist/types.d.ts +21 -1
package/dist/unpkg/worldorbit.js
CHANGED
|
@@ -31171,9 +31171,14 @@ void main() {
|
|
|
31171
31171
|
function parseWorldOrbit(source) {
|
|
31172
31172
|
const lines = source.split(/\r?\n/);
|
|
31173
31173
|
const objects = [];
|
|
31174
|
+
let themeNode = null;
|
|
31174
31175
|
let currentObject = null;
|
|
31175
31176
|
let inInfoBlock = false;
|
|
31177
|
+
let inThemeBlock = false;
|
|
31176
31178
|
let infoIndent = null;
|
|
31179
|
+
let themeIndent = null;
|
|
31180
|
+
let themeBlockIndent = null;
|
|
31181
|
+
let currentThemeBlock = null;
|
|
31177
31182
|
for (let index = 0; index < lines.length; index++) {
|
|
31178
31183
|
const rawLine = lines[index];
|
|
31179
31184
|
const lineNumber = index + 1;
|
|
@@ -31190,12 +31195,48 @@ void main() {
|
|
|
31190
31195
|
}
|
|
31191
31196
|
if (indent === 0) {
|
|
31192
31197
|
inInfoBlock = false;
|
|
31198
|
+
inThemeBlock = false;
|
|
31193
31199
|
infoIndent = null;
|
|
31200
|
+
themeIndent = null;
|
|
31201
|
+
themeBlockIndent = null;
|
|
31202
|
+
currentThemeBlock = null;
|
|
31203
|
+
if (tokens.length >= 1 && tokens[0].value === "theme") {
|
|
31204
|
+
inThemeBlock = true;
|
|
31205
|
+
themeIndent = 0;
|
|
31206
|
+
themeNode = {
|
|
31207
|
+
type: "theme",
|
|
31208
|
+
preset: tokens.length >= 2 ? tokens[1].value : null,
|
|
31209
|
+
blocks: [],
|
|
31210
|
+
location: { line: lineNumber, column: tokens[0].column }
|
|
31211
|
+
};
|
|
31212
|
+
continue;
|
|
31213
|
+
}
|
|
31194
31214
|
const objectNode = parseObjectHeader(tokens, lineNumber);
|
|
31195
31215
|
objects.push(objectNode);
|
|
31196
31216
|
currentObject = objectNode;
|
|
31197
31217
|
continue;
|
|
31198
31218
|
}
|
|
31219
|
+
if (inThemeBlock) {
|
|
31220
|
+
if (tokens.length >= 2 && tokens[0].value === "preset" && (!themeBlockIndent || indent <= themeBlockIndent)) {
|
|
31221
|
+
if (themeNode) {
|
|
31222
|
+
themeNode.preset = tokens[1].value;
|
|
31223
|
+
}
|
|
31224
|
+
continue;
|
|
31225
|
+
}
|
|
31226
|
+
if (currentThemeBlock && themeBlockIndent !== null && indent > themeBlockIndent) {
|
|
31227
|
+
currentThemeBlock.fields.push(parseThemeField(tokens, lineNumber));
|
|
31228
|
+
} else {
|
|
31229
|
+
themeBlockIndent = indent;
|
|
31230
|
+
currentThemeBlock = {
|
|
31231
|
+
type: "theme-block",
|
|
31232
|
+
target: tokens[0].value,
|
|
31233
|
+
fields: [],
|
|
31234
|
+
location: { line: lineNumber, column: tokens[0].column }
|
|
31235
|
+
};
|
|
31236
|
+
themeNode?.blocks.push(currentThemeBlock);
|
|
31237
|
+
}
|
|
31238
|
+
continue;
|
|
31239
|
+
}
|
|
31199
31240
|
if (!currentObject) {
|
|
31200
31241
|
throw new WorldOrbitError("Indented line without parent object", lineNumber, indent + 1);
|
|
31201
31242
|
}
|
|
@@ -31215,6 +31256,7 @@ void main() {
|
|
|
31215
31256
|
}
|
|
31216
31257
|
return {
|
|
31217
31258
|
type: "document",
|
|
31259
|
+
theme: themeNode,
|
|
31218
31260
|
objects
|
|
31219
31261
|
};
|
|
31220
31262
|
}
|
|
@@ -31285,6 +31327,17 @@ void main() {
|
|
|
31285
31327
|
location: { line, column: tokens[0].column }
|
|
31286
31328
|
};
|
|
31287
31329
|
}
|
|
31330
|
+
function parseThemeField(tokens, line) {
|
|
31331
|
+
if (tokens.length < 2) {
|
|
31332
|
+
throw new WorldOrbitError("Invalid theme field line", line, tokens[0]?.column ?? 1);
|
|
31333
|
+
}
|
|
31334
|
+
return {
|
|
31335
|
+
type: "field",
|
|
31336
|
+
key: tokens[0].value,
|
|
31337
|
+
values: tokens.slice(1).map((token) => token.value),
|
|
31338
|
+
location: { line, column: tokens[0].column }
|
|
31339
|
+
};
|
|
31340
|
+
}
|
|
31288
31341
|
function parseInfoEntry(tokens, line) {
|
|
31289
31342
|
if (tokens.length < 2) {
|
|
31290
31343
|
throw new WorldOrbitError("Invalid info entry", line, tokens[0]?.column ?? 1);
|
|
@@ -31309,6 +31362,7 @@ void main() {
|
|
|
31309
31362
|
function normalizeDocument(ast) {
|
|
31310
31363
|
let system = null;
|
|
31311
31364
|
const objects = [];
|
|
31365
|
+
const theme = ast.theme ? normalizeTheme(ast.theme) : null;
|
|
31312
31366
|
for (const node of ast.objects) {
|
|
31313
31367
|
const normalized = normalizeObject(node);
|
|
31314
31368
|
if (node.objectType === "system") {
|
|
@@ -31324,6 +31378,7 @@ void main() {
|
|
|
31324
31378
|
format: "worldorbit",
|
|
31325
31379
|
version: "1.0",
|
|
31326
31380
|
schemaVersion: "1.0",
|
|
31381
|
+
theme,
|
|
31327
31382
|
system,
|
|
31328
31383
|
groups: [],
|
|
31329
31384
|
relations: [],
|
|
@@ -31331,6 +31386,40 @@ void main() {
|
|
|
31331
31386
|
objects
|
|
31332
31387
|
};
|
|
31333
31388
|
}
|
|
31389
|
+
function normalizeTheme(node) {
|
|
31390
|
+
const styles = {};
|
|
31391
|
+
for (const block of node.blocks) {
|
|
31392
|
+
const fieldMap = collectFields(block.fields);
|
|
31393
|
+
styles[block.target] = normalizeThemeProperties(fieldMap);
|
|
31394
|
+
}
|
|
31395
|
+
return {
|
|
31396
|
+
preset: node.preset,
|
|
31397
|
+
styles
|
|
31398
|
+
};
|
|
31399
|
+
}
|
|
31400
|
+
function normalizeThemeProperties(fieldMap) {
|
|
31401
|
+
const result = {};
|
|
31402
|
+
for (const [key, field] of fieldMap.entries()) {
|
|
31403
|
+
if (field.values.length === 1) {
|
|
31404
|
+
const rawValue = field.values[0];
|
|
31405
|
+
if (rawValue === "true") {
|
|
31406
|
+
result[key] = true;
|
|
31407
|
+
continue;
|
|
31408
|
+
}
|
|
31409
|
+
if (rawValue === "false") {
|
|
31410
|
+
result[key] = false;
|
|
31411
|
+
continue;
|
|
31412
|
+
}
|
|
31413
|
+
const num = Number(rawValue);
|
|
31414
|
+
if (!Number.isNaN(num) && rawValue.trim() !== "") {
|
|
31415
|
+
result[key] = num;
|
|
31416
|
+
continue;
|
|
31417
|
+
}
|
|
31418
|
+
}
|
|
31419
|
+
result[key] = field.values.join(" ");
|
|
31420
|
+
}
|
|
31421
|
+
return result;
|
|
31422
|
+
}
|
|
31334
31423
|
function normalizeObject(node) {
|
|
31335
31424
|
const mergedFields = [...node.inlineFields, ...node.blockFields];
|
|
31336
31425
|
validateFieldCompatibility(node.objectType, mergedFields);
|
|
@@ -32751,7 +32840,7 @@ void main() {
|
|
|
32751
32840
|
}
|
|
32752
32841
|
function parseViewpointGroups(value, document2, relationships, objectMap) {
|
|
32753
32842
|
return splitListValue(value).map((entry) => {
|
|
32754
|
-
if (document2.schemaVersion === "2.1" || document2.schemaVersion === "2.5" || document2.groups.some((group) => group.id === entry)) {
|
|
32843
|
+
if (document2.schemaVersion === "2.1" || document2.schemaVersion === "2.5" || document2.schemaVersion === "2.6.1" || document2.groups.some((group) => group.id === entry)) {
|
|
32755
32844
|
return entry;
|
|
32756
32845
|
}
|
|
32757
32846
|
if (entry.startsWith("wo-") && entry.endsWith("-group")) {
|
|
@@ -33941,9 +34030,10 @@ void main() {
|
|
|
33941
34030
|
}
|
|
33942
34031
|
return {
|
|
33943
34032
|
format: "worldorbit",
|
|
33944
|
-
version: "2.
|
|
33945
|
-
schemaVersion: "2.
|
|
34033
|
+
version: "2.6.1",
|
|
34034
|
+
schemaVersion: "2.6.1",
|
|
33946
34035
|
sourceVersion: document2.version,
|
|
34036
|
+
theme: document2.theme ?? null,
|
|
33947
34037
|
system,
|
|
33948
34038
|
groups: structuredClone(document2.groups ?? []),
|
|
33949
34039
|
relations: structuredClone(document2.relations ?? []),
|
|
@@ -33972,6 +34062,7 @@ void main() {
|
|
|
33972
34062
|
format: "worldorbit",
|
|
33973
34063
|
version: "1.0",
|
|
33974
34064
|
schemaVersion: document2.version,
|
|
34065
|
+
theme: document2.theme ?? null,
|
|
33975
34066
|
system,
|
|
33976
34067
|
groups: structuredClone(document2.groups ?? []),
|
|
33977
34068
|
relations: structuredClone(document2.relations ?? []),
|
|
@@ -34397,22 +34488,22 @@ void main() {
|
|
|
34397
34488
|
];
|
|
34398
34489
|
function formatDocument(document2, options = {}) {
|
|
34399
34490
|
const schema = options.schema ?? "auto";
|
|
34400
|
-
const useDraft = schema === "2.0" || schema === "2.1" || schema === "2.5" || schema === "2.0-draft" || document2.version === "2.0" || document2.version === "2.1" || document2.version === "2.5" || document2.version === "2.0-draft";
|
|
34491
|
+
const useDraft = schema === "2.0" || schema === "2.1" || schema === "2.5" || schema === "2.6.1" || schema === "2.0-draft" || document2.version === "2.0" || document2.version === "2.1" || document2.version === "2.5" || document2.version === "2.6.1" || document2.version === "2.0-draft";
|
|
34401
34492
|
if (useDraft) {
|
|
34402
34493
|
if (schema === "2.0-draft") {
|
|
34403
|
-
const legacyDraftDocument = document2.version === "2.0-draft" ? document2 : document2.version === "2.0" || document2.version === "2.1" || document2.version === "2.5" ? {
|
|
34494
|
+
const legacyDraftDocument = document2.version === "2.0-draft" ? document2 : document2.version === "2.0" || document2.version === "2.1" || document2.version === "2.5" || document2.version === "2.6.1" ? {
|
|
34404
34495
|
...document2,
|
|
34405
34496
|
version: "2.0-draft",
|
|
34406
34497
|
schemaVersion: "2.0-draft"
|
|
34407
34498
|
} : upgradeDocumentToDraftV2(document2);
|
|
34408
34499
|
return formatDraftDocument(legacyDraftDocument);
|
|
34409
34500
|
}
|
|
34410
|
-
const atlasDocument = document2.version === "2.0" || document2.version === "2.1" || document2.version === "2.5" ? document2 : document2.version === "2.0-draft" ? {
|
|
34501
|
+
const atlasDocument = document2.version === "2.0" || document2.version === "2.1" || document2.version === "2.5" || document2.version === "2.6.1" ? document2 : document2.version === "2.0-draft" ? {
|
|
34411
34502
|
...document2,
|
|
34412
34503
|
version: "2.0",
|
|
34413
34504
|
schemaVersion: "2.0"
|
|
34414
34505
|
} : upgradeDocumentToV2(document2);
|
|
34415
|
-
if ((schema === "2.0" || schema === "2.1" || schema === "2.5") && atlasDocument.version !== schema) {
|
|
34506
|
+
if ((schema === "2.0" || schema === "2.1" || schema === "2.5" || schema === "2.6.1") && atlasDocument.version !== schema) {
|
|
34416
34507
|
return formatAtlasDocument({
|
|
34417
34508
|
...atlasDocument,
|
|
34418
34509
|
version: schema,
|
|
@@ -35166,7 +35257,7 @@ void main() {
|
|
|
35166
35257
|
}
|
|
35167
35258
|
function validateViewpoint(viewpoint, groupIds, eventIds, sourceSchemaVersion, diagnostics, objectMap) {
|
|
35168
35259
|
const filter = viewpoint.filter;
|
|
35169
|
-
if (sourceSchemaVersion === "2.1" || sourceSchemaVersion === "2.5") {
|
|
35260
|
+
if (sourceSchemaVersion === "2.1" || sourceSchemaVersion === "2.5" || sourceSchemaVersion === "2.6.1") {
|
|
35170
35261
|
if (filter) {
|
|
35171
35262
|
for (const groupId of filter.groupIds) {
|
|
35172
35263
|
if (!groupIds.has(groupId)) {
|
|
@@ -35730,6 +35821,7 @@ void main() {
|
|
|
35730
35821
|
const baseDocument = {
|
|
35731
35822
|
format: "worldorbit",
|
|
35732
35823
|
sourceVersion: "1.0",
|
|
35824
|
+
theme: null,
|
|
35733
35825
|
system,
|
|
35734
35826
|
groups,
|
|
35735
35827
|
relations,
|
|
@@ -35763,11 +35855,11 @@ void main() {
|
|
|
35763
35855
|
return document2;
|
|
35764
35856
|
}
|
|
35765
35857
|
function assertDraftSchemaHeader(tokens, line) {
|
|
35766
|
-
if (tokens.length !== 2 || tokens[0].value.toLowerCase() !== "schema" || !["2.0-draft", "2.0", "2.1", "2.5"].includes(tokens[1].value.toLowerCase())) {
|
|
35767
|
-
throw new WorldOrbitError('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", or legacy "schema 2.0-draft"', line, tokens[0]?.column ?? 1);
|
|
35858
|
+
if (tokens.length !== 2 || tokens[0].value.toLowerCase() !== "schema" || !["2.0-draft", "2.0", "2.1", "2.5", "2.6.1"].includes(tokens[1].value.toLowerCase())) {
|
|
35859
|
+
throw new WorldOrbitError('Expected atlas header "schema 2.0", "schema 2.1", "schema 2.5", "schema 2.6.1", or legacy "schema 2.0-draft"', line, tokens[0]?.column ?? 1);
|
|
35768
35860
|
}
|
|
35769
35861
|
const version = tokens[1].value.toLowerCase();
|
|
35770
|
-
return version === "2.5" ? "2.5" : version === "2.1" ? "2.1" : version === "2.0-draft" ? "2.0-draft" : "2.0";
|
|
35862
|
+
return version === "2.6.1" ? "2.6.1" : version === "2.5" ? "2.5" : version === "2.1" ? "2.1" : version === "2.0-draft" ? "2.0-draft" : "2.0";
|
|
35771
35863
|
}
|
|
35772
35864
|
function startTopLevelSection(tokens, line, sourceSchemaVersion, diagnostics, system, objectNodes, groups, relations, events, eventPoseNodes, viewpointIds, annotationIds, groupIds, relationIds, eventIds, flags) {
|
|
35773
35865
|
const keyword = tokens[0]?.value.toLowerCase();
|
|
@@ -37063,6 +37155,8 @@ void main() {
|
|
|
37063
37155
|
return 2;
|
|
37064
37156
|
case "2.5":
|
|
37065
37157
|
return 3;
|
|
37158
|
+
case "2.6.1":
|
|
37159
|
+
return 4;
|
|
37066
37160
|
}
|
|
37067
37161
|
}
|
|
37068
37162
|
function preprocessAtlasSource(source) {
|
|
@@ -37152,12 +37246,16 @@ void main() {
|
|
|
37152
37246
|
}
|
|
37153
37247
|
|
|
37154
37248
|
// packages/core/dist/atlas-edit.js
|
|
37155
|
-
function createEmptyAtlasDocument(systemId = "WorldOrbit", version = "2.
|
|
37249
|
+
function createEmptyAtlasDocument(systemId = "WorldOrbit", version = "2.6.1") {
|
|
37156
37250
|
return {
|
|
37157
37251
|
format: "worldorbit",
|
|
37158
37252
|
version,
|
|
37159
37253
|
schemaVersion: version,
|
|
37160
37254
|
sourceVersion: "1.0",
|
|
37255
|
+
theme: {
|
|
37256
|
+
preset: "blueprint",
|
|
37257
|
+
styles: {}
|
|
37258
|
+
},
|
|
37161
37259
|
system: {
|
|
37162
37260
|
type: "system",
|
|
37163
37261
|
id: systemId,
|
|
@@ -37516,7 +37614,7 @@ void main() {
|
|
|
37516
37614
|
return "2.1";
|
|
37517
37615
|
}
|
|
37518
37616
|
if (ATLAS_SCHEMA_25_PATTERN.test(trimmed)) {
|
|
37519
|
-
return "2.
|
|
37617
|
+
return "2.6.1";
|
|
37520
37618
|
}
|
|
37521
37619
|
if (ATLAS_SCHEMA_PATTERN.test(trimmed)) {
|
|
37522
37620
|
return "2.0";
|
|
@@ -37578,7 +37676,7 @@ void main() {
|
|
|
37578
37676
|
}
|
|
37579
37677
|
function loadWorldOrbitSourceWithDiagnostics(source) {
|
|
37580
37678
|
const schemaVersion = detectWorldOrbitSchemaVersion(source);
|
|
37581
|
-
if (schemaVersion === "2.0" || schemaVersion === "2.0-draft" || schemaVersion === "2.1" || schemaVersion === "2.5") {
|
|
37679
|
+
if (schemaVersion === "2.0" || schemaVersion === "2.0-draft" || schemaVersion === "2.1" || schemaVersion === "2.5" || schemaVersion === "2.6.1") {
|
|
37582
37680
|
return loadAtlasSourceWithDiagnostics(source, schemaVersion);
|
|
37583
37681
|
}
|
|
37584
37682
|
let ast;
|