@spyglassmc/json 0.3.50 → 0.3.51
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/lib/checker/index.js +21 -17
- package/package.json +3 -3
package/lib/checker/index.js
CHANGED
|
@@ -10,23 +10,27 @@ export function register(meta) {
|
|
|
10
10
|
export function index(type, options) {
|
|
11
11
|
return (node, ctx) => {
|
|
12
12
|
mcdoc.runtime.checker.typeDefinition([{ originalNode: node, inferredType: inferType(node) }], type, mcdoc.runtime.checker.McdocCheckerContext.create(ctx, {
|
|
13
|
-
|
|
14
|
-
switch (
|
|
15
|
-
case '
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
tryConvertTo: (node, target) => {
|
|
14
|
+
switch (node.type) {
|
|
15
|
+
case 'json:array':
|
|
16
|
+
switch (target.kind) {
|
|
17
|
+
case 'list':
|
|
18
|
+
return { kind: 'list', item: { kind: 'any' } };
|
|
19
|
+
case 'byte_array':
|
|
20
|
+
case 'int_array':
|
|
21
|
+
case 'long_array':
|
|
22
|
+
return { kind: target.kind };
|
|
23
|
+
case 'tuple':
|
|
24
|
+
return { kind: 'tuple', items: [] };
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
case 'json:number':
|
|
28
|
+
const literalValue = mcdoc.LiteralNumericValue.makeIfValid(target.kind, node.value.value, true, true);
|
|
29
|
+
if (literalValue !== undefined) {
|
|
30
|
+
return { kind: 'literal', value: literalValue };
|
|
31
|
+
}
|
|
29
32
|
}
|
|
33
|
+
return undefined;
|
|
30
34
|
},
|
|
31
35
|
getChildren: node => {
|
|
32
36
|
if (node.type === 'json:array') {
|
|
@@ -46,7 +50,7 @@ export function index(type, options) {
|
|
|
46
50
|
if (err.kind === 'duplicate_key' && options?.discardDuplicateKeyErrors) {
|
|
47
51
|
return;
|
|
48
52
|
}
|
|
49
|
-
mcdoc.runtime.checker.getDefaultErrorReporter(ctx,
|
|
53
|
+
mcdoc.runtime.checker.getDefaultErrorReporter(ctx, mcdoc.runtime.checker.getDefaultErrorRange)(err);
|
|
50
54
|
},
|
|
51
55
|
attachTypeInfo: (node, definition, desc = '') => {
|
|
52
56
|
node.typeDef = definition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/json",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.51",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/SpyglassMC/Spyglass/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@spyglassmc/core": "0.4.
|
|
28
|
+
"@spyglassmc/core": "0.4.47",
|
|
29
29
|
"@spyglassmc/locales": "0.3.24",
|
|
30
|
-
"@spyglassmc/mcdoc": "0.3.
|
|
30
|
+
"@spyglassmc/mcdoc": "0.3.51"
|
|
31
31
|
}
|
|
32
32
|
}
|