@spyglassmc/mcdoc 0.3.2 → 0.3.4

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.
@@ -17,9 +17,9 @@ export declare const string: InfallibleParser<StringNode>;
17
17
  export declare const identifier: InfallibleParser<IdentifierNode>;
18
18
  export declare const path: InfallibleParser<PathNode>;
19
19
  export declare const attribute: Parser<AttributeNode>;
20
- export declare const dispatchStatement: Parser<DispatchStatementNode>;
21
20
  export declare const docComment: Parser<CommentNode>;
22
21
  export declare const docComments: InfallibleParser<DocCommentsNode>;
22
+ export declare const dispatchStatement: Parser<DispatchStatementNode>;
23
23
  export declare const float: InfallibleParser<FloatNode>;
24
24
  export declare const typedNumber: InfallibleParser<TypedNumberNode>;
25
25
  export declare const enum_: Parser<EnumNode>;
@@ -328,9 +328,18 @@ const typeParamBlock = setType('mcdoc:type_param_block', syntax([
328
328
  ]),
329
329
  ]));
330
330
  const noop = () => undefined;
331
+ export const docComment = core.comment({
332
+ singleLinePrefixes: new Set(['///']),
333
+ includesEol: true,
334
+ });
335
+ export const docComments = setType('mcdoc:doc_comments', repeat(docComment, (src) => {
336
+ src.skipWhitespace();
337
+ return [];
338
+ }));
339
+ const prelim = syntax([optional(failOnEmpty(docComments)), attributes]);
331
340
  const optionalTypeParamBlock = select([{ prefix: '<', parser: typeParamBlock }, { parser: noop }]);
332
341
  export const dispatchStatement = setType('mcdoc:dispatch_statement', syntax([
333
- attributes,
342
+ prelim,
334
343
  keyword('dispatch'),
335
344
  resLoc({
336
345
  category: 'mcdoc/dispatcher',
@@ -341,15 +350,6 @@ export const dispatchStatement = setType('mcdoc:dispatch_statement', syntax([
341
350
  literal('to'),
342
351
  { get: () => type },
343
352
  ], true));
344
- export const docComment = core.comment({
345
- singleLinePrefixes: new Set(['///']),
346
- includesEol: true,
347
- });
348
- export const docComments = setType('mcdoc:doc_comments', repeat(docComment, (src) => {
349
- src.skipWhitespace();
350
- return [];
351
- }));
352
- const prelim = syntax([optional(failOnEmpty(docComments)), attributes]);
353
353
  const enumType = literal(['byte', 'short', 'int', 'long', 'string', 'float', 'double'], { colorTokenType: 'type' });
354
354
  export const float = core.float({
355
355
  pattern: /^[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)?|[0-9]*\.[0-9]+(?:[eE][-+]?[0-9]+)?)$/,
@@ -425,7 +425,12 @@ const structBlock = setType('mcdoc:struct/block', syntax([
425
425
  },
426
426
  ]),
427
427
  ], true));
428
- export const struct = setType('mcdoc:struct', syntax([prelim, keyword('struct'), optional(failOnEmpty(identifier)), structBlock], true));
428
+ export const struct = setType('mcdoc:struct', syntax([
429
+ prelim,
430
+ keyword('struct'),
431
+ optional(failOnEmpty(identifier)),
432
+ structBlock,
433
+ ], true));
429
434
  const enumInjection = setType('mcdoc:injection/enum', syntax([
430
435
  literal('enum'),
431
436
  punctuation('('),
@@ -490,7 +495,7 @@ function typeBase(type, parser) {
490
495
  syntaxRepeat(select([
491
496
  { prefix: '<', parser: typeArgBlock },
492
497
  { parser: failOnError(indexBody()) },
493
- ])),
498
+ ]), true),
494
499
  ], true));
495
500
  }
496
501
  export const anyType = typeBase('mcdoc:type/any', keyword('any', { colorTokenType: 'type' }));
@@ -561,13 +566,13 @@ export const numericType = typeBase('mcdoc:type/numeric_type', select([
561
566
  parser: syntax([
562
567
  keyword(NumericTypeFloatKinds, { colorTokenType: 'type' }),
563
568
  atFloatRange,
564
- ]),
569
+ ], true),
565
570
  },
566
571
  {
567
572
  parser: syntax([
568
573
  keyword(NumericTypeIntKinds, { colorTokenType: 'type' }),
569
574
  atIntRange,
570
- ]),
575
+ ], true),
571
576
  },
