@spyglassmc/json 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.
- package/lib/checker/JsonChecker.d.ts +8 -0
- package/lib/checker/JsonChecker.js +3 -0
- package/lib/checker/index.d.ts +3 -0
- package/lib/checker/index.js +15 -0
- package/lib/checker/primitives/boolean.d.ts +4 -0
- package/lib/checker/primitives/boolean.js +13 -0
- package/lib/checker/primitives/index.d.ts +7 -0
- package/lib/checker/primitives/index.js +19 -0
- package/lib/checker/primitives/list.d.ts +10 -0
- package/lib/checker/primitives/list.js +49 -0
- package/lib/checker/primitives/number.d.ts +6 -0
- package/lib/checker/primitives/number.js +28 -0
- package/lib/checker/primitives/object.d.ts +34 -0
- package/lib/checker/primitives/object.js +190 -0
- package/lib/checker/primitives/string.d.ts +12 -0
- package/lib/checker/primitives/string.js +72 -0
- package/lib/checker/primitives/util.d.ts +15 -0
- package/lib/checker/primitives/util.js +77 -0
- package/lib/colorizer/index.d.ts +7 -0
- package/lib/colorizer/index.js +55 -0
- package/lib/completer/index.d.ts +9 -0
- package/lib/completer/index.js +165 -0
- package/lib/formatter/index.d.ts +3 -0
- package/lib/formatter/index.js +53 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +49 -0
- package/lib/node/JsonAstNode.d.ts +97 -0
- package/lib/node/JsonAstNode.js +152 -0
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.js +14 -0
- package/lib/parser/array.d.ts +4 -0
- package/lib/parser/array.js +38 -0
- package/lib/parser/boolean.d.ts +4 -0
- package/lib/parser/boolean.js +44 -0
- package/lib/parser/entry.d.ts +5 -0
- package/lib/parser/entry.js +49 -0
- package/lib/parser/index.d.ts +6 -0
- package/lib/parser/index.js +18 -0
- package/lib/parser/null.d.ts +4 -0
- package/lib/parser/null.js +36 -0
- package/lib/parser/number.d.ts +4 -0
- package/lib/parser/number.js +34 -0
- package/lib/parser/object.d.ts +4 -0
- package/lib/parser/object.js +34 -0
- package/lib/parser/string.d.ts +5 -0
- package/lib/parser/string.js +38 -0
- package/lib/util.d.ts +1 -0
- package/lib/util.js +2 -0
- package/package.json +30 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
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 __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.entry = exports.json = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
const array_1 = require("./array");
|
|
25
|
+
const boolean_1 = require("./boolean");
|
|
26
|
+
const null_1 = require("./null");
|
|
27
|
+
const number_1 = require("./number");
|
|
28
|
+
const object_1 = require("./object");
|
|
29
|
+
const string_1 = require("./string");
|
|
30
|
+
const LegalNumberStart = new Set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-']);
|
|
31
|
+
function json(dumpErrors = false) {
|
|
32
|
+
return (src, ctx) => {
|
|
33
|
+
const result = core.select([
|
|
34
|
+
{ predicate: src => src.tryPeek('['), parser: array_1.array },
|
|
35
|
+
{ predicate: src => src.tryPeek('false') || src.tryPeek('true'), parser: boolean_1.boolean },
|
|
36
|
+
{ predicate: src => src.tryPeek('null'), parser: null_1.null_ },
|
|
37
|
+
{ predicate: src => LegalNumberStart.has(src.peek()), parser: number_1.number },
|
|
38
|
+
{ predicate: src => src.tryPeek('{'), parser: object_1.object },
|
|
39
|
+
{ parser: string_1.string },
|
|
40
|
+
])(src, ctx);
|
|
41
|
+
if (dumpErrors) {
|
|
42
|
+
ctx.err.dump();
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.json = json;
|
|
48
|
+
exports.entry = json(true);
|
|
49
|
+
//# sourceMappingURL=entry.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
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("./array"), exports);
|
|
14
|
+
__exportStar(require("./entry"), exports);
|
|
15
|
+
__exportStar(require("./number"), exports);
|
|
16
|
+
__exportStar(require("./object"), exports);
|
|
17
|
+
__exportStar(require("./string"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
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 __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.null_ = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
const core_1 = require("@spyglassmc/core");
|
|
25
|
+
const null_ = (src, ctx) => {
|
|
26
|
+
const start = src.cursor;
|
|
27
|
+
if (src.trySkip('null')) {
|
|
28
|
+
return {
|
|
29
|
+
type: 'json:null',
|
|
30
|
+
range: core_1.Range.create(start, src),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return core.Failure;
|
|
34
|
+
};
|
|
35
|
+
exports.null_ = null_;
|
|
36
|
+
//# sourceMappingURL=null.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
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 __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.number = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
const number = (src, ctx) => {
|
|
25
|
+
const parser = core.float({
|
|
26
|
+
// Regex form of the chart from https://www.json.org.
|
|
27
|
+
pattern: /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?$/,
|
|
28
|
+
});
|
|
29
|
+
const ans = parser(src, ctx);
|
|
30
|
+
ans.type = 'json:number';
|
|
31
|
+
return ans;
|
|
32
|
+
};
|
|
33
|
+
exports.number = number;
|
|
34
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
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 __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.object = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
const entry_1 = require("./entry");
|
|
25
|
+
const string_1 = require("./string");
|
|
26
|
+
const object = (src, ctx) => {
|
|
27
|
+
return core.setType('json:object', core.record({
|
|
28
|
+
start: '{',
|
|
29
|
+
pair: { key: string_1.string, sep: ':', value: entry_1.entry, end: ',', trailingEnd: false },
|
|
30
|
+
end: '}',
|
|
31
|
+
}))(src, ctx);
|
|
32
|
+
};
|
|
33
|
+
exports.object = object;
|
|
34
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
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 __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.string = exports.JsonStringOptions = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
exports.JsonStringOptions = {
|
|
25
|
+
escapable: {
|
|
26
|
+
characters: ['b', 'f', 'n', 'r', 't'],
|
|
27
|
+
unicode: true,
|
|
28
|
+
},
|
|
29
|
+
quotes: ['"'],
|
|
30
|
+
};
|
|
31
|
+
const string = (src, ctx) => {
|
|
32
|
+
const parser = core.string(exports.JsonStringOptions);
|
|
33
|
+
const ans = parser(src, ctx);
|
|
34
|
+
ans.type = 'json:string';
|
|
35
|
+
return ans;
|
|
36
|
+
};
|
|
37
|
+
exports.string = string;
|
|
38
|
+
//# sourceMappingURL=string.js.map
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=util.d.ts.map
|
package/lib/util.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spyglassmc/json",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "lib/index.js",
|
|
5
|
+
"types": "lib/index.d.ts",
|
|
6
|
+
"author": "Misode",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"directories": {
|
|
9
|
+
"test": "test/"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"release": "npm publish",
|
|
13
|
+
"release:dry": "npm publish --dry-run"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/SpyglassMC/Spyglass.git"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://spyglassmc.com",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/SpyglassMC/Spyglass/issues"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@spyglassmc/core": "0.1.0",
|
|
28
|
+
"@spyglassmc/locales": "0.1.0"
|
|
29
|
+
}
|
|
30
|
+
}
|