@spyglassmc/json 0.1.0 → 0.2.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.
- package/lib/checker/JsonChecker.d.ts +1 -1
- package/lib/checker/JsonChecker.js +1 -2
- package/lib/checker/index.d.ts +2 -2
- package/lib/checker/index.js +2 -14
- package/lib/checker/primitives/boolean.d.ts +2 -2
- package/lib/checker/primitives/boolean.js +5 -9
- package/lib/checker/primitives/index.d.ts +6 -6
- package/lib/checker/primitives/index.js +6 -18
- package/lib/checker/primitives/list.d.ts +2 -2
- package/lib/checker/primitives/list.js +11 -16
- package/lib/checker/primitives/number.d.ts +1 -1
- package/lib/checker/primitives/number.js +11 -14
- package/lib/checker/primitives/object.d.ts +2 -2
- package/lib/checker/primitives/object.js +33 -47
- package/lib/checker/primitives/string.d.ts +3 -3
- package/lib/checker/primitives/string.js +15 -40
- package/lib/checker/primitives/util.d.ts +2 -2
- package/lib/checker/primitives/util.js +13 -21
- package/lib/colorizer/index.d.ts +1 -1
- package/lib/colorizer/index.js +12 -38
- package/lib/completer/index.d.ts +1 -1
- package/lib/completer/index.js +27 -53
- package/lib/formatter/index.d.ts +1 -1
- package/lib/formatter/index.js +5 -28
- package/lib/index.d.ts +6 -6
- package/lib/index.js +11 -37
- package/lib/node/JsonAstNode.js +25 -47
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +1 -13
- package/lib/parser/array.d.ts +1 -1
- package/lib/parser/array.js +4 -27
- package/lib/parser/boolean.d.ts +1 -1
- package/lib/parser/boolean.js +5 -28
- package/lib/parser/entry.d.ts +1 -1
- package/lib/parser/entry.js +15 -38
- package/lib/parser/index.d.ts +5 -5
- package/lib/parser/index.js +5 -17
- package/lib/parser/null.d.ts +1 -1
- package/lib/parser/null.js +4 -27
- package/lib/parser/number.d.ts +1 -1
- package/lib/parser/number.js +2 -25
- package/lib/parser/object.d.ts +1 -1
- package/lib/parser/object.js +5 -28
- package/lib/parser/string.d.ts +1 -1
- package/lib/parser/string.js +4 -27
- package/package.json +4 -3
- package/lib/util.d.ts +0 -1
- package/lib/util.js +0 -2
package/lib/colorizer/index.js
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { ColorToken } from '@spyglassmc/core';
|
|
3
|
+
export const boolean = node => {
|
|
4
|
+
return [ColorToken.create(node, 'literal')];
|
|
20
5
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const core_1 = require("@spyglassmc/core");
|
|
25
|
-
const boolean = node => {
|
|
26
|
-
return [core_1.ColorToken.create(node, 'literal')];
|
|
6
|
+
export const null_ = node => {
|
|
7
|
+
return [ColorToken.create(node, 'literal')];
|
|
27
8
|
};
|
|
28
|
-
|
|
29
|
-
const null_ = node => {
|
|
30
|
-
return [core_1.ColorToken.create(node, 'literal')];
|
|
31
|
-
};
|
|
32
|
-
exports.null_ = null_;
|
|
33
|
-
const object = (node, ctx) => {
|
|
9
|
+
export const object = (node, ctx) => {
|
|
34
10
|
const ans = [];
|
|
35
11
|
for (const pair of node.children) {
|
|
36
12
|
if (pair.key) {
|
|
37
|
-
ans.push(
|
|
13
|
+
ans.push(ColorToken.create(pair.key, 'property'));
|
|
38
14
|
}
|
|
39
15
|
if (pair.value) {
|
|
40
16
|
const colorizer = ctx.meta.getColorizer(pair.value.type);
|
|
@@ -43,13 +19,11 @@ const object = (node, ctx) => {
|
|
|
43
19
|
}
|
|
44
20
|
return ans;
|
|
45
21
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
meta.registerColorizer('json:
|
|
49
|
-
meta.registerColorizer('json:null', exports.null_);
|
|
22
|
+
export function register(meta) {
|
|
23
|
+
meta.registerColorizer('json:boolean', boolean);
|
|
24
|
+
meta.registerColorizer('json:null', null_);
|
|
50
25
|
meta.registerColorizer('json:number', core.colorizer.number);
|
|
51
|
-
meta.registerColorizer('json:object',
|
|
26
|
+
meta.registerColorizer('json:object', object);
|
|
52
27
|
meta.registerColorizer('json:string', core.colorizer.string);
|
|
53
28
|
}
|
|
54
|
-
exports.register = register;
|
|
55
29
|
//# sourceMappingURL=index.js.map
|
package/lib/completer/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Completer, MetaRegistry } from '@spyglassmc/core';
|
|
2
|
-
import type { JsonArrayNode, JsonBooleanNode, JsonNode, JsonObjectNode } from '../node';
|
|
2
|
+
import type { JsonArrayNode, JsonBooleanNode, JsonNode, JsonObjectNode } from '../node/index.js';
|
|
3
3
|
export declare const JsonTriggerCharacters: string[];
|
|
4
4
|
export declare const entry: Completer<JsonNode>;
|
|
5
5
|
export declare const object: Completer<JsonObjectNode>;
|
package/lib/completer/index.js
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.register = exports.boolean = exports.array = exports.object = exports.entry = exports.JsonTriggerCharacters = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const core_1 = require("@spyglassmc/core");
|
|
25
|
-
const node_1 = require("../node");
|
|
26
|
-
exports.JsonTriggerCharacters = ['\n', ':', '"'];
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { CompletionItem, Range } from '@spyglassmc/core';
|
|
3
|
+
import { JsonExpectation } from '../node/index.js';
|
|
4
|
+
export const JsonTriggerCharacters = ['\n', ':', '"'];
|
|
27
5
|
const SIMPLE_SNIPPETS = {
|
|
28
6
|
'json:object': '{$1}',
|
|
29
7
|
'json:array': '[$1]',
|
|
@@ -31,24 +9,23 @@ const SIMPLE_SNIPPETS = {
|
|
|
31
9
|
'json:boolean': '${1|false,true|}',
|
|
32
10
|
'json:number': '${1:0}',
|
|
33
11
|
};
|
|
34
|
-
const entry = (node, ctx) => {
|
|
12
|
+
export const entry = (node, ctx) => {
|
|
35
13
|
return core.completer.dispatch(node, ctx);
|
|
36
14
|
};
|
|
37
|
-
|
|
38
|
-
exports.object = core.completer.record({
|
|
15
|
+
export const object = core.completer.record({
|
|
39
16
|
key: (record, pair, ctx, range, insertValue, insertComma) => {
|
|
40
17
|
if (record.expectation) {
|
|
41
|
-
return unique(record.expectation.filter(
|
|
18
|
+
return unique(record.expectation.filter(JsonExpectation.isObject)
|
|
42
19
|
.flatMap(e => objectCompletion(range, record, e, ctx, insertValue, insertComma, pair?.key?.value)));
|
|
43
20
|
}
|
|
44
21
|
return [];
|
|
45
22
|
},
|
|
46
23
|
value: (record, pair, ctx) => {
|
|
47
|
-
if (pair.value && !
|
|
24
|
+
if (pair.value && !Range.isEmpty(pair.value)) {
|
|
48
25
|
return core.completer.dispatch(pair.value, ctx);
|
|
49
26
|
}
|
|
50
27
|
if (record.expectation) {
|
|
51
|
-
return unique(record.expectation.filter(
|
|
28
|
+
return unique(record.expectation.filter(JsonExpectation.isObject)
|
|
52
29
|
.filter(e => e.fields)
|
|
53
30
|
.map(e => e.fields.find(f => f.key === pair.key?.value))
|
|
54
31
|
.flatMap(f => valueCompletion(ctx.offset, f.value, ctx)));
|
|
@@ -56,32 +33,30 @@ exports.object = core.completer.record({
|
|
|
56
33
|
return [];
|
|
57
34
|
},
|
|
58
35
|
});
|
|
59
|
-
const array = (node, ctx) => {
|
|
36
|
+
export const array = (node, ctx) => {
|
|
60
37
|
const index = core.binarySearch(node.children, ctx.offset, (n, o) => n.sep
|
|
61
|
-
?
|
|
62
|
-
:
|
|
38
|
+
? Range.compareOffset(Range.translate(n, 0, -1), o, true)
|
|
39
|
+
: Range.compareOffset(n.range, o, true));
|
|
63
40
|
const item = index >= 0 ? node.children[index] : undefined;
|
|
64
41
|
if (item?.value) {
|
|
65
42
|
return core.completer.dispatch(item.value, ctx);
|
|
66
43
|
}
|
|
67
|
-
if (node.expectation &&
|
|
68
|
-
return unique(node.expectation.filter(
|
|
44
|
+
if (node.expectation && Range.contains(Range.translate(node, 1, -1), ctx.offset, true)) {
|
|
45
|
+
return unique(node.expectation.filter(JsonExpectation.isArray)
|
|
69
46
|
.filter(e => e.items)
|
|
70
47
|
.flatMap(e => valueCompletion(ctx.offset, e.items, ctx)));
|
|
71
48
|
}
|
|
72
49
|
return [];
|
|
73
50
|
};
|
|
74
|
-
|
|
75
|
-
const boolean = (node) => {
|
|
51
|
+
export const boolean = (node) => {
|
|
76
52
|
return ['false', 'true'].map(v => simpleCompletion(node, v));
|
|
77
53
|
};
|
|
78
|
-
exports.boolean = boolean;
|
|
79
54
|
const string = (node, ctx) => {
|
|
80
55
|
if (node.children?.length) {
|
|
81
56
|
return core.completer.string(node, ctx);
|
|
82
57
|
}
|
|
83
58
|
if (node.expectation) {
|
|
84
|
-
return unique(node.expectation.filter(
|
|
59
|
+
return unique(node.expectation.filter(JsonExpectation.isString)
|
|
85
60
|
.flatMap(e => stringCompletion(node, e, ctx)));
|
|
86
61
|
}
|
|
87
62
|
return [];
|
|
@@ -103,8 +78,8 @@ function objectCompletion(range, node, expectation, ctx, insertValue, insertComm
|
|
|
103
78
|
}
|
|
104
79
|
function fieldCompletion(range, field, insertValue, insertComma) {
|
|
105
80
|
const value = field.value?.[0] ? SIMPLE_SNIPPETS[field.value[0].type] : '';
|
|
106
|
-
return
|
|
107
|
-
kind: 10 /* Property */,
|
|
81
|
+
return CompletionItem.create(field.key, range, {
|
|
82
|
+
kind: 10 /* CompletionKind.Property */,
|
|
108
83
|
detail: field.value?.map(e => e.typedoc).join(' | '),
|
|
109
84
|
sortText: `${field.deprecated ? 2 : field.opt ? 1 : 0}${field.key}`,
|
|
110
85
|
deprecated: field.deprecated,
|
|
@@ -129,8 +104,8 @@ function valueCompletion(range, expectation, ctx) {
|
|
|
129
104
|
}
|
|
130
105
|
function stringCompletion(range, expectation, ctx) {
|
|
131
106
|
if (Array.isArray(expectation.pool)) {
|
|
132
|
-
return expectation.pool.map(v =>
|
|
133
|
-
kind: 12 /* Value */,
|
|
107
|
+
return expectation.pool.map(v => CompletionItem.create(v, range, {
|
|
108
|
+
kind: 12 /* CompletionKind.Value */,
|
|
134
109
|
filterText: `"${v}"`,
|
|
135
110
|
insertText: `"${v}"`,
|
|
136
111
|
}));
|
|
@@ -138,8 +113,8 @@ function stringCompletion(range, expectation, ctx) {
|
|
|
138
113
|
return [simpleCompletion(range, SIMPLE_SNIPPETS[expectation.type])];
|
|
139
114
|
}
|
|
140
115
|
function simpleCompletion(range, value) {
|
|
141
|
-
return
|
|
142
|
-
kind: 12 /* Value */,
|
|
116
|
+
return CompletionItem.create(value.replace('$1', ''), range, {
|
|
117
|
+
kind: 12 /* CompletionKind.Value */,
|
|
143
118
|
insertText: value,
|
|
144
119
|
});
|
|
145
120
|
}
|
|
@@ -154,12 +129,11 @@ function unique(completions) {
|
|
|
154
129
|
});
|
|
155
130
|
return ans;
|
|
156
131
|
}
|
|
157
|
-
function register(meta) {
|
|
158
|
-
meta.registerCompleter('json:entry',
|
|
159
|
-
meta.registerCompleter('json:array',
|
|
160
|
-
meta.registerCompleter('json:boolean',
|
|
161
|
-
meta.registerCompleter('json:object',
|
|
132
|
+
export function register(meta) {
|
|
133
|
+
meta.registerCompleter('json:entry', entry);
|
|
134
|
+
meta.registerCompleter('json:array', array);
|
|
135
|
+
meta.registerCompleter('json:boolean', boolean);
|
|
136
|
+
meta.registerCompleter('json:object', object);
|
|
162
137
|
meta.registerCompleter('json:string', string);
|
|
163
138
|
}
|
|
164
|
-
exports.register = register;
|
|
165
139
|
//# sourceMappingURL=index.js.map
|
package/lib/formatter/index.d.ts
CHANGED
package/lib/formatter/index.js
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.register = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const lib_1 = require("../../../core/lib");
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { indentFormatter } from '@spyglassmc/core';
|
|
25
3
|
const array = (node, ctx) => {
|
|
26
4
|
if (node.children.length === 0)
|
|
27
5
|
return '[]';
|
|
28
6
|
const values = node.children.map(child => {
|
|
29
|
-
const value = child.value && ctx.meta.getFormatter(child.value.type)(child.value,
|
|
7
|
+
const value = child.value && ctx.meta.getFormatter(child.value.type)(child.value, indentFormatter(ctx));
|
|
30
8
|
return `${ctx.indent(1)}${value ?? ''}`;
|
|
31
9
|
});
|
|
32
10
|
return `[\n${values.join(',\n')}\n${ctx.indent()}]`;
|
|
@@ -36,12 +14,12 @@ const object = (node, ctx) => {
|
|
|
36
14
|
return '{}';
|
|
37
15
|
const fields = node.children.map(child => {
|
|
38
16
|
const key = child.key && core.formatter.string(child.key, ctx);
|
|
39
|
-
const value = child.value && ctx.meta.getFormatter(child.value.type)(child.value,
|
|
17
|
+
const value = child.value && ctx.meta.getFormatter(child.value.type)(child.value, indentFormatter(ctx));
|
|
40
18
|
return `${ctx.indent(1)}${key ?? ''}: ${value ?? ''}`;
|
|
41
19
|
});
|
|
42
20
|
return `{\n${fields.join(',\n')}\n${ctx.indent()}}`;
|
|
43
21
|
};
|
|
44
|
-
function register(meta) {
|
|
22
|
+
export function register(meta) {
|
|
45
23
|
meta.registerFormatter('json:array', array);
|
|
46
24
|
meta.registerFormatter('json:boolean', core.formatter.boolean);
|
|
47
25
|
meta.registerFormatter('json:null', () => 'null');
|
|
@@ -49,5 +27,4 @@ function register(meta) {
|
|
|
49
27
|
meta.registerFormatter('json:object', object);
|
|
50
28
|
meta.registerFormatter('json:string', core.formatter.string);
|
|
51
29
|
}
|
|
52
|
-
exports.register = register;
|
|
53
30
|
//# sourceMappingURL=index.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as core from '@spyglassmc/core';
|
|
2
|
-
export * as checker from './checker';
|
|
3
|
-
export * as colorizer from './colorizer';
|
|
4
|
-
export * as completer from './completer';
|
|
5
|
-
export * as formatter from './formatter';
|
|
6
|
-
export * from './node';
|
|
7
|
-
export * as parser from './parser';
|
|
2
|
+
export * as checker from './checker/index.js';
|
|
3
|
+
export * as colorizer from './colorizer/index.js';
|
|
4
|
+
export * as completer from './completer/index.js';
|
|
5
|
+
export * as formatter from './formatter/index.js';
|
|
6
|
+
export * from './node/index.js';
|
|
7
|
+
export * as parser from './parser/index.js';
|
|
8
8
|
export declare const initialize: core.ProjectInitializer;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,40 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
16
|
-
if (mod && mod.__esModule) return mod;
|
|
17
|
-
var result = {};
|
|
18
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
19
|
-
__setModuleDefault(result, mod);
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.initialize = exports.parser = exports.formatter = exports.completer = exports.colorizer = exports.checker = void 0;
|
|
27
|
-
const colorizer = __importStar(require("./colorizer"));
|
|
28
|
-
const completer = __importStar(require("./completer"));
|
|
29
|
-
const formatter = __importStar(require("./formatter"));
|
|
30
|
-
const parser = __importStar(require("./parser"));
|
|
31
|
-
exports.checker = __importStar(require("./checker"));
|
|
32
|
-
exports.colorizer = __importStar(require("./colorizer"));
|
|
33
|
-
exports.completer = __importStar(require("./completer"));
|
|
34
|
-
exports.formatter = __importStar(require("./formatter"));
|
|
35
|
-
__exportStar(require("./node"), exports);
|
|
36
|
-
exports.parser = __importStar(require("./parser"));
|
|
37
|
-
const initialize = ({ meta }) => {
|
|
2
|
+
import * as colorizer from './colorizer/index.js';
|
|
3
|
+
import * as completer from './completer/index.js';
|
|
4
|
+
import * as formatter from './formatter/index.js';
|
|
5
|
+
import * as parser from './parser/index.js';
|
|
6
|
+
export * as checker from './checker/index.js';
|
|
7
|
+
export * as colorizer from './colorizer/index.js';
|
|
8
|
+
export * as completer from './completer/index.js';
|
|
9
|
+
export * as formatter from './formatter/index.js';
|
|
10
|
+
export * from './node/index.js';
|
|
11
|
+
export * as parser from './parser/index.js';
|
|
12
|
+
export const initialize = ({ meta }) => {
|
|
38
13
|
meta.registerLanguage('json', {
|
|
39
14
|
extensions: ['.json', '.mcmeta'],
|
|
40
15
|
triggerCharacters: completer.JsonTriggerCharacters,
|
|
@@ -45,5 +20,4 @@ const initialize = ({ meta }) => {
|
|
|
45
20
|
completer.register(meta);
|
|
46
21
|
formatter.register(meta);
|
|
47
22
|
};
|
|
48
|
-
exports.initialize = initialize;
|
|
49
23
|
//# sourceMappingURL=index.js.map
|
package/lib/node/JsonAstNode.js
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.JsonNullNode = exports.JsonBooleanNode = exports.JsonNumberNode = exports.JsonStringNode = exports.JsonStringExpectation = exports.JsonItemNode = exports.JsonArrayNode = exports.JsonPairNode = exports.JsonObjectNode = exports.JsonExpectation = exports.JsonNode = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const parser_1 = require("../parser");
|
|
25
|
-
var JsonNode;
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { JsonStringOptions } from '../parser/index.js';
|
|
3
|
+
export var JsonNode;
|
|
26
4
|
(function (JsonNode) {
|
|
27
5
|
function is(node) {
|
|
28
6
|
return (JsonObjectNode.is(node) ||
|
|
@@ -39,8 +17,8 @@ var JsonNode;
|
|
|
39
17
|
JsonItemNode.is(node));
|
|
40
18
|
}
|
|
41
19
|
JsonNode.isRelated = isRelated;
|
|
42
|
-
})(JsonNode
|
|
43
|
-
var JsonExpectation;
|
|
20
|
+
})(JsonNode || (JsonNode = {}));
|
|
21
|
+
export var JsonExpectation;
|
|
44
22
|
(function (JsonExpectation) {
|
|
45
23
|
function isArray(e) {
|
|
46
24
|
return e.type === 'json:array';
|
|
@@ -54,8 +32,8 @@ var JsonExpectation;
|
|
|
54
32
|
return e.type === 'json:string';
|
|
55
33
|
}
|
|
56
34
|
JsonExpectation.isString = isString;
|
|
57
|
-
})(JsonExpectation
|
|
58
|
-
var JsonObjectNode;
|
|
35
|
+
})(JsonExpectation || (JsonExpectation = {}));
|
|
36
|
+
export var JsonObjectNode;
|
|
59
37
|
(function (JsonObjectNode) {
|
|
60
38
|
/* istanbul ignore next */
|
|
61
39
|
function is(obj) {
|
|
@@ -70,16 +48,16 @@ var JsonObjectNode;
|
|
|
70
48
|
};
|
|
71
49
|
}
|
|
72
50
|
JsonObjectNode.mock = mock;
|
|
73
|
-
})(JsonObjectNode
|
|
74
|
-
var JsonPairNode;
|
|
51
|
+
})(JsonObjectNode || (JsonObjectNode = {}));
|
|
52
|
+
export var JsonPairNode;
|
|
75
53
|
(function (JsonPairNode) {
|
|
76
54
|
/* istanbul ignore next */
|
|
77
55
|
function is(obj) {
|
|
78
56
|
return obj.type === 'pair';
|
|
79
57
|
}
|
|
80
58
|
JsonPairNode.is = is;
|
|
81
|
-
})(JsonPairNode
|
|
82
|
-
var JsonArrayNode;
|
|
59
|
+
})(JsonPairNode || (JsonPairNode = {}));
|
|
60
|
+
export var JsonArrayNode;
|
|
83
61
|
(function (JsonArrayNode) {
|
|
84
62
|
function is(obj) {
|
|
85
63
|
return obj?.type === 'json:array';
|
|
@@ -93,24 +71,24 @@ var JsonArrayNode;
|
|
|
93
71
|
};
|
|
94
72
|
}
|
|
95
73
|
JsonArrayNode.mock = mock;
|
|
96
|
-
})(JsonArrayNode
|
|
97
|
-
var JsonItemNode;
|
|
74
|
+
})(JsonArrayNode || (JsonArrayNode = {}));
|
|
75
|
+
export var JsonItemNode;
|
|
98
76
|
(function (JsonItemNode) {
|
|
99
77
|
/* istanbul ignore next */
|
|
100
78
|
function is(obj) {
|
|
101
79
|
return obj.type === 'item';
|
|
102
80
|
}
|
|
103
81
|
JsonItemNode.is = is;
|
|
104
|
-
})(JsonItemNode
|
|
105
|
-
var JsonStringExpectation;
|
|
82
|
+
})(JsonItemNode || (JsonItemNode = {}));
|
|
83
|
+
export var JsonStringExpectation;
|
|
106
84
|
(function (JsonStringExpectation) {
|
|
107
85
|
/* istanbul ignore next */
|
|
108
86
|
function is(obj) {
|
|
109
87
|
return obj.type === 'json:string';
|
|
110
88
|
}
|
|
111
89
|
JsonStringExpectation.is = is;
|
|
112
|
-
})(JsonStringExpectation
|
|
113
|
-
var JsonStringNode;
|
|
90
|
+
})(JsonStringExpectation || (JsonStringExpectation = {}));
|
|
91
|
+
export var JsonStringNode;
|
|
114
92
|
(function (JsonStringNode) {
|
|
115
93
|
/* istanbul ignore next */
|
|
116
94
|
function is(obj) {
|
|
@@ -119,34 +97,34 @@ var JsonStringNode;
|
|
|
119
97
|
JsonStringNode.is = is;
|
|
120
98
|
function mock(range) {
|
|
121
99
|
return {
|
|
122
|
-
...core.StringNode.mock(range,
|
|
100
|
+
...core.StringNode.mock(range, JsonStringOptions),
|
|
123
101
|
type: 'json:string',
|
|
124
102
|
};
|
|
125
103
|
}
|
|
126
104
|
JsonStringNode.mock = mock;
|
|
127
|
-
})(JsonStringNode
|
|
128
|
-
var JsonNumberNode;
|
|
105
|
+
})(JsonStringNode || (JsonStringNode = {}));
|
|
106
|
+
export var JsonNumberNode;
|
|
129
107
|
(function (JsonNumberNode) {
|
|
130
108
|
/* istanbul ignore next */
|
|
131
109
|
function is(obj) {
|
|
132
110
|
return obj.type === 'json:number';
|
|
133
111
|
}
|
|
134
112
|
JsonNumberNode.is = is;
|
|
135
|
-
})(JsonNumberNode
|
|
136
|
-
var JsonBooleanNode;
|
|
113
|
+
})(JsonNumberNode || (JsonNumberNode = {}));
|
|
114
|
+
export var JsonBooleanNode;
|
|
137
115
|
(function (JsonBooleanNode) {
|
|
138
116
|
/* istanbul ignore next */
|
|
139
117
|
function is(obj) {
|
|
140
118
|
return obj.type === 'json:boolean';
|
|
141
119
|
}
|
|
142
120
|
JsonBooleanNode.is = is;
|
|
143
|
-
})(JsonBooleanNode
|
|
144
|
-
var JsonNullNode;
|
|
121
|
+
})(JsonBooleanNode || (JsonBooleanNode = {}));
|
|
122
|
+
export var JsonNullNode;
|
|
145
123
|
(function (JsonNullNode) {
|
|
146
124
|
/* istanbul ignore next */
|
|
147
125
|
function is(obj) {
|
|
148
126
|
return obj.type === 'json:null';
|
|
149
127
|
}
|
|
150
128
|
JsonNullNode.is = is;
|
|
151
|
-
})(JsonNullNode
|
|
129
|
+
})(JsonNullNode || (JsonNullNode = {}));
|
|
152
130
|
//# sourceMappingURL=JsonAstNode.js.map
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './JsonAstNode';
|
|
1
|
+
export * from './JsonAstNode.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/node/index.js
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./JsonAstNode"), exports);
|
|
1
|
+
export * from './JsonAstNode.js';
|
|
14
2
|
//# sourceMappingURL=index.js.map
|
package/lib/parser/array.d.ts
CHANGED
package/lib/parser/array.js
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.array = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const entry_1 = require("./entry");
|
|
25
|
-
const array = (src, ctx) => {
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { entry } from './entry.js';
|
|
3
|
+
export const array = (src, ctx) => {
|
|
26
4
|
const parser = core.list({
|
|
27
5
|
start: '[',
|
|
28
|
-
value:
|
|
6
|
+
value: entry,
|
|
29
7
|
sep: ',',
|
|
30
8
|
trailingSep: false,
|
|
31
9
|
end: ']',
|
|
@@ -34,5 +12,4 @@ const array = (src, ctx) => {
|
|
|
34
12
|
ans.type = 'json:array';
|
|
35
13
|
return ans;
|
|
36
14
|
};
|
|
37
|
-
exports.array = array;
|
|
38
15
|
//# sourceMappingURL=array.js.map
|
package/lib/parser/boolean.d.ts
CHANGED
package/lib/parser/boolean.js
CHANGED
|
@@ -1,44 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.boolean = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const core_1 = require("@spyglassmc/core");
|
|
25
|
-
const boolean = (src, ctx) => {
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { Range } from '@spyglassmc/core';
|
|
3
|
+
export const boolean = (src, ctx) => {
|
|
26
4
|
const start = src.cursor;
|
|
27
5
|
if (src.trySkip('false')) {
|
|
28
6
|
return {
|
|
29
7
|
type: 'json:boolean',
|
|
30
|
-
range:
|
|
8
|
+
range: Range.create(start, src),
|
|
31
9
|
value: false,
|
|
32
10
|
};
|
|
33
11
|
}
|
|
34
12
|
if (src.trySkip('true')) {
|
|
35
13
|
return {
|
|
36
14
|
type: 'json:boolean',
|
|
37
|
-
range:
|
|
15
|
+
range: Range.create(start, src),
|
|
38
16
|
value: true,
|
|
39
17
|
};
|
|
40
18
|
}
|
|
41
19
|
return core.Failure;
|
|
42
20
|
};
|
|
43
|
-
exports.boolean = boolean;
|
|
44
21
|
//# sourceMappingURL=boolean.js.map
|
package/lib/parser/entry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
|
-
import type { JsonNode } from '../node';
|
|
2
|
+
import type { JsonNode } from '../node/index.js';
|
|
3
3
|
export declare function json(dumpErrors?: boolean): core.Parser<JsonNode>;
|
|
4
4
|
export declare const entry: core.Parser<JsonNode>;
|
|
5
5
|
//# sourceMappingURL=entry.d.ts.map
|