@spyglassmc/java-edition 0.1.3 → 0.3.1
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/binder/index.d.ts +1 -1
- package/lib/binder/index.js +11 -17
- package/lib/common/index.js +6 -33
- package/lib/dependency/common.js +6 -9
- package/lib/dependency/index.d.ts +6 -8
- package/lib/dependency/index.js +34 -59
- package/lib/dependency/mcmeta.d.ts +2 -2
- package/lib/dependency/mcmeta.js +8 -37
- package/lib/index.d.ts +3 -3
- package/lib/index.js +21 -48
- package/lib/json/checker/data/advancement.d.ts +13 -13
- package/lib/json/checker/data/advancement.js +263 -266
- package/lib/json/checker/data/biome.d.ts +3 -3
- package/lib/json/checker/data/biome.js +98 -101
- package/lib/json/checker/data/common.d.ts +1 -1
- package/lib/json/checker/data/common.js +145 -152
- package/lib/json/checker/data/dimension.d.ts +3 -3
- package/lib/json/checker/data/dimension.js +148 -151
- package/lib/json/checker/data/feature.d.ts +8 -8
- package/lib/json/checker/data/feature.js +370 -373
- package/lib/json/checker/data/index.d.ts +2 -2
- package/lib/json/checker/data/index.js +36 -39
- package/lib/json/checker/data/loot_table.d.ts +7 -7
- package/lib/json/checker/data/loot_table.js +125 -128
- package/lib/json/checker/data/recipe.d.ts +1 -1
- package/lib/json/checker/data/recipe.js +25 -28
- package/lib/json/checker/data/structure.d.ts +7 -7
- package/lib/json/checker/data/structure.js +80 -83
- package/lib/json/checker/data/tag.d.ts +6 -6
- package/lib/json/checker/data/tag.js +23 -26
- package/lib/json/checker/data/text_component.d.ts +1 -1
- package/lib/json/checker/data/text_component.js +61 -64
- package/lib/json/checker/index.js +14 -19
- package/lib/json/checker/util/advancement.d.ts +1 -1
- package/lib/json/checker/util/advancement.js +6 -10
- package/lib/json/checker/util/block_states.d.ts +1 -1
- package/lib/json/checker/util/block_states.js +25 -53
- package/lib/json/checker/util/color.d.ts +1 -1
- package/lib/json/checker/util/color.js +24 -29
- package/lib/json/checker/util/index.d.ts +7 -7
- package/lib/json/checker/util/index.js +7 -23
- package/lib/json/checker/util/nbt.d.ts +1 -1
- package/lib/json/checker/util/nbt.js +23 -28
- package/lib/json/checker/util/recipe.d.ts +1 -1
- package/lib/json/checker/util/recipe.js +4 -8
- package/lib/json/checker/util/uuid.d.ts +1 -1
- package/lib/json/checker/util/uuid.js +4 -7
- package/lib/json/checker/util/version.d.ts +2 -2
- package/lib/json/checker/util/version.js +7 -13
- package/lib/json/index.d.ts +1 -1
- package/lib/json/index.js +4 -31
- package/lib/mcfunction/checker/index.d.ts +1 -1
- package/lib/mcfunction/checker/index.js +24 -53
- package/lib/mcfunction/colorizer/index.d.ts +1 -1
- package/lib/mcfunction/colorizer/index.js +6 -35
- package/lib/mcfunction/common/index.js +7 -33
- package/lib/mcfunction/completer/argument.js +93 -120
- package/lib/mcfunction/completer/index.d.ts +1 -1
- package/lib/mcfunction/completer/index.js +1 -17
- package/lib/mcfunction/index.d.ts +5 -5
- package/lib/mcfunction/index.js +16 -43
- package/lib/mcfunction/inlayHintProvider.js +3 -30
- package/lib/mcfunction/node/argument.d.ts +7 -7
- package/lib/mcfunction/node/argument.js +38 -63
- package/lib/mcfunction/node/index.d.ts +1 -1
- package/lib/mcfunction/node/index.js +1 -17
- package/lib/mcfunction/parser/argument.d.ts +1 -1
- package/lib/mcfunction/parser/argument.js +72 -100
- package/lib/mcfunction/parser/index.d.ts +1 -1
- package/lib/mcfunction/parser/index.js +1 -17
- package/lib/mcfunction/signatureHelpProvider.js +3 -30
- package/lib/mcfunction/tree/argument.js +1 -2
- package/lib/mcfunction/tree/index.d.ts +1 -1
- package/lib/mcfunction/tree/index.js +1 -17
- package/lib/mcfunction/tree/patch.d.ts +1 -1
- package/lib/mcfunction/tree/patch.js +5 -9
- package/package.json +8 -7
package/lib/binder/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const Categories: Map<string, {
|
|
|
7
7
|
}>;
|
|
8
8
|
export declare function getRels(uri: string, rootUris: readonly RootUriString[]): Generator<string, undefined, unknown>;
|
|
9
9
|
export declare function dissectUri(uri: string, ctx: ContextBase): {
|
|
10
|
-
category: "function" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/activity" | "tag/attribute" | "tag/block" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/chunk_status" | "tag/custom_stat" | "tag/enchantment" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/game_event" | "tag/height_provider_type" | "tag/int_provider_type" | "tag/item" | "tag/loot_condition_type" | "tag/loot_function_type" | "tag/loot_nbt_provider_type" | "tag/loot_number_provider_type" | "tag/loot_pool_entry_type" | "tag/loot_score_provider_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/particle_type" | "tag/point_of_interest_type" | "tag/pos_rule_test" | "tag/position_source_type" | "tag/potion" | "tag/recipe_serializer" | "tag/recipe_type" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/villager_profession" | "tag/villager_type" | "tag/worldgen/biome_source" | "tag/worldgen/block_placer_type" | "tag/worldgen/block_state_provider_type" | "tag/worldgen/carver" | "tag/worldgen/chunk_generator" | "tag/worldgen/decorator" | "tag/worldgen/feature" | "tag/worldgen/feature_size_type" | "tag/worldgen/foliage_placer_type" | "tag/worldgen/material_condition" | "tag/worldgen/material_rule" | "tag/worldgen/placement_modifier_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/worldgen/biome" | "tag/worldgen/configured_carver" | "tag/worldgen/configured_feature" | "tag/worldgen/configured_structure_feature" | "tag/worldgen/configured_surface_builder" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool"
|
|
10
|
+
category: "function" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/activity" | "tag/attribute" | "tag/block" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/chunk_status" | "tag/custom_stat" | "tag/enchantment" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/game_event" | "tag/height_provider_type" | "tag/int_provider_type" | "tag/item" | "tag/loot_condition_type" | "tag/loot_function_type" | "tag/loot_nbt_provider_type" | "tag/loot_number_provider_type" | "tag/loot_pool_entry_type" | "tag/loot_score_provider_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/particle_type" | "tag/point_of_interest_type" | "tag/pos_rule_test" | "tag/position_source_type" | "tag/potion" | "tag/recipe_serializer" | "tag/recipe_type" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/villager_profession" | "tag/villager_type" | "tag/worldgen/biome_source" | "tag/worldgen/block_placer_type" | "tag/worldgen/block_state_provider_type" | "tag/worldgen/carver" | "tag/worldgen/chunk_generator" | "tag/worldgen/decorator" | "tag/worldgen/feature" | "tag/worldgen/feature_size_type" | "tag/worldgen/foliage_placer_type" | "tag/worldgen/material_condition" | "tag/worldgen/material_rule" | "tag/worldgen/placement_modifier_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/worldgen/biome" | "tag/worldgen/configured_carver" | "tag/worldgen/configured_feature" | "tag/worldgen/configured_structure_feature" | "tag/worldgen/configured_surface_builder" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool";
|
|
11
11
|
namespace: string;
|
|
12
12
|
identifier: string;
|
|
13
13
|
} | undefined;
|
package/lib/binder/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@spyglassmc/core");
|
|
5
|
-
const dependency_1 = require("../dependency");
|
|
6
|
-
exports.Categories = (() => {
|
|
1
|
+
import { fileUtil, RegistryCategories } from '@spyglassmc/core';
|
|
2
|
+
import { ReleaseVersion } from '../dependency/index.js';
|
|
3
|
+
export const Categories = (() => {
|
|
7
4
|
const NonTaggableRegistries = new Set([
|
|
8
5
|
'block', 'fluid', 'game_event', 'item',
|
|
9
6
|
'worldgen/block_placer_type', 'worldgen/surface_builder', // They are removed at some point.
|
|
@@ -34,7 +31,7 @@ exports.Categories = (() => {
|
|
|
34
31
|
['worldgen/processor_list', { category: 'worldgen/processor_list', extname: '.json', since: '1.16' }],
|
|
35
32
|
['worldgen/template_pool', { category: 'worldgen/template_pool', extname: '.json', since: '1.16' }],
|
|
36
33
|
]);
|
|
37
|
-
for (const registry of
|
|
34
|
+
for (const registry of RegistryCategories) {
|
|
38
35
|
if (NonTaggableRegistries.has(registry)) {
|
|
39
36
|
continue;
|
|
40
37
|
}
|
|
@@ -42,8 +39,8 @@ exports.Categories = (() => {
|
|
|
42
39
|
}
|
|
43
40
|
return ans;
|
|
44
41
|
})();
|
|
45
|
-
function* getRels(uri, rootUris) {
|
|
46
|
-
yield*
|
|
42
|
+
export function* getRels(uri, rootUris) {
|
|
43
|
+
yield* fileUtil.getRels(uri, rootUris);
|
|
47
44
|
const parts = uri.split('/');
|
|
48
45
|
for (let i = parts.length - 2; i >= 0; i--) {
|
|
49
46
|
if (parts[i] === 'data') {
|
|
@@ -52,8 +49,7 @@ function* getRels(uri, rootUris) {
|
|
|
52
49
|
}
|
|
53
50
|
return undefined;
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
function dissectUri(uri, ctx) {
|
|
52
|
+
export function dissectUri(uri, ctx) {
|
|
57
53
|
const regex = /^data\/([^\/]+)\/((?:tags\/|worldgen\/)?[a-z_]+)\/(.*)(\.(?:mcfunction|json))$/;
|
|
58
54
|
const rels = getRels(uri, ctx.roots);
|
|
59
55
|
for (const rel of rels) {
|
|
@@ -61,7 +57,7 @@ function dissectUri(uri, ctx) {
|
|
|
61
57
|
if (!match) {
|
|
62
58
|
continue;
|
|
63
59
|
}
|
|
64
|
-
const def =
|
|
60
|
+
const def = Categories.get(match[2]);
|
|
65
61
|
if (!def || def.extname !== match[4]) {
|
|
66
62
|
continue;
|
|
67
63
|
}
|
|
@@ -76,8 +72,7 @@ function dissectUri(uri, ctx) {
|
|
|
76
72
|
}
|
|
77
73
|
return undefined;
|
|
78
74
|
}
|
|
79
|
-
|
|
80
|
-
const uriBinder = (uris, ctx) => {
|
|
75
|
+
export const uriBinder = (uris, ctx) => {
|
|
81
76
|
for (const uri of uris) {
|
|
82
77
|
const parts = dissectUri(uri, ctx);
|
|
83
78
|
if (parts) {
|
|
@@ -91,11 +86,10 @@ const uriBinder = (uris, ctx) => {
|
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
};
|
|
94
|
-
exports.uriBinder = uriBinder;
|
|
95
89
|
function matchVersion(target, since, until) {
|
|
96
|
-
if (since &&
|
|
90
|
+
if (since && ReleaseVersion.cmp(target, since) < 0)
|
|
97
91
|
return false;
|
|
98
|
-
if (until &&
|
|
92
|
+
if (until && ReleaseVersion.cmp(until, target) < 0)
|
|
99
93
|
return false;
|
|
100
94
|
return true;
|
|
101
95
|
}
|
package/lib/common/index.js
CHANGED
|
@@ -1,46 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getTagValues = exports.getUris = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const json = __importStar(require("@spyglassmc/json"));
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import * as json from '@spyglassmc/json';
|
|
29
3
|
/**
|
|
30
4
|
* @returns An array of URIs corresponding to the specified resource.
|
|
31
5
|
*/
|
|
32
|
-
function getUris(category, id, ctx) {
|
|
6
|
+
export function getUris(category, id, ctx) {
|
|
33
7
|
return ctx.symbols
|
|
34
8
|
.query(ctx.doc, category, core.ResourceLocation.lengthen(id))
|
|
35
9
|
.symbol?.definition?.map(v => v.uri) ?? [];
|
|
36
10
|
}
|
|
37
|
-
|
|
38
|
-
function getTagValues(category, id, ctx) {
|
|
11
|
+
export function getTagValues(category, id, ctx) {
|
|
39
12
|
const resolveValueNode = (node) => json.JsonStringNode.is(node)
|
|
40
13
|
? node.value
|
|
41
14
|
: node.children.find(n => n.key?.value === 'id').value.value;
|
|
42
15
|
const set = getUris(category, id, ctx).reduce((ans, uri) => {
|
|
43
|
-
const result = ctx.getDocAndNode(uri)
|
|
16
|
+
// const result = ctx.getDocAndNode(uri)
|
|
17
|
+
const result = undefined; // FIXME: Use global symbol table to get the result
|
|
44
18
|
if (!result || result.node.parserErrors.length || result.node.checkerErrors?.length) {
|
|
45
19
|
return ans;
|
|
46
20
|
}
|
|
@@ -60,5 +34,4 @@ function getTagValues(category, id, ctx) {
|
|
|
60
34
|
}, new Set());
|
|
61
35
|
return [...set];
|
|
62
36
|
}
|
|
63
|
-
exports.getTagValues = getTagValues;
|
|
64
37
|
//# sourceMappingURL=index.js.map
|
package/lib/dependency/common.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackMcmeta = exports.PackVersionMap = exports.ReleaseVersion = void 0;
|
|
4
|
-
var ReleaseVersion;
|
|
1
|
+
export var ReleaseVersion;
|
|
5
2
|
(function (ReleaseVersion) {
|
|
6
3
|
/**
|
|
7
4
|
* @returns
|
|
@@ -13,12 +10,12 @@ var ReleaseVersion;
|
|
|
13
10
|
return Math.sign(Number(a.slice(2)) - Number(b.slice(2)));
|
|
14
11
|
}
|
|
15
12
|
ReleaseVersion.cmp = cmp;
|
|
16
|
-
})(ReleaseVersion
|
|
13
|
+
})(ReleaseVersion || (ReleaseVersion = {}));
|
|
17
14
|
// DOCS: Update here when format_version is changed.
|
|
18
15
|
/**
|
|
19
16
|
* A map from `pack_format` numbers to a RegExp. The latest version whose `release_target` matches the RegExp should be used.
|
|
20
17
|
*/
|
|
21
|
-
|
|
18
|
+
export const PackVersionMap = {
|
|
22
19
|
5: /^1\.15.*$/,
|
|
23
20
|
6: /^1\.16.*$/,
|
|
24
21
|
7: /^1\.17.*$/,
|
|
@@ -26,17 +23,17 @@ exports.PackVersionMap = {
|
|
|
26
23
|
9: /^1\.18.*$/,
|
|
27
24
|
10: /^1\.19.*$/,
|
|
28
25
|
};
|
|
29
|
-
var PackMcmeta;
|
|
26
|
+
export var PackMcmeta;
|
|
30
27
|
(function (PackMcmeta) {
|
|
31
28
|
function assert(data) {
|
|
32
29
|
const format = data?.pack?.pack_format?.toString();
|
|
33
30
|
if (!format) {
|
|
34
31
|
throw new Error('“pack.pack_format” undefined');
|
|
35
32
|
}
|
|
36
|
-
if (!Object.keys(
|
|
33
|
+
if (!Object.keys(PackVersionMap).includes(format)) {
|
|
37
34
|
throw new Error(`Unknown pack_format “${format}”`);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
PackMcmeta.assert = assert;
|
|
41
|
-
})(PackMcmeta
|
|
38
|
+
})(PackMcmeta || (PackMcmeta = {}));
|
|
42
39
|
//# sourceMappingURL=common.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './mcmeta';
|
|
1
|
+
export * from './common.js';
|
|
2
|
+
export * from './mcmeta.js';
|
|
3
3
|
import * as core from '@spyglassmc/core';
|
|
4
|
-
import type { McmetaSummary, McmetaVersions } from './mcmeta';
|
|
4
|
+
import type { McmetaSummary, McmetaVersions } from './mcmeta.js';
|
|
5
5
|
/**
|
|
6
6
|
* Return the deserialized [`versions.json`][versions.json].
|
|
7
7
|
*
|
|
8
8
|
* [versions.json]: https://github.com/misode/mcmeta/blob/summary/versions/data.json
|
|
9
9
|
*/
|
|
10
|
-
export declare function getVersions(downloader: core.Downloader): Promise<McmetaVersions | undefined>;
|
|
10
|
+
export declare function getVersions(externals: core.Externals, downloader: core.Downloader): Promise<McmetaVersions | undefined>;
|
|
11
11
|
interface GetMcmetaSummaryResult extends Partial<McmetaSummary> {
|
|
12
12
|
checksum: string | undefined;
|
|
13
13
|
}
|
|
@@ -16,15 +16,13 @@ interface GetMcmetaSummaryResult extends Partial<McmetaSummary> {
|
|
|
16
16
|
*
|
|
17
17
|
* @throws Network/file system errors.
|
|
18
18
|
*/
|
|
19
|
-
export declare function getMcmetaSummary(downloader: core.Downloader, logger: core.Logger, version: string, isLatest: boolean, source: string, overridePaths?: core.EnvConfig['mcmetaSummaryOverrides']): Promise<GetMcmetaSummaryResult>;
|
|
19
|
+
export declare function getMcmetaSummary(externals: core.Externals, downloader: core.Downloader, logger: core.Logger, version: string, isLatest: boolean, source: string, overridePaths?: core.EnvConfig['mcmetaSummaryOverrides']): Promise<GetMcmetaSummaryResult>;
|
|
20
20
|
/**
|
|
21
|
-
* @param version An already resolved version identifier.
|
|
22
|
-
*
|
|
23
21
|
* @throws Network/file system errors.
|
|
24
22
|
*
|
|
25
23
|
* @returns
|
|
26
24
|
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
27
25
|
* - `uri`: URI to the `.tar.gz` file.
|
|
28
26
|
*/
|
|
29
|
-
export declare function getVanillaMcdoc(downloader: core.Downloader
|
|
27
|
+
export declare function getVanillaMcdoc(downloader: core.Downloader): Promise<core.Dependency>;
|
|
30
28
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/dependency/index.js
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getVanillaMcdoc = exports.getMcmetaSummary = exports.getVersions = void 0;
|
|
30
|
-
__exportStar(require("./common"), exports);
|
|
31
|
-
__exportStar(require("./mcmeta"), exports);
|
|
32
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
33
|
-
const mcmeta_1 = require("./mcmeta");
|
|
1
|
+
export * from './common.js';
|
|
2
|
+
export * from './mcmeta.js';
|
|
3
|
+
import * as core from '@spyglassmc/core';
|
|
4
|
+
import { Fluids, getMcmetaSummaryUris } from './mcmeta.js';
|
|
34
5
|
const DownloaderTtl = 15000;
|
|
35
6
|
/* istanbul ignore next */
|
|
36
7
|
/**
|
|
@@ -38,35 +9,34 @@ const DownloaderTtl = 15000;
|
|
|
38
9
|
*
|
|
39
10
|
* [versions.json]: https://github.com/misode/mcmeta/blob/summary/versions/data.json
|
|
40
11
|
*/
|
|
41
|
-
async function getVersions(downloader) {
|
|
12
|
+
export async function getVersions(externals, downloader) {
|
|
42
13
|
return downloader.download({
|
|
43
14
|
id: 'mc-je/versions.json.gz',
|
|
44
15
|
uri: 'https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json.gz',
|
|
45
|
-
transformer: buffer => core.parseGzippedJson(buffer),
|
|
16
|
+
transformer: buffer => core.parseGzippedJson(externals, buffer),
|
|
46
17
|
cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', 'refs/heads/summary'),
|
|
47
18
|
ttl: DownloaderTtl,
|
|
48
19
|
});
|
|
49
20
|
}
|
|
50
|
-
exports.getVersions = getVersions;
|
|
51
21
|
/* istanbul ignore next */
|
|
52
22
|
/**
|
|
53
23
|
* Get vanilla resources, including block definitions, fluid definitions, command tree, and registries.
|
|
54
24
|
*
|
|
55
25
|
* @throws Network/file system errors.
|
|
56
26
|
*/
|
|
57
|
-
async function getMcmetaSummary(downloader, logger, version, isLatest, source, overridePaths = {}) {
|
|
27
|
+
export async function getMcmetaSummary(externals, downloader, logger, version, isLatest, source, overridePaths = {}) {
|
|
58
28
|
const ref = getGitRef({
|
|
59
29
|
defaultBranch: 'summary',
|
|
60
30
|
getTag: v => `${v}-summary`,
|
|
61
31
|
isLatest,
|
|
62
32
|
version,
|
|
63
33
|
});
|
|
64
|
-
const uris =
|
|
34
|
+
const uris = getMcmetaSummaryUris(version, isLatest, source);
|
|
65
35
|
let checksum;
|
|
66
|
-
|
|
36
|
+
async function handleOverride(currentValue, overrideConfig) {
|
|
67
37
|
if (overrideConfig) {
|
|
68
38
|
try {
|
|
69
|
-
const override = await core.fileUtil.readJson(
|
|
39
|
+
const override = await core.fileUtil.readJson(externals, overrideConfig.path);
|
|
70
40
|
if (overrideConfig.replace) {
|
|
71
41
|
return override;
|
|
72
42
|
}
|
|
@@ -79,28 +49,27 @@ async function getMcmetaSummary(downloader, logger, version, isLatest, source, o
|
|
|
79
49
|
}
|
|
80
50
|
}
|
|
81
51
|
return currentValue;
|
|
82
|
-
}
|
|
52
|
+
}
|
|
83
53
|
const getResource = async (type, overrideConfig) => {
|
|
84
54
|
const out = {};
|
|
85
55
|
const data = await downloader.download({
|
|
86
56
|
id: `mc-je/${version}/${type}.json.gz`,
|
|
87
57
|
uri: uris[type],
|
|
88
|
-
transformer: buffer => core.parseGzippedJson(buffer),
|
|
58
|
+
transformer: buffer => core.parseGzippedJson(externals, buffer),
|
|
89
59
|
cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', ref),
|
|
90
60
|
ttl: DownloaderTtl,
|
|
91
61
|
}, out);
|
|
92
|
-
checksum
|
|
62
|
+
checksum ||= out.checksum;
|
|
93
63
|
return handleOverride(data, overrideConfig);
|
|
94
64
|
};
|
|
95
65
|
const [blocks, commands, fluids, registries] = [
|
|
96
66
|
await getResource('blocks', overridePaths.blocks),
|
|
97
67
|
await getResource('commands', overridePaths.commands),
|
|
98
|
-
await handleOverride(
|
|
68
|
+
await handleOverride(Fluids, overridePaths.fluids),
|
|
99
69
|
await getResource('registries', overridePaths.registries),
|
|
100
70
|
];
|
|
101
71
|
return { blocks, commands, fluids, registries, checksum };
|
|
102
72
|
}
|
|
103
|
-
exports.getMcmetaSummary = getMcmetaSummary;
|
|
104
73
|
function getGitRef({ defaultBranch, getTag, isLatest, version }) {
|
|
105
74
|
return isLatest ? `refs/heads/${defaultBranch}` : `refs/tags/${getTag(version)}`;
|
|
106
75
|
}
|
|
@@ -133,6 +102,11 @@ function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
|
|
|
133
102
|
};
|
|
134
103
|
}
|
|
135
104
|
/**
|
|
105
|
+
* Download data from a GitHub repository with tags corresponding to Minecraft versions.
|
|
106
|
+
* The downloaded data will be cached based on the commit SHA of the respective tag.
|
|
107
|
+
*
|
|
108
|
+
* If `isLatest` if `true`, instead of finding the tag corresponding to the given version, the default branch will be used.
|
|
109
|
+
*
|
|
136
110
|
* @returns The URI to the `.tar.gz` file.
|
|
137
111
|
*/
|
|
138
112
|
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version }) {
|
|
@@ -146,31 +120,32 @@ async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isL
|
|
|
146
120
|
options: GitHubApiDownloadOptions,
|
|
147
121
|
ttl: DownloaderTtl,
|
|
148
122
|
}, out);
|
|
149
|
-
return
|
|
123
|
+
return out.cacheUri;
|
|
150
124
|
}
|
|
151
125
|
/* istanbul ignore next */
|
|
152
126
|
/**
|
|
153
|
-
* @param version An already resolved version identifier.
|
|
154
|
-
*
|
|
155
127
|
* @throws Network/file system errors.
|
|
156
128
|
*
|
|
157
129
|
* @returns
|
|
158
130
|
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
159
131
|
* - `uri`: URI to the `.tar.gz` file.
|
|
160
132
|
*/
|
|
161
|
-
async function getVanillaMcdoc(downloader
|
|
133
|
+
export async function getVanillaMcdoc(downloader) {
|
|
134
|
+
const owner = 'SpyglassMC';
|
|
135
|
+
const repo = 'vanilla-mcdoc';
|
|
136
|
+
const ref = 'refs/heads/main';
|
|
137
|
+
const out = {};
|
|
138
|
+
await downloader.download({
|
|
139
|
+
id: 'mc-je/vanilla-mcdoc.tar.gz',
|
|
140
|
+
uri: `https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`,
|
|
141
|
+
transformer: b => b,
|
|
142
|
+
cache: getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref),
|
|
143
|
+
options: GitHubApiDownloadOptions,
|
|
144
|
+
ttl: DownloaderTtl,
|
|
145
|
+
}, out);
|
|
162
146
|
return {
|
|
163
147
|
info: { startDepth: 1 },
|
|
164
|
-
uri:
|
|
165
|
-
defaultBranch: 'main',
|
|
166
|
-
downloader,
|
|
167
|
-
getTag: v => v,
|
|
168
|
-
isLatest,
|
|
169
|
-
owner: 'SpyglassMC',
|
|
170
|
-
repo: 'vanila-mcdoc',
|
|
171
|
-
version,
|
|
172
|
-
}),
|
|
148
|
+
uri: out.cacheUri,
|
|
173
149
|
};
|
|
174
150
|
}
|
|
175
|
-
exports.getVanillaMcdoc = getVanillaMcdoc;
|
|
176
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
|
-
import type { PackMcmeta, VersionInfo } from './common';
|
|
2
|
+
import type { PackMcmeta, VersionInfo } from './common.js';
|
|
3
3
|
/**
|
|
4
|
-
* @param inputVersion {@link Config.env.gameVersion}
|
|
4
|
+
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
5
5
|
*/
|
|
6
6
|
export declare function resolveConfiguredVersion(inputVersion: string, { packMcmeta, versions }: {
|
|
7
7
|
packMcmeta: PackMcmeta | undefined;
|
package/lib/dependency/mcmeta.js
CHANGED
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Fluids = exports.symbolRegistrar = exports.getMcmetaSummaryUris = exports.resolveConfiguredVersion = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const common_1 = require("./common");
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { PackVersionMap } from './common.js';
|
|
29
3
|
/**
|
|
30
|
-
* @param inputVersion {@link Config.env.gameVersion}
|
|
4
|
+
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
31
5
|
*/
|
|
32
|
-
function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
|
|
6
|
+
export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
|
|
33
7
|
function toVersionInfo(index) {
|
|
34
8
|
if (index < 0) {
|
|
35
9
|
index = 0;
|
|
@@ -49,7 +23,7 @@ function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
|
|
|
49
23
|
versions = versions.sort((a, b) => b.data_version - a.data_version);
|
|
50
24
|
if (inputVersion === 'auto') {
|
|
51
25
|
if (packMcmeta) {
|
|
52
|
-
const regex =
|
|
26
|
+
const regex = PackVersionMap[packMcmeta.pack.pack_format];
|
|
53
27
|
if (regex) {
|
|
54
28
|
return toVersionInfo(versions.findIndex(v => regex.test(v.release_target)));
|
|
55
29
|
}
|
|
@@ -64,13 +38,12 @@ function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
|
|
|
64
38
|
}
|
|
65
39
|
return toVersionInfo(versions.findIndex(v => inputVersion === v.id.toLowerCase() || inputVersion === v.name.toLowerCase()));
|
|
66
40
|
}
|
|
67
|
-
exports.resolveConfiguredVersion = resolveConfiguredVersion;
|
|
68
41
|
const DataSources = {
|
|
69
42
|
fastly: 'https://fastly.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}',
|
|
70
43
|
github: 'https://raw.githubusercontent.com/${user}/${repo}/${tag}/${path}',
|
|
71
44
|
jsdelivr: 'https://cdn.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}',
|
|
72
45
|
};
|
|
73
|
-
function getMcmetaSummaryUris(version, isLatest, source) {
|
|
46
|
+
export function getMcmetaSummaryUris(version, isLatest, source) {
|
|
74
47
|
const tag = isLatest ? 'summary' : `${version}-summary`;
|
|
75
48
|
function getUri(path) {
|
|
76
49
|
const template = DataSources[source.toLowerCase()] ?? source;
|
|
@@ -90,8 +63,7 @@ function getMcmetaSummaryUris(version, isLatest, source) {
|
|
|
90
63
|
registries: getUri('registries/data.json.gz'),
|
|
91
64
|
};
|
|
92
65
|
}
|
|
93
|
-
|
|
94
|
-
function symbolRegistrar(summary) {
|
|
66
|
+
export function symbolRegistrar(summary) {
|
|
95
67
|
const McmetaSummaryUri = 'mcmeta://summary/registries.json';
|
|
96
68
|
/**
|
|
97
69
|
* Add states of blocks or fluids to the symbol table.
|
|
@@ -151,8 +123,7 @@ function symbolRegistrar(summary) {
|
|
|
151
123
|
addStatesSymbols('fluid', summary.fluids, symbols);
|
|
152
124
|
};
|
|
153
125
|
}
|
|
154
|
-
|
|
155
|
-
exports.Fluids = {
|
|
126
|
+
export const Fluids = {
|
|
156
127
|
flowing_lava: [{ falling: ['false', 'true'], level: ['1', '2', '3', '4', '5', '6', '7', '8'] }, { falling: 'false', level: '1' }],
|
|
157
128
|
flowing_water: [{ falling: ['false', 'true'], level: ['1', '2', '3', '4', '5', '6', '7', '8'] }, { falling: 'false', level: '1' }],
|
|
158
129
|
lava: [{ falling: ['false', 'true'] }, { falling: 'false' }],
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
|
-
export * as dependency from './dependency';
|
|
3
|
-
export * as json from './json';
|
|
4
|
-
export * as mcf from './mcfunction';
|
|
2
|
+
export * as dependency from './dependency/index.js';
|
|
3
|
+
export * as json from './json/index.js';
|
|
4
|
+
export * as mcf from './mcfunction/index.js';
|
|
5
5
|
export declare const initialize: core.ProjectInitializer;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,74 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.initialize = exports.mcf = exports.json = exports.dependency = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const mcdoc = __importStar(require("@spyglassmc/mcdoc"));
|
|
29
|
-
const nbt = __importStar(require("@spyglassmc/nbt"));
|
|
30
|
-
const binder_1 = require("./binder");
|
|
31
|
-
const dependency_1 = require("./dependency");
|
|
32
|
-
const jeJson = __importStar(require("./json"));
|
|
33
|
-
const jeMcf = __importStar(require("./mcfunction"));
|
|
34
|
-
exports.dependency = __importStar(require("./dependency"));
|
|
35
|
-
exports.json = __importStar(require("./json"));
|
|
36
|
-
exports.mcf = __importStar(require("./mcfunction"));
|
|
37
|
-
const initialize = async (ctx) => {
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import * as mcdoc from '@spyglassmc/mcdoc';
|
|
3
|
+
import * as nbt from '@spyglassmc/nbt';
|
|
4
|
+
import { uriBinder } from './binder/index.js';
|
|
5
|
+
import { getMcmetaSummary, getVanillaMcdoc, getVersions, PackMcmeta, resolveConfiguredVersion, symbolRegistrar } from './dependency/index.js';
|
|
6
|
+
import * as jeJson from './json/index.js';
|
|
7
|
+
import * as jeMcf from './mcfunction/index.js';
|
|
8
|
+
export * as dependency from './dependency/index.js';
|
|
9
|
+
export * as json from './json/index.js';
|
|
10
|
+
export * as mcf from './mcfunction/index.js';
|
|
11
|
+
export const initialize = async (ctx) => {
|
|
12
|
+
const { config, downloader, externals, logger, meta, projectRoot } = ctx;
|
|
38
13
|
async function getPackMcmeta() {
|
|
39
14
|
let ans;
|
|
40
15
|
const uri = `${projectRoot}pack.mcmeta`;
|
|
41
16
|
try {
|
|
42
|
-
const data = await core.fileUtil.readJson(uri);
|
|
43
|
-
|
|
17
|
+
const data = await core.fileUtil.readJson(externals, uri);
|
|
18
|
+
PackMcmeta.assert(data);
|
|
44
19
|
ans = data;
|
|
45
20
|
}
|
|
46
21
|
catch (e) {
|
|
47
|
-
if (!
|
|
22
|
+
if (!externals.error.isKind(e, 'ENOENT')) {
|
|
48
23
|
// `pack.mcmeta` exists but broken. Log an error.
|
|
49
24
|
logger.error(`[je.initialize] Failed loading pack.mcmeta “${uri}”`, e);
|
|
50
25
|
}
|
|
51
26
|
}
|
|
52
27
|
return ans;
|
|
53
28
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const versions = await (0, dependency_1.getVersions)(ctx.downloader);
|
|
29
|
+
meta.registerUriBinder(uriBinder);
|
|
30
|
+
const versions = await getVersions(ctx.externals, ctx.downloader);
|
|
57
31
|
if (!versions) {
|
|
58
32
|
ctx.logger.error('[je-initialize] Failed loading game version list. Expect everything to be broken.');
|
|
59
33
|
return;
|
|
60
34
|
}
|
|
61
35
|
const packMcmeta = await getPackMcmeta();
|
|
62
|
-
const { release, id: version, isLatest } =
|
|
63
|
-
meta.registerDependencyProvider('@vanilla-mcdoc', () =>
|
|
64
|
-
const summary = await (
|
|
36
|
+
const { release, id: version, isLatest } = resolveConfiguredVersion(config.env.gameVersion, { packMcmeta, versions });
|
|
37
|
+
meta.registerDependencyProvider('@vanilla-mcdoc', () => getVanillaMcdoc(downloader));
|
|
38
|
+
const summary = await getMcmetaSummary(ctx.externals, downloader, logger, version, isLatest, config.env.dataSource, config.env.mcmetaSummaryOverrides);
|
|
65
39
|
if (!summary.blocks || !summary.commands || !summary.fluids || !summary.registries) {
|
|
66
40
|
ctx.logger.error('[je-initialize] Failed loading mcmeta summaries. Expect everything to be broken.');
|
|
67
41
|
return;
|
|
68
42
|
}
|
|
69
43
|
meta.registerSymbolRegistrar('mcmeta-summary', {
|
|
70
44
|
checksum: summary.checksum,
|
|
71
|
-
registrar:
|
|
45
|
+
registrar: symbolRegistrar(summary),
|
|
72
46
|
});
|
|
73
47
|
meta.registerLinter('nameOfNbtKey', {
|
|
74
48
|
configValidator: core.linter.configValidator.nameConvention,
|
|
@@ -88,5 +62,4 @@ const initialize = async (ctx) => {
|
|
|
88
62
|
loadedVersion: release,
|
|
89
63
|
};
|
|
90
64
|
};
|
|
91
|
-
exports.initialize = initialize;
|
|
92
65
|
//# sourceMappingURL=index.js.map
|