@sandstone-mc/mcdoc-ts-generator 0.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.
Files changed (46) hide show
  1. package/README.md +15 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +3150 -0
  4. package/dist/index.d.ts +17 -0
  5. package/dist/index.js +3086 -0
  6. package/dist/typegen/compile.d.ts +2 -0
  7. package/dist/typegen/export.d.ts +39 -0
  8. package/dist/typegen/import.d.ts +6 -0
  9. package/dist/typegen/index.d.ts +38 -0
  10. package/dist/typegen/mcdoc/assert.d.ts +427 -0
  11. package/dist/typegen/mcdoc/bind.d.ts +61 -0
  12. package/dist/typegen/mcdoc/complex/dispatcher.d.ts +34 -0
  13. package/dist/typegen/mcdoc/complex/index.d.ts +3 -0
  14. package/dist/typegen/mcdoc/complex/indexed.d.ts +47 -0
  15. package/dist/typegen/mcdoc/complex/template.d.ts +54 -0
  16. package/dist/typegen/mcdoc/dispatcher_symbol.d.ts +58 -0
  17. package/dist/typegen/mcdoc/index.d.ts +425 -0
  18. package/dist/typegen/mcdoc/list/array/byte.d.ts +20 -0
  19. package/dist/typegen/mcdoc/list/array/index.d.ts +3 -0
  20. package/dist/typegen/mcdoc/list/array/int.d.ts +20 -0
  21. package/dist/typegen/mcdoc/list/array/long.d.ts +20 -0
  22. package/dist/typegen/mcdoc/list/index.d.ts +2 -0
  23. package/dist/typegen/mcdoc/list/list.d.ts +66 -0
  24. package/dist/typegen/mcdoc/multi/enum.d.ts +8 -0
  25. package/dist/typegen/mcdoc/multi/index.d.ts +4 -0
  26. package/dist/typegen/mcdoc/multi/struct.d.ts +31 -0
  27. package/dist/typegen/mcdoc/multi/tuple.d.ts +62 -0
  28. package/dist/typegen/mcdoc/multi/union.d.ts +62 -0
  29. package/dist/typegen/mcdoc/primitives/any.d.ts +7 -0
  30. package/dist/typegen/mcdoc/primitives/boolean.d.ts +7 -0
  31. package/dist/typegen/mcdoc/primitives/byte.d.ts +19 -0
  32. package/dist/typegen/mcdoc/primitives/concrete.d.ts +37 -0
  33. package/dist/typegen/mcdoc/primitives/double.d.ts +27 -0
  34. package/dist/typegen/mcdoc/primitives/float.d.ts +19 -0
  35. package/dist/typegen/mcdoc/primitives/index.d.ts +12 -0
  36. package/dist/typegen/mcdoc/primitives/int.d.ts +35 -0
  37. package/dist/typegen/mcdoc/primitives/literal.d.ts +14 -0
  38. package/dist/typegen/mcdoc/primitives/long.d.ts +19 -0
  39. package/dist/typegen/mcdoc/primitives/reference.d.ts +54 -0
  40. package/dist/typegen/mcdoc/primitives/short.d.ts +19 -0
  41. package/dist/typegen/mcdoc/primitives/string.d.ts +28 -0
  42. package/dist/typegen/mcdoc/utils.d.ts +20 -0
  43. package/dist/util/config.d.ts +1 -0
  44. package/dist/util/fetch.d.ts +18 -0
  45. package/dist/util/index.d.ts +22 -0
  46. package/package.json +58 -0
