@sandstone-mc/mcdoc-ts-generator 0.1.10 → 0.1.12

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 CHANGED
@@ -740,19 +740,6 @@ class Bind {
740
740
  factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
741
741
  factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)
742
742
  ]);
743
- static DocPart(doc) {
744
- return doc.trim().replaceAll(`
745
-
746
-
747
-
748
- `, "@@bad@@").replaceAll(`
749
-
750
- `, `
751
- `).replaceAll("@@bad@@", `
752
-
753
- `).split(`
754
- `);
755
- }
756
743
  static Doc(node, docs) {
757
744
  let doc = "*";
758
745
  if (docs === undefined) {
@@ -761,7 +748,8 @@ class Bind {
761
748
  for (const _doc of docs) {
762
749
  if (Array.isArray(_doc)) {
763
750
  try {
764
- const sanitized = Bind.DocPart(_doc[0]);
751
+ const sanitized = _doc[0].trim().split(`
752
+ `);
765
753
  for (const __doc of sanitized) {
766
754
  if (__doc === "") {
767
755
  doc += `
@@ -1368,7 +1356,8 @@ function enum_docs(enum_type) {
1368
1356
  for (const member of enum_type.values) {
1369
1357
  const id_value = `${member.identifier}(\`${member.value}\`)`;
1370
1358
  if (member.desc) {
1371
- const member_doc = Bind.DocPart(member.desc);
1359
+ const member_doc = member.desc.trim().split(`
1360
+ `);
1372
1361
  if (member_doc.length > 1) {
1373
1362
  docs.push(` - ${id_value}:`);
1374
1363
  docs.push(...member_doc.map((doc) => ` ${doc}`));
@@ -1946,7 +1935,8 @@ function mcdoc_struct(type) {
1946
1935
  const id_attr = attr.value;
1947
1936
  let registry_id;
1948
1937
  if (id_attr === undefined) {
1949
- throw new Error(`[mcdoc_struct] #[id] on a struct key is currently not handled`);
1938
+ inherit.push(Bind.MappedType(Bind.NonEmptyString, value.type));
1939
+ return;
1950
1940
  }
1951
1941
  if (id_attr.kind === "literal") {
1952
1942
  registry_id = `minecraft:${id_attr.value.value}`;
@@ -2856,6 +2846,7 @@ var eslint = new ESLint({
2856
2846
  "@stylistic/eol-last": ["error", "always"],
2857
2847
  "@stylistic/no-trailing-spaces": "error",
2858
2848
  "@stylistic/no-multiple-empty-lines": ["error", { max: 1 }],
2849
+ "@stylistic/multiline-comment-style": ["error", "starred-block"],
2859
2850
  "@stylistic/padding-line-between-statements": [
2860
2851
  "error",
2861
2852
  { blankLine: "always", prev: "export", next: "export" },
package/dist/index.js CHANGED
@@ -738,19 +738,6 @@ class Bind {
738
738
  factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
739
739
  factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)
740
740
  ]);
741
- static DocPart(doc) {
742
- return doc.trim().replaceAll(`
743
-
744
-
745
-
746
- `, "@@bad@@").replaceAll(`
747
-
748
- `, `
749
- `).replaceAll("@@bad@@", `
750
-
751
- `).split(`
752
- `);
753
- }
754
741
  static Doc(node, docs) {
755
742
  let doc = "*";
756
743
  if (docs === undefined) {
@@ -759,7 +746,8 @@ class Bind {
759
746
  for (const _doc of docs) {
760
747
  if (Array.isArray(_doc)) {
761
748
  try {
762
- const sanitized = Bind.DocPart(_doc[0]);
749
+ const sanitized = _doc[0].trim().split(`
750
+ `);
763
751
  for (const __doc of sanitized) {
764
752
  if (__doc === "") {
765
753
  doc += `
@@ -1366,7 +1354,8 @@ function enum_docs(enum_type) {
1366
1354
  for (const member of enum_type.values) {
1367
1355
  const id_value = `${member.identifier}(\`${member.value}\`)`;
1368
1356
  if (member.desc) {
1369
- const member_doc = Bind.DocPart(member.desc);
1357
+ const member_doc = member.desc.trim().split(`
1358
+ `);
1370
1359
  if (member_doc.length > 1) {
1371
1360
  docs.push(` - ${id_value}:`);
1372
1361
  docs.push(...member_doc.map((doc) => ` ${doc}`));
@@ -1944,7 +1933,8 @@ function mcdoc_struct(type) {
1944
1933
  const id_attr = attr.value;
1945
1934
  let registry_id;
1946
1935
  if (id_attr === undefined) {
1947
- throw new Error(`[mcdoc_struct] #[id] on a struct key is currently not handled`);
1936
+ inherit.push(Bind.MappedType(Bind.NonEmptyString, value.type));
1937
+ return;
1948
1938
  }
1949
1939
  if (id_attr.kind === "literal") {
1950
1940
  registry_id = `minecraft:${id_attr.value.value}`;
@@ -2854,6 +2844,7 @@ var eslint = new ESLint({
2854
2844
  "@stylistic/eol-last": ["error", "always"],
2855
2845
  "@stylistic/no-trailing-spaces": "error",
2856
2846
  "@stylistic/no-multiple-empty-lines": ["error", { max: 1 }],
2847
+ "@stylistic/multiline-comment-style": ["error", "starred-block"],
2857
2848
  "@stylistic/padding-line-between-statements": [
2858
2849
  "error",
2859
2850
  { blankLine: "always", prev: "export", next: "export" },
@@ -52,7 +52,6 @@ export declare class Bind {
52
52
  * ```
53
53
  */
54
54
  static readonly EmptyObject: ts.TypeReferenceNode;
55
- static DocPart(doc: string): string[];
56
55
  /**
57
56
  * https://stackoverflow.com/questions/67575784/typescript-ast-factory-how-to-use-comments
58
57
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandstone-mc/mcdoc-ts-generator",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Generate TypeScript types from Minecraft mcdoc definitions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",