@sandstone-mc/mcdoc-ts-generator 0.1.19 → 0.1.20
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/cli.js +49 -3
- package/dist/index.js +49 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -28,12 +28,18 @@ function pascal_case(name) {
|
|
|
28
28
|
return words.map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join("");
|
|
29
29
|
}
|
|
30
30
|
function pluralize(name) {
|
|
31
|
-
if (
|
|
31
|
+
if (/[aeiou]y$/i.test(name)) {
|
|
32
32
|
return `${name}s`;
|
|
33
|
-
|
|
33
|
+
}
|
|
34
|
+
if (name.endsWith("y")) {
|
|
34
35
|
return `${name.slice(0, -1)}ies`;
|
|
35
|
-
|
|
36
|
+
}
|
|
37
|
+
if (/[bdfgklmnprtvw]s$/i.test(name)) {
|
|
38
|
+
return name;
|
|
39
|
+
}
|
|
40
|
+
if (name.endsWith("s") || name.endsWith("ch") || name.endsWith("sh") || name.endsWith("x") || name.endsWith("z")) {
|
|
36
41
|
return `${name}es`;
|
|
42
|
+
}
|
|
37
43
|
return `${name}s`;
|
|
38
44
|
}
|
|
39
45
|
function add(obj) {
|
|
@@ -2689,6 +2695,46 @@ var SPECIAL_CASES = new Map([
|
|
|
2689
2695
|
imports
|
|
2690
2696
|
};
|
|
2691
2697
|
}],
|
|
2698
|
+
["::java::assets::item_definition::ComponentStrings", () => {
|
|
2699
|
+
let imports = undefined;
|
|
2700
|
+
imports = add_import(imports, "::java::dispatcher::SymbolDataComponent");
|
|
2701
|
+
imports = add_import(imports, "::java::assets::item_definition::SelectCases");
|
|
2702
|
+
imports = add_import(imports, "sandstone::arguments::nbt::RootNBT");
|
|
2703
|
+
const keyof_symbol = factory25.createTypeOperatorNode(ts25.SyntaxKind.KeyOfKeyword, factory25.createTypeReferenceNode("SymbolDataComponent"));
|
|
2704
|
+
const component_property = factory25.createPropertySignature(undefined, "component", undefined, factory25.createTypeReferenceNode("S"));
|
|
2705
|
+
const component_property_with_doc = Bind.Doc(component_property, [
|
|
2706
|
+
"The component type to check the values of.",
|
|
2707
|
+
"If the selected value comes from a registry that the client doesn't have access to,",
|
|
2708
|
+
"the entry will be silently ignored."
|
|
2709
|
+
]);
|
|
2710
|
+
const value_type = factory25.createParenthesizedType(factory25.createIntersectionTypeNode([
|
|
2711
|
+
factory25.createTypeLiteralNode([component_property_with_doc]),
|
|
2712
|
+
factory25.createTypeReferenceNode("SelectCases", [
|
|
2713
|
+
factory25.createIndexedAccessTypeNode(factory25.createTypeReferenceNode("SymbolDataComponent"), factory25.createTypeReferenceNode("S"))
|
|
2714
|
+
])
|
|
2715
|
+
]));
|
|
2716
|
+
const mapped_type = Bind.MappedType(keyof_symbol, value_type, { key_name: "S", parenthesized: false });
|
|
2717
|
+
const indexed_access = factory25.createIndexedAccessTypeNode(factory25.createParenthesizedType(mapped_type), keyof_symbol);
|
|
2718
|
+
const non_nullable = factory25.createTypeReferenceNode("NonNullable", [
|
|
2719
|
+
factory25.createParenthesizedType(indexed_access)
|
|
2720
|
+
]);
|
|
2721
|
+
const fallback_type = factory25.createParenthesizedType(factory25.createIntersectionTypeNode([
|
|
2722
|
+
factory25.createTypeReferenceNode("RootNBT"),
|
|
2723
|
+
factory25.createTypeLiteralNode([
|
|
2724
|
+
factory25.createPropertySignature(undefined, "component", undefined, factory25.createTemplateLiteralType(factory25.createTemplateHead(""), [
|
|
2725
|
+
factory25.createTemplateLiteralTypeSpan(factory25.createKeywordTypeNode(ts25.SyntaxKind.StringKeyword), factory25.createTemplateMiddle(":")),
|
|
2726
|
+
factory25.createTemplateLiteralTypeSpan(factory25.createKeywordTypeNode(ts25.SyntaxKind.StringKeyword), factory25.createTemplateTail(""))
|
|
2727
|
+
]))
|
|
2728
|
+
])
|
|
2729
|
+
]));
|
|
2730
|
+
return {
|
|
2731
|
+
type: factory25.createParenthesizedType(factory25.createUnionTypeNode([
|
|
2732
|
+
non_nullable,
|
|
2733
|
+
fallback_type
|
|
2734
|
+
])),
|
|
2735
|
+
imports
|
|
2736
|
+
};
|
|
2737
|
+
}],
|
|
2692
2738
|
["::java::util::text::Text", () => {
|
|
2693
2739
|
let imports = undefined;
|
|
2694
2740
|
imports = add_import(imports, "::java::util::text::TextObject");
|
package/dist/index.js
CHANGED
|
@@ -26,12 +26,18 @@ function pascal_case(name) {
|
|
|
26
26
|
return words.map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join("");
|
|
27
27
|
}
|
|
28
28
|
function pluralize(name) {
|
|
29
|
-
if (
|
|
29
|
+
if (/[aeiou]y$/i.test(name)) {
|
|
30
30
|
return `${name}s`;
|
|
31
|
-
|
|
31
|
+
}
|
|
32
|
+
if (name.endsWith("y")) {
|
|
32
33
|
return `${name.slice(0, -1)}ies`;
|
|
33
|
-
|
|
34
|
+
}
|
|
35
|
+
if (/[bdfgklmnprtvw]s$/i.test(name)) {
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
if (name.endsWith("s") || name.endsWith("ch") || name.endsWith("sh") || name.endsWith("x") || name.endsWith("z")) {
|
|
34
39
|
return `${name}es`;
|
|
40
|
+
}
|
|
35
41
|
return `${name}s`;
|
|
36
42
|
}
|
|
37
43
|
function add(obj) {
|
|
@@ -2687,6 +2693,46 @@ var SPECIAL_CASES = new Map([
|
|
|
2687
2693
|
imports
|
|
2688
2694
|
};
|
|
2689
2695
|
}],
|
|
2696
|
+
["::java::assets::item_definition::ComponentStrings", () => {
|
|
2697
|
+
let imports = undefined;
|
|
2698
|
+
imports = add_import(imports, "::java::dispatcher::SymbolDataComponent");
|
|
2699
|
+
imports = add_import(imports, "::java::assets::item_definition::SelectCases");
|
|
2700
|
+
imports = add_import(imports, "sandstone::arguments::nbt::RootNBT");
|
|
2701
|
+
const keyof_symbol = factory25.createTypeOperatorNode(ts25.SyntaxKind.KeyOfKeyword, factory25.createTypeReferenceNode("SymbolDataComponent"));
|
|
2702
|
+
const component_property = factory25.createPropertySignature(undefined, "component", undefined, factory25.createTypeReferenceNode("S"));
|
|
2703
|
+
const component_property_with_doc = Bind.Doc(component_property, [
|
|
2704
|
+
"The component type to check the values of.",
|
|
2705
|
+
"If the selected value comes from a registry that the client doesn't have access to,",
|
|
2706
|
+
"the entry will be silently ignored."
|
|
2707
|
+
]);
|
|
2708
|
+
const value_type = factory25.createParenthesizedType(factory25.createIntersectionTypeNode([
|
|
2709
|
+
factory25.createTypeLiteralNode([component_property_with_doc]),
|
|
2710
|
+
factory25.createTypeReferenceNode("SelectCases", [
|
|
2711
|
+
factory25.createIndexedAccessTypeNode(factory25.createTypeReferenceNode("SymbolDataComponent"), factory25.createTypeReferenceNode("S"))
|
|
2712
|
+
])
|
|
2713
|
+
]));
|
|
2714
|
+
const mapped_type = Bind.MappedType(keyof_symbol, value_type, { key_name: "S", parenthesized: false });
|
|
2715
|
+
const indexed_access = factory25.createIndexedAccessTypeNode(factory25.createParenthesizedType(mapped_type), keyof_symbol);
|
|
2716
|
+
const non_nullable = factory25.createTypeReferenceNode("NonNullable", [
|
|
2717
|
+
factory25.createParenthesizedType(indexed_access)
|
|
2718
|
+
]);
|
|
2719
|
+
const fallback_type = factory25.createParenthesizedType(factory25.createIntersectionTypeNode([
|
|
2720
|
+
factory25.createTypeReferenceNode("RootNBT"),
|
|
2721
|
+
factory25.createTypeLiteralNode([
|
|
2722
|
+
factory25.createPropertySignature(undefined, "component", undefined, factory25.createTemplateLiteralType(factory25.createTemplateHead(""), [
|
|
2723
|
+
factory25.createTemplateLiteralTypeSpan(factory25.createKeywordTypeNode(ts25.SyntaxKind.StringKeyword), factory25.createTemplateMiddle(":")),
|
|
2724
|
+
factory25.createTemplateLiteralTypeSpan(factory25.createKeywordTypeNode(ts25.SyntaxKind.StringKeyword), factory25.createTemplateTail(""))
|
|
2725
|
+
]))
|
|
2726
|
+
])
|
|
2727
|
+
]));
|
|
2728
|
+
return {
|
|
2729
|
+
type: factory25.createParenthesizedType(factory25.createUnionTypeNode([
|
|
2730
|
+
non_nullable,
|
|
2731
|
+
fallback_type
|
|
2732
|
+
])),
|
|
2733
|
+
imports
|
|
2734
|
+
};
|
|
2735
|
+
}],
|
|
2690
2736
|
["::java::util::text::Text", () => {
|
|
2691
2737
|
let imports = undefined;
|
|
2692
2738
|
imports = add_import(imports, "::java::util::text::TextObject");
|