@@ -0,0 +1,31 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import { TypeHandlers, type NonEmptyList } from '..';
4
+ type ResolvedSpreadType = ReturnType<ReturnType<(typeof TypeHandlers[('reference' | 'dispatcher' | 'concrete' | 'template')])>>['type'];
5
+ type ResolvedIndexSignatureType = ts.ParenthesizedTypeNode | ts.TypeReferenceNode;
6
+ type StructIntersection = ResolvedSpreadType | ResolvedIndexSignatureType;
7
+ declare function mcdoc_struct(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
8
+ readonly type: ts.TypeLiteralNode | ts.TypeAliasDeclaration | StructIntersection;
9
+ } | {
10
+ readonly child_dispatcher: [parent_count: number, property: string][] & {
11
+ 0: [parent_count: number, property: string];
12
+ };
13
+ readonly type: ts.TypeLiteralNode | ts.TypeAliasDeclaration | StructIntersection;
14
+ } | {
15
+ readonly imports: {
16
+ readonly ordered: NonEmptyList<string>;
17
+ readonly check: Map<string, number>;
18
+ };
19
+ readonly type: ts.TypeLiteralNode | ts.TypeAliasDeclaration | StructIntersection;
20
+ } | {
21
+ readonly imports: {
22
+ readonly ordered: NonEmptyList<string>;
23
+ readonly check: Map<string, number>;
24
+ };
25
+ readonly child_dispatcher: [parent_count: number, property: string][] & {
26
+ 0: [parent_count: number, property: string];
27
+ };
28
+ readonly type: ts.TypeLiteralNode | ts.TypeAliasDeclaration | StructIntersection;
29
+ };
30
+ export declare const McdocStruct: typeof mcdoc_struct;
31
+ export {};
@@ -0,0 +1,62 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import { type NonEmptyList } from '..';
4
+ declare function mcdoc_tuple(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TupleTypeNode;
6
+ } | {
7
+ readonly child_dispatcher: [parent_count: number, property: string][] & {
8
+ 0: [parent_count: number, property: string];
9
+ };
10
+ readonly type: ts.TupleTypeNode;
11
+ } | {
12
+ readonly docs: (string | [string])[] & {
13
+ 0: string | [string];
14
+ };
15
+ readonly type: ts.TupleTypeNode;
16
+ } | {
17
+ readonly docs: (string | [string])[] & {
18
+ 0: string | [string];
19
+ };
20
+ readonly child_dispatcher: [parent_count: number, property: string][] & {
21
+ 0: [parent_count: number, property: string];
22
+ };
23
+ readonly type: ts.TupleTypeNode;
24
+ } | {
25
+ readonly imports: {
26
+ readonly ordered: NonEmptyList<string>;
27
+ readonly check: Map<string, number>;
28
+ };
29
+ readonly type: ts.TupleTypeNode;
30
+ } | {
31
+ readonly imports: {
32
+ readonly ordered: NonEmptyList<string>;
33
+ readonly check: Map<string, number>;
34
+ };
35
+ readonly child_dispatcher: [parent_count: number, property: string][] & {
36
+ 0: [parent_count: number, property: string];
37
+ };
38
+ readonly type: ts.TupleTypeNode;
39
+ } | {
40
+ readonly imports: {
41
+ readonly ordered: NonEmptyList<string>;
42
+ readonly check: Map<string, number>;
43
+ };
44
+ readonly docs: (string | [string])[] & {
45
+ 0: string | [string];
46
+ };
47
+ readonly type: ts.TupleTypeNode;
48
+ } | {
49
+ readonly imports: {
50
+ readonly ordered: NonEmptyList<string>;
51
+ readonly check: Map<string, number>;
52
+ };
53
+ readonly docs: (string | [string])[] & {
54
+ 0: string | [string];
55
+ };
56
+ readonly child_dispatcher: [parent_count: number, property: string][] & {
57
+ 0: [parent_count: number, property: string];
58
+ };
59
+ readonly type: ts.TupleTypeNode;
60
+ };
61
+ export declare const McdocTuple: typeof mcdoc_tuple;
62
+ export {};
@@ -0,0 +1,62 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import { type NonEmptyList } from '..';
4
+ declare function mcdoc_union(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeNode;
6
+ } | {
7
+ readonly child_dispatcher: [number, string][] & {
8
+ 0: [number, string];
9
+ };
10
+ readonly type: ts.TypeNode;
11
+ } | {
12
+ readonly docs: (string | [string])[] & {
13
+ 0: string | [string];
14
+ };
15
+ readonly type: ts.TypeNode;
16
+ } | {
17
+ readonly docs: (string | [string])[] & {
18
+ 0: string | [string];
19
+ };
20
+ readonly child_dispatcher: [number, string][] & {
21
+ 0: [number, string];
22
+ };
23
+ readonly type: ts.TypeNode;
24
+ } | {
25
+ readonly imports: {
26
+ readonly ordered: NonEmptyList<string>;
27
+ readonly check: Map<string, number>;
28
+ };
29
+ readonly type: ts.TypeNode;
30
+ } | {
31
+ readonly imports: {
32
+ readonly ordered: NonEmptyList<string>;
33
+ readonly check: Map<string, number>;
34
+ };
35
+ readonly child_dispatcher: [number, string][] & {
36
+ 0: [number, string];
37
+ };
38
+ readonly type: ts.TypeNode;
39
+ } | {
40
+ readonly imports: {
41
+ readonly ordered: NonEmptyList<string>;
42
+ readonly check: Map<string, number>;
43
+ };
44
+ readonly docs: (string | [string])[] & {
45
+ 0: string | [string];
46
+ };
47
+ readonly type: ts.TypeNode;
48
+ } | {
49
+ readonly imports: {
50
+ readonly ordered: NonEmptyList<string>;
51
+ readonly check: Map<string, number>;
52
+ };
53
+ readonly docs: (string | [string])[] & {
54
+ 0: string | [string];
55
+ };
56
+ readonly child_dispatcher: [number, string][] & {
57
+ 0: [number, string];
58
+ };
59
+ readonly type: ts.TypeNode;
60
+ };
61
+ export declare const McdocUnion: typeof mcdoc_union;
62
+ export {};
@@ -0,0 +1,7 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ declare function mcdoc_any(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
4
+ readonly type: ts.KeywordTypeNode<ts.SyntaxKind.UnknownKeyword>;
5
+ };
6
+ export declare const McdocAny: typeof mcdoc_any;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ declare function mcdoc_boolean(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
4
+ readonly type: ts.KeywordTypeNode<ts.SyntaxKind.BooleanKeyword>;
5
+ };
6
+ export declare const McdocBoolean: typeof mcdoc_boolean;
7
+ export {};
@@ -0,0 +1,19 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_byte(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeReferenceNode;
6
+ readonly docs: NonEmptyList<string>;
7
+ readonly imports: {
8
+ readonly ordered: NonEmptyList<string>;
9
+ readonly check: Map<string, number>;
10
+ };
11
+ } | {
12
+ readonly type: ts.TypeReferenceNode;
13
+ readonly imports: {
14
+ readonly ordered: NonEmptyList<string>;
15
+ readonly check: Map<string, number>;
16
+ };
17
+ };
18
+ export declare const McdocByte: typeof mcdoc_byte;
19
+ export {};
@@ -0,0 +1,37 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import { type NonEmptyList } from '..';
4
+ /**
5
+ * Handles `concrete` types which are type references with generic arguments.
6
+ *
7
+ * A concrete type has:
8
+ * - `child`: The base type being referenced (always a `reference` or `dispatcher` type)
9
+ * - `typeArgs`: The generic arguments being passed to the template
10
+ *
11
+ * Example: `SomeTemplate<boolean, string>` would have child=reference to SomeTemplate, typeArgs=[boolean, string]
12
+ */
13
+ declare function mcdoc_concrete(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
14
+ readonly type: ts.TypeNode | ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
15
+ } | {
16
+ readonly child_dispatcher: [number, string][] & {
17
+ 0: [number, string];
18
+ };
19
+ readonly type: ts.TypeNode | ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
20
+ } | {
21
+ readonly imports: {
22
+ readonly ordered: NonEmptyList<string>;
23
+ readonly check: Map<string, number>;
24
+ };
25
+ readonly type: ts.TypeNode | ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
26
+ } | {
27
+ readonly imports: {
28
+ readonly ordered: NonEmptyList<string>;
29
+ readonly check: Map<string, number>;
30
+ };
31
+ readonly child_dispatcher: [number, string][] & {
32
+ 0: [number, string];
33
+ };
34
+ readonly type: ts.TypeNode | ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
35
+ };
36
+ export declare const McdocConcrete: typeof mcdoc_concrete;
37
+ export {};
@@ -0,0 +1,27 @@
1
+ import * as mcdoc from '@spyglassmc/mcdoc';
2
+ import ts from 'typescript';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_double(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.ParenthesizedTypeNode;
6
+ readonly docs: NonEmptyList<string>;
7
+ readonly imports: {
8
+ readonly ordered: NonEmptyList<string>;
9
+ readonly check: Map<string, number>;
10
+ };
11
+ } | {
12
+ readonly type: ts.ParenthesizedTypeNode;
13
+ readonly imports: {
14
+ readonly ordered: NonEmptyList<string>;
15
+ readonly check: Map<string, number>;
16
+ };
17
+ };
18
+ export declare const McdocDouble: typeof mcdoc_double;
19
+ export declare function non_integral_generic<TYPE extends string, JS_NUMBER_ALLOWED extends (true | undefined)>(range: mcdoc.NumericRange, type: TYPE, allow_js_number?: JS_NUMBER_ALLOWED): {
20
+ readonly type: JS_NUMBER_ALLOWED extends true ? ts.ParenthesizedTypeNode : ts.TypeReferenceNode;
21
+ readonly docs: NonEmptyList<string>;
22
+ readonly imports: {
23
+ readonly ordered: NonEmptyList<string>;
24
+ readonly check: Map<string, number>;
25
+ };
26
+ };
27
+ export {};
@@ -0,0 +1,19 @@
1
+ import * as mcdoc from '@spyglassmc/mcdoc';
2
+ import ts from 'typescript';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_float(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
6
+ readonly docs: NonEmptyList<string>;
7
+ readonly imports: {
8
+ readonly ordered: NonEmptyList<string>;
9
+ readonly check: Map<string, number>;
10
+ };
11
+ } | {
12
+ readonly type: ts.TypeReferenceNode;
13
+ readonly imports: {
14
+ readonly ordered: NonEmptyList<string>;
15
+ readonly check: Map<string, number>;
16
+ };
17
+ };
18
+ export declare const McdocFloat: typeof mcdoc_float;
19
+ export {};
@@ -0,0 +1,12 @@
1
+ export { McdocAny } from './any';
2
+ export { McdocBoolean } from './boolean';
3
+ export { McdocByte } from './byte';
4
+ export { McdocConcrete } from './concrete';
5
+ export { McdocDouble } from './double';
6
+ export { McdocFloat } from './float';
7
+ export { McdocInt } from './int';
8
+ export { McdocLiteral } from './literal';
9
+ export { McdocLong } from './long';
10
+ export { McdocReference } from './reference';
11
+ export { McdocShort } from './short';
12
+ export { McdocString } from './string';
@@ -0,0 +1,35 @@
1
+ import * as mcdoc from '@spyglassmc/mcdoc';
2
+ import ts from 'typescript';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_int(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeReferenceNode;
6
+ readonly docs: NonEmptyList<string>;
7
+ readonly imports: {
8
+ readonly ordered: NonEmptyList<string>;
9
+ readonly check: Map<string, number>;
10
+ };
11
+ } | {
12
+ readonly type: ts.TypeReferenceNode;
13
+ readonly imports: {
14
+ readonly ordered: NonEmptyList<string>;
15
+ readonly check: Map<string, number>;
16
+ };
17
+ };
18
+ export declare const McdocInt: typeof mcdoc_int;
19
+ /**
20
+ *
21
+ */
22
+ export declare function whole_number_generic<TYPE extends string>(range: mcdoc.NumericRange, type: TYPE): {
23
+ readonly type: ts.TypeReferenceNode;
24
+ readonly docs: NonEmptyList<string>;
25
+ readonly imports: {
26
+ readonly ordered: NonEmptyList<string>;
27
+ readonly check: Map<string, number>;
28
+ };
29
+ };
30
+ /**
31
+ * Returns the number of valid values within the range.
32
+ * Lower value must actually be lower than the upper
33
+ */
34
+ export declare function integer_range_size(lower: number, upper: number): number;
35
+ export {};
@@ -0,0 +1,14 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_literal(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.LiteralTypeNode;
6
+ } | {
7
+ readonly type: ts.TypeReferenceNode;
8
+ readonly imports: {
9
+ readonly ordered: NonEmptyList<string>;
10
+ readonly check: Map<string, number>;
11
+ };
12
+ };
13
+ export declare const McdocLiteral: typeof mcdoc_literal;
14
+ export {};
@@ -0,0 +1,19 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_long(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeReferenceNode;
6
+ readonly docs: NonEmptyList<string>;
7
+ readonly imports: {
8
+ readonly ordered: NonEmptyList<string>;
9
+ readonly check: Map<string, number>;
10
+ };
11
+ } | {
12
+ readonly type: ts.TypeReferenceNode;
13
+ readonly imports: {
14
+ readonly ordered: NonEmptyList<string>;
15
+ readonly check: Map<string, number>;
16
+ };
17
+ };
18
+ export declare const McdocLong: typeof mcdoc_long;
19
+ export {};
@@ -0,0 +1,54 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_reference(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
6
+ } | {
7
+ readonly child_dispatcher: [[0, string]];
8
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
9
+ } | {
10
+ readonly docs: (string | [string])[] & {
11
+ 0: string | [string];
12
+ };
13
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
14
+ } | {
15
+ readonly docs: (string | [string])[] & {
16
+ 0: string | [string];
17
+ };
18
+ readonly child_dispatcher: [[0, string]];
19
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
20
+ } | {
21
+ readonly imports: {
22
+ readonly ordered: NonEmptyList<string>;
23
+ readonly check: Map<string, number>;
24
+ };
25
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
26
+ } | {
27
+ readonly imports: {
28
+ readonly ordered: NonEmptyList<string>;
29
+ readonly check: Map<string, number>;
30
+ };
31
+ readonly child_dispatcher: [[0, string]];
32
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
33
+ } | {
34
+ readonly imports: {
35
+ readonly ordered: NonEmptyList<string>;
36
+ readonly check: Map<string, number>;
37
+ };
38
+ readonly docs: (string | [string])[] & {
39
+ 0: string | [string];
40
+ };
41
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
42
+ } | {
43
+ readonly imports: {
44
+ readonly ordered: NonEmptyList<string>;
45
+ readonly check: Map<string, number>;
46
+ };
47
+ readonly docs: (string | [string])[] & {
48
+ 0: string | [string];
49
+ };
50
+ readonly child_dispatcher: [[0, string]];
51
+ readonly type: ts.TypeReferenceNode | ts.ParenthesizedTypeNode;
52
+ };
53
+ export declare const McdocReference: typeof mcdoc_reference;
54
+ export {};
@@ -0,0 +1,19 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import type { NonEmptyList } from '..';
4
+ declare function mcdoc_short(type: mcdoc.McdocType): (args: Record<string, unknown>) => {
5
+ readonly type: ts.TypeReferenceNode;
6
+ readonly docs: NonEmptyList<string>;
7
+ readonly imports: {
8
+ readonly ordered: NonEmptyList<string>;
9
+ readonly check: Map<string, number>;
10
+ };
11
+ } | {
12
+ readonly type: ts.TypeReferenceNode;
13
+ readonly imports: {
14
+ readonly ordered: NonEmptyList<string>;
15
+ readonly check: Map<string, number>;
16
+ };
17
+ };
18
+ export declare const McdocShort: typeof mcdoc_short;
19
+ export {};
@@ -0,0 +1,28 @@
1
+ import ts from 'typescript';
2
+ import * as mcdoc from '@spyglassmc/mcdoc';
3
+ import type { NonEmptyList } from '..';
4
+ /**
5
+ * This only handles strings as value types, not struct keys
6
+ */
7
+ declare function mcdoc_string(type: mcdoc.McdocType): ((args: Record<string, unknown>) => {
8
+ readonly type: ts.KeywordTypeNode<ts.SyntaxKind.StringKeyword>;
9
+ }) | ((args: Record<string, unknown>) => {
10
+ readonly type: ts.TemplateLiteralTypeNode;
11
+ }) | ((args: Record<string, unknown>) => {
12
+ readonly type: ts.TemplateLiteralTypeNode;
13
+ readonly docs: NonEmptyList<string>;
14
+ readonly imports?: never;
15
+ } | {
16
+ readonly type: ts.TypeNode;
17
+ readonly imports: {
18
+ ordered: NonEmptyList<string>;
19
+ check: Map<string, number>;
20
+ };
21
+ readonly docs?: never;
22
+ }) | ((args: Record<string, unknown>) => {
23
+ readonly type: ts.UnionTypeNode;
24
+ }) | ((args: Record<string, unknown>) => {
25
+ readonly type: ts.ParenthesizedTypeNode;
26
+ });
27
+ export declare const McdocString: typeof mcdoc_string;
28
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { SymbolUtil } from '@spyglassmc/core';
2
+ import type { TypeHandlerResult } from '.';
3
+ export type NonEmptyList<T> = T[] & {
4
+ 0: T;
5
+ };
6
+ /**
7
+ * Check if a registry has entries in the symbol table.
8
+ * @param symbols The symbol utility
9
+ * @param registry_id The registry ID with minecraft: prefix (e.g., 'minecraft:block')
10
+ * @returns true if the registry is non-empty
11
+ */
12
+ export declare function is_valid_registry(symbols: SymbolUtil | undefined, registry_id: string): boolean;
13
+ export declare function add_import(imports: TypeHandlerResult['imports'], add_import: string): NonNullable<TypeHandlerResult['imports']>;
14
+ export declare function merge_imports(imports: TypeHandlerResult['imports'], new_imports: NonNullable<TypeHandlerResult['imports']>): NonNullable<TypeHandlerResult['imports']>;
15
+ type GetConstructorArgs<T> = T extends new (...args: infer U) => any ? U : never;
16
+ export declare class Set<T> extends global.Set<T> {
17
+ constructor(...args: GetConstructorArgs<typeof global.Set<T>>);
18
+ has(value: unknown): boolean;
19
+ }
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A non-spec-compliant, non-complete implementation of the Cache Web API for use in Spyglass.
3
+ * This class stores the cached response on the file system under the cache root.
4
+ */
5
+ declare class HttpCache implements Cache {
6
+ #private;
7
+ constructor(cacheRoot: string | undefined);
8
+ match(request: RequestInfo | URL, _options?: CacheQueryOptions | undefined): Promise<Response | undefined>;
9
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
10
+ add(): Promise<void>;
11
+ addAll(): Promise<void>;
12
+ delete(): Promise<boolean>;
13
+ keys(): Promise<readonly Request[]>;
14
+ matchAll(): Promise<readonly Response[]>;
15
+ }
16
+ export declare const cache: HttpCache;
17
+ export declare function fetchWithCache(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
18
+ export {};
@@ -0,0 +1,22 @@
1
+ export declare function errorMessage(e: unknown): string;
2
+ export declare const join: (...paths: string[]) => string;
3
+ export declare function pascal_case(name: string): string;
4
+ export declare function camel_case(name: string): string;
5
+ export declare function pluralize(name: string): string;
6
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
7
+ type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => (infer R) ? R : never;
8
+ type Push<T extends any[], V> = [...T, V];
9
+ type UnionToTuple<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<UnionToTuple<Exclude<T, L>>, L>;
10
+ type PowerSet<T, Keys extends any[] = UnionToTuple<keyof T>> = Keys extends [infer Head, ...infer Rest] ? PowerSet<T, Rest> | (Head extends keyof T ? {
11
+ [K in Head]: NonNullable<T[K]>;
12
+ } & PowerSet<T, Rest> : never) : Record<string, never>;
13
+ type Prettify<T> = {
14
+ [K in keyof T]: T[K];
15
+ } & {};
16
+ /**
17
+ * Helper to add key-value pairs to an object if the values are not undefined.
18
+ *
19
+ * @returns An object with the key-value pairs if the values are not undefined, otherwise an empty object.
20
+ */
21
+ export declare function add<O extends Record<string, any>>(obj: O): Prettify<PowerSet<O>>;
22
+ export {};
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@sandstone-mc/mcdoc-ts-generator",
3
+ "version": "0.1.0",
4
+ "description": "Generate TypeScript types from Minecraft mcdoc definitions",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "mcdoc-ts-generator": "./dist/cli.js"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "compile": "bun run ./src/index.ts",
23
+ "build": "bun run build:bundle && bun run build:types",
24
+ "build:bundle": "bun build ./src/cli.ts --outfile ./dist/cli.js --target node --format esm --packages external && bun build ./src/index.ts --outfile ./dist/index.js --target node --format esm --packages external",
25
+ "build:types": "tsc --emitDeclarationOnly --declaration --outDir ./dist",
26
+ "prepublishOnly": "bun run build"
27
+ },
28
+ "keywords": [
29
+ "minecraft",
30
+ "mcdoc",
31
+ "typescript",
32
+ "types",
33
+ "generator",
34
+ "datapack",
35
+ "resourcepack"
36
+ ],
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/sandstone-mc/mcdoc-ts-generator"
41
+ },
42
+ "devDependencies": {
43
+ "@types/bun": "latest"
44
+ },
45
+ "peerDependencies": {
46
+ "typescript": "^5.0.0"
47
+ },
48
+ "dependencies": {
49
+ "@seahax/eslint-plugin-wrap": "^0.6.10",
50
+ "@spyglassmc/core": "^0.4.39",
51
+ "@spyglassmc/java-edition": "^0.3.51",
52
+ "@spyglassmc/mcdoc": "^0.3.43",
53
+ "@stylistic/eslint-plugin": "^5.6.1",
54
+ "@typescript-eslint/parser": "^8.49.0",
55
+ "eslint": "^9.39.2",
56
+ "ts-pattern": "^5.9.0"
57
+ }
58
+ }