572
577
  ]));
573
578
  export const primitiveArrayType = typeBase('mcdoc:type/primitive_array', syntax([
@@ -4,20 +4,20 @@ export interface Attribute {
4
4
  name: string;
5
5
  value?: AttributeValue;
6
6
  }
7
- export declare type AttributeValue = McdocType | {
7
+ export type AttributeValue = McdocType | {
8
8
  kind: 'tree';
9
9
  values: AttributeTree;
10
10
  };
11
- export declare type AttributeTree = {
11
+ export type AttributeTree = {
12
12
  [key: string | number]: AttributeValue;
13
13
  };
14
- export declare type NumericRange = {
14
+ export type NumericRange = {
15
15
  kind: RangeKind;
16
16
  min?: number;
17
17
  max?: number;
18
18
  };
19
- export declare const StaticIndexKeywords: readonly ["fallback", "none", "unknown"];
20
- export declare type StaticIndexKeyword = typeof StaticIndexKeywords[number];
19
+ export declare const StaticIndexKeywords: readonly ["fallback", "none", "unknown", "spawnitem"];
20
+ export type StaticIndexKeyword = (typeof StaticIndexKeywords)[number];
21
21
  export interface StaticIndex {
22
22
  kind: 'static';
23
23
  value: string;
@@ -28,11 +28,11 @@ export interface DynamicIndex {
28
28
  keyword: 'key' | 'parent';
29
29
  })[];
30
30
  }
31
- export declare type Index = StaticIndex | DynamicIndex;
31
+ export type Index = StaticIndex | DynamicIndex;
32
32
  /**
33
33
  * Corresponds to the IndexBodyNode
34
34
  */
35
- export declare type ParallelIndices = Index[];
35
+ export type ParallelIndices = Index[];
36
36
  export interface DispatcherData {
37
37
  registry: FullResourceLocation;
38
38
  parallelIndices: ParallelIndices;
@@ -44,7 +44,7 @@ export interface StructType {
44
44
  kind: 'struct';
45
45
  fields: StructTypeField[];
46
46
  }
47
- export declare type StructTypeField = StructTypePairField | StructTypeSpreadField;
47
+ export type StructTypeField = StructTypePairField | StructTypeSpreadField;
48
48
  export interface StructTypePairField {
49
49
  kind: 'pair';
50
50
  attributes?: Attribute[];
@@ -106,7 +106,7 @@ export interface StringType {
106
106
  kind: 'string';
107
107
  lengthRange?: NumericRange;
108
108
  }
109
- export declare type LiteralValue = {
109
+ export type LiteralValue = {
110
110
  kind: 'boolean';
111
111
  value: boolean;
112
112
  } | {
@@ -122,28 +122,28 @@ export interface LiteralType {
122
122
  value: LiteralValue;
123
123
  }
124
124
  export declare const LiteralNumberSuffixes: readonly ["b", "s", "l", "f", "d"];
125
- export declare type LiteralNumberSuffix = typeof LiteralNumberSuffixes[number];
125
+ export type LiteralNumberSuffix = (typeof LiteralNumberSuffixes)[number];
126
126
  export declare const LiteralNumberCaseInsensitiveSuffixes: readonly ["b", "s", "l", "f", "d", "B", "S", "L", "F", "D"];
127
- export declare type LiteralNumberCaseInsensitiveSuffix = typeof LiteralNumberCaseInsensitiveSuffixes[number];
127
+ export type LiteralNumberCaseInsensitiveSuffix = (typeof LiteralNumberCaseInsensitiveSuffixes)[number];
128
128
  export interface NumericType {
129
129
  kind: NumericTypeKind;
130
130
  valueRange?: NumericRange;
131
131
  }
132
132
  export declare const NumericTypeIntKinds: readonly ["byte", "short", "int", "long"];
133
- export declare type NumericTypeIntKind = typeof NumericTypeIntKinds[number];
133
+ export type NumericTypeIntKind = (typeof NumericTypeIntKinds)[number];
134
134
  export declare const NumericTypeFloatKinds: readonly ["float", "double"];
135
- export declare type NumericTypeFloatKind = typeof NumericTypeFloatKinds[number];
135
+ export type NumericTypeFloatKind = (typeof NumericTypeFloatKinds)[number];
136
136
  export declare const NumericTypeKinds: readonly ["byte", "short", "int", "long", "float", "double"];
137
- export declare type NumericTypeKind = typeof NumericTypeKinds[number];
137
+ export type NumericTypeKind = (typeof NumericTypeKinds)[number];
138
138
  export interface PrimitiveArrayType {
139
139
  kind: 'byte_array' | 'int_array' | 'long_array';
140
140
  valueRange?: NumericRange;
141
141
  lengthRange?: NumericRange;
142
142
  }
143
143
  export declare const PrimitiveArrayValueKinds: readonly ["byte", "int", "long"];
144
- export declare type PrimitiveArrayValueKind = typeof PrimitiveArrayValueKinds[number];
144
+ export type PrimitiveArrayValueKind = (typeof PrimitiveArrayValueKinds)[number];
145
145
  export declare const PrimitiveArrayKinds: readonly ("byte_array" | "int_array" | "long_array")[];
146
- export declare type PrimitiveArrayKind = typeof PrimitiveArrayKinds[number];
146
+ export type PrimitiveArrayKind = (typeof PrimitiveArrayKinds)[number];
147
147
  export interface ListType {
148
148
  kind: 'list';
149
149
  item: McdocType;
@@ -153,27 +153,27 @@ export interface TupleType {
153
153
  kind: 'tuple';
154
154
  items: McdocType[];
155
155
  }
156
- export declare type McdocType = DispatcherType | EnumType | KeywordType | ListType | LiteralType | NumericType | PrimitiveArrayType | ReferenceType | StringType | StructType | TupleType | UnionType | AttributedType | IndexedType | TemplateType | ConcreteType;
156
+ export type McdocType = DispatcherType | EnumType | KeywordType | ListType | LiteralType | NumericType | PrimitiveArrayType | ReferenceType | StringType | StructType | TupleType | UnionType | AttributedType | IndexedType | TemplateType | ConcreteType;
157
157
  export declare namespace McdocType {
158
158
  function toString(type: McdocType | undefined): string;
159
159
  }
160
160
  /**
161
161
  * A type that doesn't include a dispatcher type.
162
162
  */
163
- export declare type DispatchedType = Exclude<McdocType, DispatcherType | UnionType> | UnionType<DispatchedType>;
163
+ export type DispatchedType = Exclude<McdocType, DispatcherType | UnionType> | UnionType<DispatchedType>;
164
164
  /**
165
165
  * A type that doesn't include a reference type.
166
166
  */
167
- export declare type DereferencedType = Exclude<McdocType, ReferenceType | UnionType> | UnionType<DereferencedType>;
167
+ export type DereferencedType = Exclude<McdocType, ReferenceType | UnionType> | UnionType<DereferencedType>;
168
168
  /**
169
169
  * A type that doesn't include a dispatcher type or a reference type.
170
170
  */
171
- export declare type TangibleType = Exclude<McdocType, DispatcherType | ReferenceType | UnionType> | UnionType<TangibleType>;
171
+ export type TangibleType = Exclude<McdocType, DispatcherType | ReferenceType | UnionType> | UnionType<TangibleType>;
172
172
  /**
173
173
  * A type that is {@link TangibleType} and doesn't have any indices.
174
174
  */
175
- export declare type ResolvedType = (Exclude<McdocType, DispatcherType | ReferenceType | UnionType> | UnionType<ResolvedType>) & NoIndices;
176
- declare type NoIndices = {
175
+ export type ResolvedType = (Exclude<McdocType, DispatcherType | ReferenceType | UnionType> | UnionType<ResolvedType>) & NoIndices;
176
+ type NoIndices = {
177
177
  indices?: undefined;
178
178
  };
179
179
  export interface FlatStructType {
package/lib/type/index.js CHANGED
@@ -5,6 +5,7 @@ export const StaticIndexKeywords = Object.freeze([
5
5
  'fallback',
6
6
  'none',
7
7
  'unknown',
8
+ 'spawnitem',
8
9
  ]);
9
10
  export const EmptyUnion = Object.freeze({
10
11
  kind: 'union',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/mcdoc",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "url": "https://github.com/SpyglassMC/Spyglass/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@spyglassmc/core": "0.4.1",
29
- "@spyglassmc/locales": "0.3.1"
28
+ "@spyglassmc/core": "0.4.3",
29
+ "@spyglassmc/locales": "0.3.3"
30
30
  }
31
31
  }