mcbe-leveldb 1.7.0 → 1.7.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/Changelog.md +6 -0
- package/nbtSchemas.d.ts +57 -58
- package/nbtSchemas.js +108 -124
- package/nbtSchemas.js.map +1 -1
- package/nbtSchemas.ts +253 -263
- package/package.json +1 -1
package/Changelog.md
CHANGED
package/nbtSchemas.d.ts
CHANGED
|
@@ -2707,10 +2707,14 @@ export declare namespace NBTSchemas {
|
|
|
2707
2707
|
};
|
|
2708
2708
|
};
|
|
2709
2709
|
};
|
|
2710
|
+
readonly LastUniqueID: {
|
|
2711
|
+
readonly description: "The numerical ID given to the last entity added on the scoreboard system.";
|
|
2712
|
+
readonly type: "long";
|
|
2713
|
+
};
|
|
2710
2714
|
readonly Objectives: {
|
|
2711
2715
|
readonly description: "A list of compound tags representing objectives.";
|
|
2712
2716
|
readonly type: "list";
|
|
2713
|
-
readonly items:
|
|
2717
|
+
readonly items: {
|
|
2714
2718
|
readonly description: "An objective.";
|
|
2715
2719
|
readonly type: "compound";
|
|
2716
2720
|
readonly required: ["Criteria", "DisplayName", "Name", "Scores"];
|
|
@@ -2747,10 +2751,7 @@ export declare namespace NBTSchemas {
|
|
|
2747
2751
|
};
|
|
2748
2752
|
};
|
|
2749
2753
|
};
|
|
2750
|
-
}
|
|
2751
|
-
readonly description: "The numerical ID given to the last entity added on the scoreboard system.";
|
|
2752
|
-
readonly type: "long";
|
|
2753
|
-
}];
|
|
2754
|
+
};
|
|
2754
2755
|
};
|
|
2755
2756
|
};
|
|
2756
2757
|
readonly $fragment: false;
|
|
@@ -12490,67 +12491,65 @@ export declare namespace NBTSchemas {
|
|
|
12490
12491
|
}[];
|
|
12491
12492
|
};
|
|
12492
12493
|
};
|
|
12494
|
+
/**
|
|
12495
|
+
* The numerical ID given to the last entity added on the scoreboard system.
|
|
12496
|
+
*/
|
|
12497
|
+
LastUniqueID: [high: number, low: number];
|
|
12493
12498
|
/**
|
|
12494
12499
|
* A list of compound tags representing objectives.
|
|
12495
12500
|
*/
|
|
12496
12501
|
Objectives: {
|
|
12497
12502
|
type: "list";
|
|
12498
12503
|
value: {
|
|
12499
|
-
type:
|
|
12500
|
-
value:
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12504
|
+
type: "compound";
|
|
12505
|
+
value: {
|
|
12506
|
+
/**
|
|
12507
|
+
* The **criterion** of this objective, currently, always `dummy`.
|
|
12508
|
+
*/
|
|
12509
|
+
Criteria: {
|
|
12510
|
+
type: "string";
|
|
12511
|
+
value: string;
|
|
12512
|
+
};
|
|
12513
|
+
/**
|
|
12514
|
+
* The **display name** of this objective.
|
|
12515
|
+
*/
|
|
12516
|
+
DisplayName: {
|
|
12517
|
+
type: "string";
|
|
12518
|
+
value: string;
|
|
12519
|
+
};
|
|
12520
|
+
/**
|
|
12521
|
+
* The internal **name** of this objective.
|
|
12522
|
+
*/
|
|
12523
|
+
Name: {
|
|
12524
|
+
type: "string";
|
|
12525
|
+
value: string;
|
|
12526
|
+
};
|
|
12527
|
+
/**
|
|
12528
|
+
* A list of compound tags representing scores tracked on this objective.
|
|
12529
|
+
*/
|
|
12530
|
+
Scores: {
|
|
12531
|
+
type: "list";
|
|
12532
|
+
value: {
|
|
12533
|
+
type: "compound";
|
|
12528
12534
|
value: {
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
};
|
|
12545
|
-
}[];
|
|
12546
|
-
};
|
|
12535
|
+
/**
|
|
12536
|
+
* The score this entity has on this objective.
|
|
12537
|
+
*/
|
|
12538
|
+
Score: {
|
|
12539
|
+
type: "int";
|
|
12540
|
+
value: number;
|
|
12541
|
+
};
|
|
12542
|
+
/**
|
|
12543
|
+
* The numerical ID given to this entity on the scoreboard system.
|
|
12544
|
+
*/
|
|
12545
|
+
ScoreboardId: {
|
|
12546
|
+
type: "long";
|
|
12547
|
+
value: [high: number, low: number];
|
|
12548
|
+
};
|
|
12549
|
+
}[];
|
|
12547
12550
|
};
|
|
12548
|
-
}
|
|
12549
|
-
|
|
12550
|
-
high: number,
|
|
12551
|
-
low: number
|
|
12552
|
-
]
|
|
12553
|
-
];
|
|
12551
|
+
};
|
|
12552
|
+
}[];
|
|
12554
12553
|
};
|
|
12555
12554
|
};
|
|
12556
12555
|
};
|
package/nbtSchemas.js
CHANGED
|
@@ -2415,53 +2415,51 @@ export var NBTSchemas;
|
|
|
2415
2415
|
},
|
|
2416
2416
|
},
|
|
2417
2417
|
},
|
|
2418
|
+
LastUniqueID: {
|
|
2419
|
+
description: "The numerical ID given to the last entity added on the scoreboard system.",
|
|
2420
|
+
type: "long",
|
|
2421
|
+
},
|
|
2418
2422
|
Objectives: {
|
|
2419
2423
|
description: "A list of compound tags representing objectives.",
|
|
2420
2424
|
type: "list",
|
|
2421
|
-
items:
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
type: "long",
|
|
2454
|
-
},
|
|
2425
|
+
items: {
|
|
2426
|
+
description: "An objective.",
|
|
2427
|
+
type: "compound",
|
|
2428
|
+
required: ["Criteria", "DisplayName", "Name", "Scores"],
|
|
2429
|
+
properties: {
|
|
2430
|
+
Criteria: {
|
|
2431
|
+
description: "The **criterion** of this objective, currently, always `dummy`.",
|
|
2432
|
+
type: "string",
|
|
2433
|
+
},
|
|
2434
|
+
DisplayName: {
|
|
2435
|
+
description: "The **display name** of this objective.",
|
|
2436
|
+
type: "string",
|
|
2437
|
+
},
|
|
2438
|
+
Name: {
|
|
2439
|
+
description: "The internal **name** of this objective.",
|
|
2440
|
+
type: "string",
|
|
2441
|
+
},
|
|
2442
|
+
Scores: {
|
|
2443
|
+
description: "A list of compound tags representing scores tracked on this objective.",
|
|
2444
|
+
type: "list",
|
|
2445
|
+
items: {
|
|
2446
|
+
description: "A tracked entity with a score.",
|
|
2447
|
+
type: "compound",
|
|
2448
|
+
required: ["Score", "ScoreboardId"],
|
|
2449
|
+
properties: {
|
|
2450
|
+
Score: {
|
|
2451
|
+
description: "The score this entity has on this objective.",
|
|
2452
|
+
type: "int",
|
|
2453
|
+
},
|
|
2454
|
+
ScoreboardId: {
|
|
2455
|
+
description: "The numerical ID given to this entity on the scoreboard system.",
|
|
2456
|
+
type: "long",
|
|
2455
2457
|
},
|
|
2456
2458
|
},
|
|
2457
2459
|
},
|
|
2458
2460
|
},
|
|
2459
2461
|
},
|
|
2460
|
-
|
|
2461
|
-
description: "The numerical ID given to the last entity added on the scoreboard system.",
|
|
2462
|
-
type: "long",
|
|
2463
|
-
},
|
|
2464
|
-
],
|
|
2462
|
+
},
|
|
2465
2463
|
},
|
|
2466
2464
|
},
|
|
2467
2465
|
$fragment: false,
|
|
@@ -8526,8 +8524,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8526
8524
|
type: { const: "compound" },
|
|
8527
8525
|
value: {
|
|
8528
8526
|
type: "object",
|
|
8529
|
-
properties: schema.properties
|
|
8530
|
-
|
|
8527
|
+
properties: schema.properties ?
|
|
8528
|
+
Object.fromEntries(Object.entries(schema.properties).map(([k, v]) => [
|
|
8531
8529
|
k,
|
|
8532
8530
|
nbtSchemaToJsonSchema(v, allSchemas, options),
|
|
8533
8531
|
]))
|
|
@@ -8731,15 +8729,14 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8731
8729
|
}
|
|
8732
8730
|
function refToType(ref, indent, opts = {}, ctx = { helperTypes: [], helperCounter: 0 }, additionalInformation = {}) {
|
|
8733
8731
|
const refLookup = opts.refLookup ?? NBTSchemas.nbtSchemas;
|
|
8734
|
-
const resolvedRef = (typeof ref === "boolean"
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
? ref.map((r) => {
|
|
8732
|
+
const resolvedRef = (typeof ref === "boolean" ? ref
|
|
8733
|
+
: Array.isArray(ref) ?
|
|
8734
|
+
ref.map((r) => {
|
|
8738
8735
|
if (typeof r === "boolean" || !r.$ref || !(r.$ref in refLookup))
|
|
8739
8736
|
return r;
|
|
8740
8737
|
const refName = resolveSchemaRefName(r.$ref, !(opts.inlineRefs ?? false), opts);
|
|
8741
|
-
return typeof refLookup[refName] === "string"
|
|
8742
|
-
|
|
8738
|
+
return typeof refLookup[refName] === "string" ?
|
|
8739
|
+
r
|
|
8743
8740
|
: {
|
|
8744
8741
|
type: refLookup[r.$ref].type,
|
|
8745
8742
|
...r /* Object.fromEntries(Object.entries(r).filter(([key]): boolean => key !== "$ref")) */,
|
|
@@ -8749,20 +8746,20 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8749
8746
|
if (typeof r === "boolean" || !r.$ref || !(r.$ref in refLookup))
|
|
8750
8747
|
return r;
|
|
8751
8748
|
const refName = resolveSchemaRefName(r.$ref, !(opts.inlineRefs ?? false), opts);
|
|
8752
|
-
return typeof refLookup[refName] === "string"
|
|
8753
|
-
|
|
8749
|
+
return typeof refLookup[refName] === "string" ?
|
|
8750
|
+
r
|
|
8754
8751
|
: {
|
|
8755
8752
|
type: refLookup[r.$ref].type,
|
|
8756
8753
|
...r /* Object.fromEntries(Object.entries(r).filter(([key]): boolean => key !== "$ref")) */,
|
|
8757
8754
|
};
|
|
8758
8755
|
})(ref)); /* ref.$ref !== undefined && ref.$ref in refLookup
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8756
|
+
? typeof refLookup[ref.$ref as keyof typeof refLookup] === "string"
|
|
8757
|
+
? ref
|
|
8758
|
+
: {
|
|
8759
|
+
...(refLookup[ref.$ref as keyof typeof refLookup] as object),
|
|
8760
|
+
...Object.fromEntries(Object.entries(ref).filter(([key]) => key !== "$ref")),
|
|
8761
|
+
}
|
|
8762
|
+
: ref */
|
|
8766
8763
|
if (resolvedRef === true) {
|
|
8767
8764
|
return { type: "any", value: "any" };
|
|
8768
8765
|
}
|
|
@@ -8805,19 +8802,16 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8805
8802
|
function schemaToBuiltType(schema, indent, opts, ctx, additionalInformation = {}) {
|
|
8806
8803
|
const refLookup = opts.refLookup ?? NBTSchemas.nbtSchemas;
|
|
8807
8804
|
const st = schema.type;
|
|
8808
|
-
const mainSchemaRefName = schema.$ref
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
const resolvedSchema = opts.inlineRefs && schema.$ref && mainSchemaRefName && mainSchemaRefName in refLookup
|
|
8812
|
-
? {
|
|
8805
|
+
const mainSchemaRefName = schema.$ref ? resolveSchemaRefName(schema.$ref, !(opts.inlineRefs ?? false), opts) : undefined;
|
|
8806
|
+
const resolvedSchema = opts.inlineRefs && schema.$ref && mainSchemaRefName && mainSchemaRefName in refLookup ?
|
|
8807
|
+
{
|
|
8813
8808
|
...refLookup[mainSchemaRefName],
|
|
8814
8809
|
...schema,
|
|
8815
8810
|
}
|
|
8816
8811
|
: schema;
|
|
8817
|
-
let allOfRefTypes = opts.inlineRefs ?? false
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
? [mainSchemaRefName + (additionalInformation.isListChild ? '["value"]' : "")]
|
|
8812
|
+
let allOfRefTypes = (opts.inlineRefs ?? false) ? undefined
|
|
8813
|
+
: typeof schema === "object" && schema.$ref !== undefined && mainSchemaRefName !== undefined /* && schema.$ref in refLookup */ ?
|
|
8814
|
+
[mainSchemaRefName + (additionalInformation.isListChild ? '["value"]' : "")]
|
|
8821
8815
|
: undefined;
|
|
8822
8816
|
if (!(opts.inlineRefs ?? false) && schema.allOf !== undefined) {
|
|
8823
8817
|
const refAllOfs = schema.allOf.filter((ref) => typeof ref === "object" && !!ref.$ref);
|
|
@@ -8850,8 +8844,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8850
8844
|
const types = refLookup[refType].type ?? resolvedSchema.type;
|
|
8851
8845
|
if (!types)
|
|
8852
8846
|
continue;
|
|
8853
|
-
inlineRefTypes.allOf.push(Array.isArray(types)
|
|
8854
|
-
|
|
8847
|
+
inlineRefTypes.allOf.push(Array.isArray(types) ?
|
|
8848
|
+
types
|
|
8855
8849
|
.map((t) => buildTypeForTag(t, refLookup[refType], indent, opts, ctx))
|
|
8856
8850
|
.join("|")
|
|
8857
8851
|
: buildTypeForTag(types, refLookup[refType], indent, opts, ctx));
|
|
@@ -8861,8 +8855,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8861
8855
|
const types = refLookup[refType].type ?? resolvedSchema.type;
|
|
8862
8856
|
if (!types)
|
|
8863
8857
|
continue;
|
|
8864
|
-
inlineRefTypes.oneOf.push(Array.isArray(types)
|
|
8865
|
-
|
|
8858
|
+
inlineRefTypes.oneOf.push(Array.isArray(types) ?
|
|
8859
|
+
types
|
|
8866
8860
|
.map((t) => buildTypeForTag(t, refLookup[refType], indent, opts, ctx))
|
|
8867
8861
|
.join("|")
|
|
8868
8862
|
: buildTypeForTag(types, refLookup[refType], indent, opts, ctx));
|
|
@@ -8873,8 +8867,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8873
8867
|
const compoundType = buildBuiltTypeForTag("compound", resolvedSchema, indent, opts, ctx);
|
|
8874
8868
|
return {
|
|
8875
8869
|
type: '"compound"',
|
|
8876
|
-
value: opts.inlineRefs ?? false
|
|
8877
|
-
|
|
8870
|
+
value: (opts.inlineRefs ?? false) ?
|
|
8871
|
+
`${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(compoundType.value) ? "" : `(${compoundType.value})`}${inlineRefTypes.allOf ? ` & ${inlineRefTypes.allOf.join(" & ")}` : ""}${inlineRefTypes.oneOf ? ` & (${inlineRefTypes.oneOf.join(" | ")})` : ""}`
|
|
8878
8872
|
: `${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(compoundType.value) ? "" : `(${compoundType.value})`}${allOfRefTypes ? ` & ${allOfRefTypes.join(" & ")}` : ""}${oneOfRefTypes ? ` & (${oneOfRefTypes.join(" | ")})` : ""}`.replace(/^ & /, ""),
|
|
8879
8873
|
};
|
|
8880
8874
|
}
|
|
@@ -8891,8 +8885,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8891
8885
|
const builtType = buildBuiltTypeForTag(st, resolvedSchema, indent, opts, ctx);
|
|
8892
8886
|
return {
|
|
8893
8887
|
type: builtType.type,
|
|
8894
|
-
value: opts.inlineRefs ?? false
|
|
8895
|
-
|
|
8888
|
+
value: (opts.inlineRefs ?? false) ?
|
|
8889
|
+
`${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(builtType.value) ? "" : `(${builtType.value})`}${inlineRefTypes.allOf ? ` & ${inlineRefTypes.allOf.join(" & ")}` : ""}${inlineRefTypes.oneOf ? ` & (${inlineRefTypes.oneOf.join(" | ")})` : ""}`.replace(/^ & /, "")
|
|
8896
8890
|
: `${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(builtType.value) ? "" : `(${builtType.value})`}${allOfRefTypes ? ` & ${allOfRefTypes.join(" & ")}` : ""}${oneOfRefTypes ? ` & (${oneOfRefTypes.join(" | ")})` : ""}`.replace(/^ & /, ""),
|
|
8897
8891
|
};
|
|
8898
8892
|
}
|
|
@@ -8947,12 +8941,9 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8947
8941
|
"longArray",
|
|
8948
8942
|
];
|
|
8949
8943
|
const primitiveUnion = primitiveListTypes.map((pt) => {
|
|
8950
|
-
const valType = pt === "long"
|
|
8951
|
-
? "[high: number, low: number]"
|
|
8952
|
-
|
|
8953
|
-
? "[high: number, low: number][]"
|
|
8954
|
-
: pt.endsWith("Array")
|
|
8955
|
-
? "number[]"
|
|
8944
|
+
const valType = pt === "long" ? "[high: number, low: number]"
|
|
8945
|
+
: pt === "longArray" ? "[high: number, low: number][]"
|
|
8946
|
+
: pt.endsWith("Array") ? "number[]"
|
|
8956
8947
|
: "number";
|
|
8957
8948
|
return { type: `"${pt}"`, value: `${valType}[]` };
|
|
8958
8949
|
});
|
|
@@ -8970,11 +8961,9 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8970
8961
|
if (Array.isArray(items)) {
|
|
8971
8962
|
const child = refToType(items, indent + " ", opts, ctx);
|
|
8972
8963
|
function builtTypeValueToTupleList(value) {
|
|
8973
|
-
return typeof value === "string"
|
|
8974
|
-
? value
|
|
8975
|
-
|
|
8976
|
-
? value.map(builtTypeValueToTupleList).join(", ")
|
|
8977
|
-
: builtTypeValueToTupleList(value.value);
|
|
8964
|
+
return (typeof value === "string" ? value
|
|
8965
|
+
: Array.isArray(value) ? value.map(builtTypeValueToTupleList).join(", ")
|
|
8966
|
+
: builtTypeValueToTupleList(value.value));
|
|
8978
8967
|
}
|
|
8979
8968
|
if (opts.allowExtraArrayItems) {
|
|
8980
8969
|
return {
|
|
@@ -8991,11 +8980,9 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
8991
8980
|
// TO-DO: Test this, as it may not work correctly.
|
|
8992
8981
|
const child = refToType(items, indent + " ", opts, ctx, { isListChild: true });
|
|
8993
8982
|
function builtTypeValueToUnionList(value) {
|
|
8994
|
-
return typeof value === "string"
|
|
8995
|
-
? value
|
|
8996
|
-
|
|
8997
|
-
? "(" + value.map(builtTypeValueToUnionList).join(" | ") + ")"
|
|
8998
|
-
: builtTypeValueToUnionList(value.value);
|
|
8983
|
+
return (typeof value === "string" ? value
|
|
8984
|
+
: Array.isArray(value) ? "(" + value.map(builtTypeValueToUnionList).join(" | ") + ")"
|
|
8985
|
+
: builtTypeValueToUnionList(value.value));
|
|
8999
8986
|
}
|
|
9000
8987
|
return { type: '"list"', value: `{ type: ${child.type}, value: ${builtTypeValueToUnionList(child.value)}[] }` };
|
|
9001
8988
|
}
|
|
@@ -9069,8 +9056,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9069
9056
|
lines.push(`${propLinesCount > 0 ? `${indent}} & {\n` : ""}${indent}[key: string]: ${builtType.value};`);
|
|
9070
9057
|
}
|
|
9071
9058
|
else {
|
|
9072
|
-
lines.push(`${propLinesCount > 0 ? `${indent}} & {\n` : ""}${indent}[key: string]: ${builtType.value.includes("\n")
|
|
9073
|
-
|
|
9059
|
+
lines.push(`${propLinesCount > 0 ? `${indent}} & {\n` : ""}${indent}[key: string]: ${builtType.value.includes("\n") ?
|
|
9060
|
+
`{\n${indent}type: ${builtType.type},\n${indent}value: ${builtType.value}\n${indent}}`
|
|
9074
9061
|
: `{ type: ${builtType.type}, value: ${builtType.value} }`};`);
|
|
9075
9062
|
}
|
|
9076
9063
|
}
|
|
@@ -9102,7 +9089,7 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9102
9089
|
!(refLookup[refLookup[ref]] === ref)) {
|
|
9103
9090
|
return resolveSchemaRefName(refLookup[ref], resolveSymbolName, opts);
|
|
9104
9091
|
}
|
|
9105
|
-
return resolveSymbolName ? opts.schemaIDToSymbolNameResolver?.(ref) ?? ref : ref;
|
|
9092
|
+
return resolveSymbolName ? (opts.schemaIDToSymbolNameResolver?.(ref) ?? ref) : ref;
|
|
9106
9093
|
}
|
|
9107
9094
|
// function resolveSchemaRefIsRenderedAsFragment(
|
|
9108
9095
|
// ref: string,
|
|
@@ -9151,19 +9138,16 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9151
9138
|
function schemaToType(schema, indent = "s".repeat(4), opts = {}, ctx = { helperTypes: [], helperCounter: 0 }) {
|
|
9152
9139
|
const refLookup = opts.refLookup ?? NBTSchemas.nbtSchemas;
|
|
9153
9140
|
const st = schema.type;
|
|
9154
|
-
const mainSchemaRefName = schema.$ref
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
const resolvedSchema = opts.inlineRefs && schema.$ref && mainSchemaRefName && mainSchemaRefName in refLookup
|
|
9158
|
-
? {
|
|
9141
|
+
const mainSchemaRefName = schema.$ref ? resolveSchemaRefName(schema.$ref, !(opts.inlineRefs ?? false), opts) : undefined;
|
|
9142
|
+
const resolvedSchema = opts.inlineRefs && schema.$ref && mainSchemaRefName && mainSchemaRefName in refLookup ?
|
|
9143
|
+
{
|
|
9159
9144
|
...refLookup[mainSchemaRefName],
|
|
9160
9145
|
...schema,
|
|
9161
9146
|
}
|
|
9162
9147
|
: schema;
|
|
9163
|
-
let allOfRefTypes = opts.inlineRefs ?? false
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
? [mainSchemaRefName]
|
|
9148
|
+
let allOfRefTypes = (opts.inlineRefs ?? false) ? undefined
|
|
9149
|
+
: typeof schema === "object" && schema.$ref !== undefined && mainSchemaRefName !== undefined /* && schema.$ref in refLookup */ ?
|
|
9150
|
+
[mainSchemaRefName]
|
|
9167
9151
|
: undefined;
|
|
9168
9152
|
if (!(opts.inlineRefs ?? false) && schema.allOf !== undefined) {
|
|
9169
9153
|
const refAllOfs = schema.allOf.filter((ref) => typeof ref === "object" && !!ref.$ref);
|
|
@@ -9194,8 +9178,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9194
9178
|
const types = refLookup[refType].type ?? resolvedSchema.type;
|
|
9195
9179
|
if (!types)
|
|
9196
9180
|
continue;
|
|
9197
|
-
inlineRefTypes.allOf.push(Array.isArray(types)
|
|
9198
|
-
|
|
9181
|
+
inlineRefTypes.allOf.push(Array.isArray(types) ?
|
|
9182
|
+
types
|
|
9199
9183
|
.map((t) => buildTypeForTag(t, refLookup[refType], indent, opts, ctx))
|
|
9200
9184
|
.join("|")
|
|
9201
9185
|
: buildTypeForTag(types, refLookup[refType], indent, opts, ctx));
|
|
@@ -9205,8 +9189,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9205
9189
|
const types = refLookup[refType].type ?? resolvedSchema.type;
|
|
9206
9190
|
if (!types)
|
|
9207
9191
|
continue;
|
|
9208
|
-
inlineRefTypes.oneOf.push(Array.isArray(types)
|
|
9209
|
-
|
|
9192
|
+
inlineRefTypes.oneOf.push(Array.isArray(types) ?
|
|
9193
|
+
types
|
|
9210
9194
|
.map((t) => buildTypeForTag(t, refLookup[refType], indent, opts, ctx))
|
|
9211
9195
|
.join("|")
|
|
9212
9196
|
: buildTypeForTag(types, refLookup[refType], indent, opts, ctx));
|
|
@@ -9215,8 +9199,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9215
9199
|
if (!st) {
|
|
9216
9200
|
if (resolvedSchema.properties) {
|
|
9217
9201
|
const compoundType = buildTypeForTag("compound", resolvedSchema, indent, opts, ctx);
|
|
9218
|
-
return opts.inlineRefs ?? false
|
|
9219
|
-
|
|
9202
|
+
return (opts.inlineRefs ?? false) ?
|
|
9203
|
+
`${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(compoundType) ? "" : `(${compoundType})`}${inlineRefTypes.allOf ? ` & ${inlineRefTypes.allOf.join(" & ")}` : ""}${inlineRefTypes.oneOf ? ` & (${inlineRefTypes.oneOf.join(" | ")})` : ""}`
|
|
9220
9204
|
: `${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(compoundType) ? "" : `(${compoundType})`}${allOfRefTypes ? ` & ${allOfRefTypes.join(" & ")}` : ""}${oneOfRefTypes ? ` & (${oneOfRefTypes.join(" | ")})` : ""}`.replace(/^ & /, "");
|
|
9221
9205
|
}
|
|
9222
9206
|
if (!(opts.inlineRefs ?? false) && schema.$ref) {
|
|
@@ -9227,8 +9211,8 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9227
9211
|
return `{ type: unknown, value: any }`;
|
|
9228
9212
|
}
|
|
9229
9213
|
const builtType = buildTypeForTag(st, resolvedSchema, indent, opts, ctx);
|
|
9230
|
-
return opts.inlineRefs ?? false
|
|
9231
|
-
|
|
9214
|
+
return (opts.inlineRefs ?? false) ?
|
|
9215
|
+
`${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(builtType) ? "" : `(${builtType})`}${inlineRefTypes.allOf ? ` & ${inlineRefTypes.allOf.join(" & ")}` : ""}${inlineRefTypes.oneOf ? ` & (${inlineRefTypes.oneOf.join(" | ")})` : ""}`.replace(/^ & /, "")
|
|
9232
9216
|
: `${(allOfRefTypes || oneOfRefTypes) && /^\{\s*\}$/.test(builtType) ? "" : `(${builtType})`}${allOfRefTypes ? ` & ${allOfRefTypes.join(" & ")}` : ""}${oneOfRefTypes ? ` & (${oneOfRefTypes.join(" | ")})` : ""}`.replace(/^ & /, "");
|
|
9233
9217
|
}
|
|
9234
9218
|
/**
|
|
@@ -9248,9 +9232,9 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9248
9232
|
throw new Error("Top-level schema must be a compound");
|
|
9249
9233
|
}
|
|
9250
9234
|
const ctx = { helperTypes: [], helperCounter: 0 };
|
|
9251
|
-
const header = renderComment(schema, opts.originalSymbolReference !== undefined
|
|
9252
|
-
|
|
9253
|
-
|
|
9235
|
+
const header = renderComment(schema, opts.originalSymbolReference !== undefined ?
|
|
9236
|
+
Array.isArray(opts.originalSymbolReference) ?
|
|
9237
|
+
opts.originalSymbolReference
|
|
9254
9238
|
: [opts.originalSymbolReference]
|
|
9255
9239
|
: undefined);
|
|
9256
9240
|
const indent = " ";
|
|
@@ -9504,11 +9488,11 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9504
9488
|
"longArray",
|
|
9505
9489
|
"end",
|
|
9506
9490
|
]);
|
|
9507
|
-
const t = tagTypeList.includes(node.type)
|
|
9508
|
-
|
|
9509
|
-
: tagTypeList.find((t) => t.toLowerCase() === node.type.toLowerCase()) ??
|
|
9491
|
+
const t = tagTypeList.includes(node.type) ?
|
|
9492
|
+
node.type
|
|
9493
|
+
: (tagTypeList.find((t) => t.toLowerCase() === node.type.toLowerCase()) ??
|
|
9510
9494
|
alternativeTagNameMapping[node.type.toLowerCase()] ??
|
|
9511
|
-
node.type;
|
|
9495
|
+
node.type);
|
|
9512
9496
|
if (primitiveTags.has(t)) {
|
|
9513
9497
|
const base = { type: t };
|
|
9514
9498
|
if (node.description)
|
|
@@ -9524,13 +9508,13 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9524
9508
|
}
|
|
9525
9509
|
else if (node.children.length === 1) {
|
|
9526
9510
|
out.items =
|
|
9527
|
-
node.children[0].type === "schemaRef"
|
|
9528
|
-
|
|
9511
|
+
node.children[0].type === "schemaRef" ?
|
|
9512
|
+
{ ...(node.children[0].description ? { description: node.children[0].description } : {}), $ref: node.children[0].$ref }
|
|
9529
9513
|
: nodeToNBTSchema(node.children[0], options);
|
|
9530
9514
|
}
|
|
9531
9515
|
else {
|
|
9532
|
-
out.items = node.children.map((c) => c.type === "schemaRef"
|
|
9533
|
-
|
|
9516
|
+
out.items = node.children.map((c) => c.type === "schemaRef" ?
|
|
9517
|
+
{ ...(c.description ? { description: c.description } : {}), $ref: c.$ref }
|
|
9534
9518
|
: nodeToNBTSchema(c, options));
|
|
9535
9519
|
}
|
|
9536
9520
|
return Utils.Misc.fixNBTSchemaPropertyOrder(out);
|
|
@@ -9540,11 +9524,11 @@ however when the corresponding block in the block layer is broken, this block ge
|
|
|
9540
9524
|
if (!node.description)
|
|
9541
9525
|
delete out.description; // Remove description if empty instead of adding if present to make it positioned before properties when JSON.stringified.
|
|
9542
9526
|
for (const child of node.children) {
|
|
9543
|
-
const type = tagTypeList.includes(child.type)
|
|
9544
|
-
|
|
9545
|
-
: tagTypeList.find((t) => t.toLowerCase() === child.type.toLowerCase()) ??
|
|
9527
|
+
const type = tagTypeList.includes(child.type) ?
|
|
9528
|
+
child.type
|
|
9529
|
+
: (tagTypeList.find((t) => t.toLowerCase() === child.type.toLowerCase()) ??
|
|
9546
9530
|
alternativeTagNameMapping[child.type.toLowerCase()] ??
|
|
9547
|
-
child.type;
|
|
9531
|
+
child.type);
|
|
9548
9532
|
if (child.$ref) {
|
|
9549
9533
|
out.allOf ??= [];
|
|
9550
9534
|
out.allOf.push({ $ref: child.$ref });
|