@spyglassmc/java-edition 0.3.8 → 0.3.10
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 +11 -9
- package/lib/binder/index.js +149 -150
- package/lib/common/index.js +6 -9
- package/lib/dependency/common.d.ts +5 -0
- package/lib/dependency/common.js +8 -0
- package/lib/dependency/index.js +7 -17
- package/lib/dependency/mcmeta.d.ts +6 -12
- package/lib/dependency/mcmeta.js +21 -38
- package/lib/index.d.ts +1 -0
- package/lib/index.js +74 -32
- package/lib/json/checker/index.d.ts +3 -10
- package/lib/json/checker/index.js +36 -244
- package/lib/json/index.d.ts +0 -1
- package/lib/json/index.js +0 -3
- package/lib/mcfunction/checker/index.d.ts +0 -2
- package/lib/mcfunction/checker/index.js +254 -183
- package/lib/mcfunction/common/index.d.ts +4 -2
- package/lib/mcfunction/common/index.js +56 -52
- package/lib/mcfunction/completer/argument.js +112 -57
- package/lib/mcfunction/index.d.ts +3 -2
- package/lib/mcfunction/index.js +18 -19
- package/lib/mcfunction/inlayHintProvider.js +2 -3
- package/lib/mcfunction/mcdocAttributes.d.ts +4 -0
- package/lib/mcfunction/mcdocAttributes.js +74 -0
- package/lib/mcfunction/node/argument.d.ts +115 -12
- package/lib/mcfunction/node/argument.js +131 -63
- package/lib/mcfunction/parser/argument.d.ts +14 -4
- package/lib/mcfunction/parser/argument.js +380 -212
- package/lib/mcfunction/signatureHelpProvider.d.ts +2 -1
- package/lib/mcfunction/signatureHelpProvider.js +10 -18
- package/lib/mcfunction/tree/argument.d.ts +68 -1
- package/lib/mcfunction/tree/patch.js +279 -77
- package/lib/mcfunction/tree/patchValidator.d.ts +7 -0
- package/lib/mcfunction/tree/patchValidator.js +25 -0
- package/package.json +8 -9
package/lib/binder/index.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const Categories: Map<string, {
|
|
3
|
-
category: FileCategory;
|
|
4
|
-
extname: string;
|
|
5
|
-
since?: `1.${number}` | undefined;
|
|
6
|
-
until?: `1.${number}` | undefined;
|
|
7
|
-
}>;
|
|
1
|
+
import type { CheckerContext, Config, RootUriString, UriBinder, UriBinderContext } from '@spyglassmc/core';
|
|
8
2
|
export declare function getRels(uri: string, rootUris: readonly RootUriString[]): Generator<string, undefined, unknown>;
|
|
9
|
-
export declare function dissectUri(uri: string, ctx:
|
|
10
|
-
category: "function" | "advancement" | "chat_type" | "damage_type" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure" | "trim_material" | "trim_pattern" | "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/density_function" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/density_function" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool";
|
|
3
|
+
export declare function dissectUri(uri: string, ctx: UriBinderContext): {
|
|
11
4
|
namespace: string;
|
|
12
5
|
identifier: string;
|
|
6
|
+
expected: string | undefined;
|
|
7
|
+
path: string;
|
|
8
|
+
category: "function" | "advancement" | "banner_pattern" | "chat_type" | "damage_type" | "dimension" | "dimension_type" | "enchantment" | "enchantment_provider" | "item_modifier" | "jukebox_song" | "loot_table" | "painting_variant" | "predicate" | "recipe" | "structure" | "trim_material" | "trim_pattern" | "wolf_variant" | "tag/function" | "tag/activity" | "tag/armor_material" | "tag/attribute" | "tag/block" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/block_type" | "tag/cat_variant" | "tag/chunk_status" | "tag/command_argument_type" | "tag/creative_mode_tab" | "tag/custom_stat" | "tag/data_component_type" | "tag/decorated_pot_pattern" | "tag/enchantment_effect_component_type" | "tag/enchantment_entity_effect_type" | "tag/enchantment_level_based_value_type" | "tag/enchantment_location_based_effect_type" | "tag/enchantment_provider_type" | "tag/enchantment_value_effect_type" | "tag/entity_sub_predicate_type" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/frog_variant" | "tag/game_event" | "tag/height_provider_type" | "tag/instrument" | "tag/int_provider_type" | "tag/item" | "tag/item_sub_predicate_type" | "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/map_decoration_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/number_format_type" | "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_block_entity_modifier" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/trigger_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/density_function_type" | "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/pool_alias_binding" | "tag/worldgen/root_placer_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_placement" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/structure_type" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/advancement" | "tag/banner_pattern" | "tag/chat_type" | "tag/damage_type" | "tag/dimension" | "tag/dimension_type" | "tag/enchantment" | "tag/enchantment_provider" | "tag/item_modifier" | "tag/jukebox_song" | "tag/loot_table" | "tag/painting_variant" | "tag/predicate" | "tag/recipe" | "tag/structure" | "tag/trim_material" | "tag/trim_pattern" | "tag/wolf_variant" | "tag/worldgen/biome" | "tag/worldgen/configured_carver" | "tag/worldgen/configured_feature" | "tag/worldgen/configured_structure_feature" | "tag/worldgen/configured_surface_builder" | "tag/worldgen/density_function" | "tag/worldgen/flat_level_generator_preset" | "tag/worldgen/multi_noise_biome_source_parameter_list" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/structure" | "tag/worldgen/structure_set" | "tag/worldgen/template_pool" | "tag/worldgen/world_preset" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/density_function" | "worldgen/flat_level_generator_preset" | "worldgen/multi_noise_biome_source_parameter_list" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/structure" | "worldgen/structure_set" | "worldgen/template_pool" | "worldgen/world_preset";
|
|
9
|
+
ext: `.${string}`;
|
|
10
|
+
since?: `1.${number}` | undefined;
|
|
11
|
+
until?: `1.${number}` | undefined;
|
|
12
|
+
ok: boolean;
|
|
13
13
|
} | undefined;
|
|
14
14
|
export declare const uriBinder: UriBinder;
|
|
15
|
+
export declare function registerCustomResources(config: Config): void;
|
|
16
|
+
export declare function reportDissectError(realPath: string, expectedPath: string | undefined, ctx: CheckerContext): void;
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/binder/index.js
CHANGED
|
@@ -1,165 +1,147 @@
|
|
|
1
|
-
import { fileUtil, TaggableResourceLocationCategories } from '@spyglassmc/core';
|
|
1
|
+
import { fileUtil, Range, TaggableResourceLocationCategories, } from '@spyglassmc/core';
|
|
2
|
+
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
2
3
|
import { ReleaseVersion } from '../dependency/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
'worldgen/noise_settings',
|
|
88
|
-
{
|
|
89
|
-
category: 'worldgen/noise_settings',
|
|
90
|
-
extname: '.json',
|
|
91
|
-
since: '1.16',
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
[
|
|
95
|
-
'worldgen/placed_feature',
|
|
96
|
-
{
|
|
97
|
-
category: 'worldgen/placed_feature',
|
|
98
|
-
extname: '.json',
|
|
99
|
-
since: '1.18',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
[
|
|
103
|
-
'worldgen/processor_list',
|
|
104
|
-
{
|
|
105
|
-
category: 'worldgen/processor_list',
|
|
106
|
-
extname: '.json',
|
|
107
|
-
since: '1.16',
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
'worldgen/template_pool',
|
|
112
|
-
{
|
|
113
|
-
category: 'worldgen/template_pool',
|
|
114
|
-
extname: '.json',
|
|
115
|
-
since: '1.16',
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
]);
|
|
119
|
-
for (const registry of TaggableResourceLocationCategories) {
|
|
120
|
-
if (NonTaggableRegistries.has(registry)) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
ans.set(`tags/${registry}`, {
|
|
124
|
-
category: `tag/${registry}`,
|
|
125
|
-
extname: '.json',
|
|
126
|
-
since: '1.18',
|
|
127
|
-
});
|
|
4
|
+
const Resources = new Map();
|
|
5
|
+
function resource(path, resource = {}) {
|
|
6
|
+
Resources.set(path, {
|
|
7
|
+
path,
|
|
8
|
+
category: resource.category ?? path,
|
|
9
|
+
ext: resource.ext ?? '.json',
|
|
10
|
+
...resource,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
// Pre-1.21 data pack plurals
|
|
14
|
+
resource('advancements', { category: 'advancement', until: '1.21' });
|
|
15
|
+
resource('functions', { category: 'function', until: '1.21', ext: '.mcfunction' });
|
|
16
|
+
resource('item_modifiers', { category: 'item_modifier', since: '1.17', until: '1.21' });
|
|
17
|
+
resource('loot_tables', { category: 'loot_table', until: '1.21' });
|
|
18
|
+
resource('predicates', { category: 'predicate', until: '1.21' });
|
|
19
|
+
resource('recipes', { category: 'recipe', until: '1.21' });
|
|
20
|
+
resource('structures', { category: 'structure', until: '1.21', ext: '.nbt' });
|
|
21
|
+
resource('tags/blocks', { category: 'tag/block', until: '1.21' });
|
|
22
|
+
resource('tags/entity_types', { category: 'tag/entity_type', until: '1.21' });
|
|
23
|
+
resource('tags/fluids', { category: 'tag/fluid', until: '1.21' });
|
|
24
|
+
resource('tags/functions', { category: 'tag/function', until: '1.21' });
|
|
25
|
+
resource('tags/game_events', { category: 'tag/game_event', since: '1.17', until: '1.21' });
|
|
26
|
+
resource('tags/items', { category: 'tag/item', until: '1.21' });
|
|
27
|
+
// Post-1.21 data pack non-plurals
|
|
28
|
+
resource('advancement', { since: '1.21' });
|
|
29
|
+
resource('function', { since: '1.21', ext: '.mcfunction' });
|
|
30
|
+
resource('item_modifier', { since: '1.21' });
|
|
31
|
+
resource('loot_table', { since: '1.21' });
|
|
32
|
+
resource('predicate', { since: '1.21' });
|
|
33
|
+
resource('recipe', { since: '1.21' });
|
|
34
|
+
resource('structure', { since: '1.21', ext: '.nbt' });
|
|
35
|
+
resource('tags/block', { category: 'tag/block', since: '1.21' });
|
|
36
|
+
resource('tags/entity_type', { category: 'tag/entity_type', since: '1.21' });
|
|
37
|
+
resource('tags/fluid', { category: 'tag/fluid', since: '1.21' });
|
|
38
|
+
resource('tags/function', { category: 'tag/function', since: '1.21' });
|
|
39
|
+
resource('tags/game_event', { category: 'tag/game_event', since: '1.21' });
|
|
40
|
+
resource('tags/item', { category: 'tag/item', since: '1.21' });
|
|
41
|
+
// Data pack
|
|
42
|
+
resource('banner_pattern', { since: '1.20.5' });
|
|
43
|
+
resource('chat_type', { since: '1.19' });
|
|
44
|
+
resource('damage_type', { since: '1.19.4' });
|
|
45
|
+
resource('enchantment', { since: '1.21' });
|
|
46
|
+
resource('enchantment_provider', { since: '1.21' });
|
|
47
|
+
resource('jukebox_song', { since: '1.21' });
|
|
48
|
+
resource('painting_variant', { since: '1.21' });
|
|
49
|
+
resource('trim_pattern', { since: '1.19.4' });
|
|
50
|
+
resource('trim_material', { since: '1.19.4' });
|
|
51
|
+
resource('wolf_variant', { since: '1.20.5' });
|
|
52
|
+
// Worldgen
|
|
53
|
+
resource('dimension', { since: '1.16' });
|
|
54
|
+
resource('dimension_type', { since: '1.16' });
|
|
55
|
+
resource('worldgen/biome', { since: '1.16.2' });
|
|
56
|
+
resource('worldgen/configured_carver', { since: '1.16.2' });
|
|
57
|
+
resource('worldgen/configured_feature', { since: '1.16.2' });
|
|
58
|
+
resource('worldgen/configured_structure_feature', { since: '1.16.2', until: '1.19' });
|
|
59
|
+
resource('worldgen/density_function', { since: '1.18.2' });
|
|
60
|
+
resource('worldgen/flat_level_generator_preset', { since: '1.19' });
|
|
61
|
+
resource('worldgen/multi_noise_biome_source_parameter_list', { since: '1.19.4' });
|
|
62
|
+
resource('worldgen/noise', { since: '1.18' });
|
|
63
|
+
resource('worldgen/noise_settings', { since: '1.16.2' });
|
|
64
|
+
resource('worldgen/placed_feature', { since: '1.18' });
|
|
65
|
+
resource('worldgen/processor_list', { since: '1.16.2' });
|
|
66
|
+
resource('worldgen/configured_surface_builder', { since: '1.16.2', until: '1.18' });
|
|
67
|
+
resource('worldgen/structure', { since: '1.19' });
|
|
68
|
+
resource('worldgen/structure_set', { since: '1.18.2' });
|
|
69
|
+
resource('worldgen/template_pool', { since: '1.16.2' });
|
|
70
|
+
resource('worldgen/world_preset', { since: '1.19' });
|
|
71
|
+
// Tags
|
|
72
|
+
const NonTaggableRegistries = new Set([
|
|
73
|
+
// Legacy plural paths
|
|
74
|
+
'block',
|
|
75
|
+
'fluid',
|
|
76
|
+
'function',
|
|
77
|
+
'game_event',
|
|
78
|
+
'item',
|
|
79
|
+
// Removed before 1.18
|
|
80
|
+
'worldgen/block_placer_type',
|
|
81
|
+
'worldgen/surface_builder',
|
|
82
|
+
]);
|
|
83
|
+
for (const registry of TaggableResourceLocationCategories) {
|
|
84
|
+
if (NonTaggableRegistries.has(registry)) {
|
|
85
|
+
continue;
|
|
128
86
|
}
|
|
129
|
-
|
|
130
|
-
}
|
|
87
|
+
resource(`tags/${registry}`, { category: `tag/${registry}`, since: '1.18' });
|
|
88
|
+
}
|
|
131
89
|
export function* getRels(uri, rootUris) {
|
|
132
90
|
yield* fileUtil.getRels(uri, rootUris);
|
|
133
91
|
const parts = uri.split('/');
|
|
134
92
|
for (let i = parts.length - 2; i >= 0; i--) {
|
|
135
|
-
if (parts[i] === 'data') {
|
|
93
|
+
if (parts[i] === 'data') { // TODO: support assets
|
|
136
94
|
yield parts.slice(i).join('/');
|
|
137
95
|
}
|
|
138
96
|
}
|
|
139
97
|
return undefined;
|
|
140
98
|
}
|
|
141
99
|
export function dissectUri(uri, ctx) {
|
|
142
|
-
const regex = /^data\/([^\/]+)\/((?:tags\/|worldgen\/)?[a-z_]+)\/(.*)(\.(?:mcfunction|json))$/;
|
|
143
100
|
const rels = getRels(uri, ctx.roots);
|
|
101
|
+
const release = ctx.project['loadedVersion'];
|
|
102
|
+
if (!release) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
144
105
|
for (const rel of rels) {
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
106
|
+
const parts = rel.split('/');
|
|
107
|
+
if (parts.length < 4) {
|
|
147
108
|
continue;
|
|
148
109
|
}
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
110
|
+
const [pack, namespace, ...rest] = parts;
|
|
111
|
+
if (pack !== 'data') {
|
|
112
|
+
continue; // TODO: support assets
|
|
113
|
+
}
|
|
114
|
+
let resource = undefined;
|
|
115
|
+
let matchIndex = 0;
|
|
116
|
+
for (let i = 1; i < rest.length; i += 1) {
|
|
117
|
+
const res = Resources.get(rest.slice(0, i).join('/'));
|
|
118
|
+
if (res) {
|
|
119
|
+
resource = res;
|
|
120
|
+
matchIndex = i;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (!resource) {
|
|
151
124
|
continue;
|
|
152
125
|
}
|
|
153
|
-
|
|
154
|
-
if (!
|
|
155
|
-
!matchVersion(loadedVersion, def.since, def.until)) {
|
|
126
|
+
let identifier = rest.slice(matchIndex).join('/');
|
|
127
|
+
if (!identifier.endsWith(resource.ext)) {
|
|
156
128
|
continue;
|
|
157
129
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
130
|
+
identifier = identifier.slice(0, -resource.ext.length);
|
|
131
|
+
if (!matchVersion(release, resource.since, resource.until)) {
|
|
132
|
+
let expected = undefined;
|
|
133
|
+
for (const [path, other] of Resources) {
|
|
134
|
+
if (other.category !== resource.category) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (matchVersion(release, other.since, other.until)) {
|
|
138
|
+
expected = path;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { ok: false, ...resource, namespace, identifier, expected };
|
|
143
|
+
}
|
|
144
|
+
return { ok: true, ...resource, namespace, identifier, expected: undefined };
|
|
163
145
|
}
|
|
164
146
|
return undefined;
|
|
165
147
|
}
|
|
@@ -167,21 +149,38 @@ export const uriBinder = (uris, ctx) => {
|
|
|
167
149
|
for (const uri of uris) {
|
|
168
150
|
const parts = dissectUri(uri, ctx);
|
|
169
151
|
if (parts) {
|
|
170
|
-
ctx.symbols
|
|
171
|
-
|
|
172
|
-
.enter({
|
|
173
|
-
usage: {
|
|
174
|
-
type: 'definition',
|
|
175
|
-
},
|
|
152
|
+
ctx.symbols.query(uri, parts.category, `${parts.namespace}:${parts.identifier}`).enter({
|
|
153
|
+
usage: { type: 'definition' },
|
|
176
154
|
});
|
|
177
155
|
}
|
|
178
156
|
}
|
|
179
157
|
};
|
|
158
|
+
export function registerCustomResources(config) {
|
|
159
|
+
for (const [path, res] of Object.entries(config.env.customResources)) {
|
|
160
|
+
if (res.pack === undefined || res.pack === 'data') {
|
|
161
|
+
resource(path, { ...res, category: res.category });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
180
165
|
function matchVersion(target, since, until) {
|
|
181
|
-
if (since && ReleaseVersion.cmp(target, since) < 0)
|
|
166
|
+
if (since && ReleaseVersion.cmp(target, since) < 0) {
|
|
182
167
|
return false;
|
|
183
|
-
|
|
168
|
+
}
|
|
169
|
+
if (until && ReleaseVersion.cmp(until, target) <= 0) {
|
|
184
170
|
return false;
|
|
171
|
+
}
|
|
185
172
|
return true;
|
|
186
173
|
}
|
|
174
|
+
export function reportDissectError(realPath, expectedPath, ctx) {
|
|
175
|
+
const release = ctx.project['loadedVersion'];
|
|
176
|
+
if (!release) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (expectedPath) {
|
|
180
|
+
ctx.err.report(localize('java-edition.binder.wrong-folder', localeQuote(realPath), release, localeQuote(expectedPath)), Range.Beginning, 0 /* ErrorSeverity.Hint */);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
ctx.err.report(localize('java-edition.binder.wrong-version', localeQuote(realPath), release), Range.Beginning, 0 /* ErrorSeverity.Hint */);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
187
186
|
//# sourceMappingURL=index.js.map
|
package/lib/common/index.js
CHANGED
|
@@ -4,27 +4,24 @@ import * as json from '@spyglassmc/json';
|
|
|
4
4
|
* @returns An array of URIs corresponding to the specified resource.
|
|
5
5
|
*/
|
|
6
6
|
export function getUris(category, id, ctx) {
|
|
7
|
-
return (ctx.symbols
|
|
8
|
-
|
|
9
|
-
.symbol?.definition?.map((v) => v.uri) ?? []);
|
|
7
|
+
return (ctx.symbols.query(ctx.doc, category, core.ResourceLocation.lengthen(id)).symbol
|
|
8
|
+
?.definition?.map((v) => v.uri) ?? []);
|
|
10
9
|
}
|
|
11
10
|
export function getTagValues(category, id, ctx) {
|
|
12
11
|
const resolveValueNode = (node) => json.JsonStringNode.is(node)
|
|
13
12
|
? node.value
|
|
14
|
-
: node.children.find((n) => n.key?.value === 'id')
|
|
15
|
-
.value.value;
|
|
13
|
+
: node.children.find((n) => n.key?.value === 'id').value.value;
|
|
16
14
|
const set = getUris(category, id, ctx).reduce((ans, uri) => {
|
|
17
15
|
// const result = ctx.getDocAndNode(uri)
|
|
18
16
|
const result = undefined; // FIXME: Use global symbol table to get the result
|
|
19
|
-
if (!result ||
|
|
20
|
-
result.node.parserErrors.length ||
|
|
21
|
-
result.node.checkerErrors?.length) {
|
|
17
|
+
if (!result || result.node.parserErrors.length || result.node.checkerErrors?.length) {
|
|
22
18
|
return ans;
|
|
23
19
|
}
|
|
24
20
|
// No errors in the node. We can assume it is a semantically correct tag file.
|
|
25
21
|
const rootNode = result.node.children[0];
|
|
26
22
|
const replaceNode = rootNode.children.find((n) => n.key?.value === 'replace')?.value;
|
|
27
|
-
const valuesNode = rootNode.children.find((n) => n.key?.value === 'values')
|
|
23
|
+
const valuesNode = rootNode.children.find((n) => n.key?.value === 'values')
|
|
24
|
+
?.value;
|
|
28
25
|
const replace = replaceNode?.value;
|
|
29
26
|
const values = valuesNode.children.map((n) => core.ResourceLocation.lengthen(resolveValueNode(n.value)));
|
|
30
27
|
if (replace) {
|
|
@@ -7,6 +7,11 @@ export declare namespace ReleaseVersion {
|
|
|
7
7
|
* * `1` if `a` is newer than `b`.
|
|
8
8
|
*/
|
|
9
9
|
function cmp(a: ReleaseVersion, b: ReleaseVersion): number;
|
|
10
|
+
/**
|
|
11
|
+
* @returns `true` if `version` is newer than `since` (inclusive) and older
|
|
12
|
+
* than `until` (exclusive)
|
|
13
|
+
*/
|
|
14
|
+
function isBetween(version: ReleaseVersion, since: ReleaseVersion, until: ReleaseVersion): boolean;
|
|
10
15
|
}
|
|
11
16
|
export interface VersionInfo {
|
|
12
17
|
release: ReleaseVersion;
|
package/lib/dependency/common.js
CHANGED
|
@@ -10,6 +10,14 @@ export var ReleaseVersion;
|
|
|
10
10
|
return Math.sign(Number(a.slice(2)) - Number(b.slice(2)));
|
|
11
11
|
}
|
|
12
12
|
ReleaseVersion.cmp = cmp;
|
|
13
|
+
/**
|
|
14
|
+
* @returns `true` if `version` is newer than `since` (inclusive) and older
|
|
15
|
+
* than `until` (exclusive)
|
|
16
|
+
*/
|
|
17
|
+
function isBetween(version, since, until) {
|
|
18
|
+
return cmp(version, since) >= 0 && cmp(version, until) < 0;
|
|
19
|
+
}
|
|
20
|
+
ReleaseVersion.isBetween = isBetween;
|
|
13
21
|
})(ReleaseVersion || (ReleaseVersion = {}));
|
|
14
22
|
export var PackMcmeta;
|
|
15
23
|
(function (PackMcmeta) {
|
package/lib/dependency/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './common.js';
|
|
|
2
2
|
export * from './mcmeta.js';
|
|
3
3
|
import * as core from '@spyglassmc/core';
|
|
4
4
|
import { Fluids, getMcmetaSummaryUris } from './mcmeta.js';
|
|
5
|
+
// Memory cache TTL in milliseconds
|
|
5
6
|
const DownloaderTtl = 15_000;
|
|
6
7
|
/* istanbul ignore next */
|
|
7
8
|
/**
|
|
@@ -70,16 +71,11 @@ export async function getMcmetaSummary(externals, downloader, logger, version, i
|
|
|
70
71
|
];
|
|
71
72
|
return { blocks, commands, fluids, registries, checksum };
|
|
72
73
|
}
|
|
73
|
-
function getGitRef({ defaultBranch, getTag, isLatest, version
|
|
74
|
-
return isLatest
|
|
75
|
-
? `refs/heads/${defaultBranch}`
|
|
76
|
-
: `refs/tags/${getTag(version)}`;
|
|
74
|
+
function getGitRef({ defaultBranch, getTag, isLatest, version }) {
|
|
75
|
+
return isLatest ? `refs/heads/${defaultBranch}` : `refs/tags/${getTag(version)}`;
|
|
77
76
|
}
|
|
78
77
|
const GitHubApiDownloadOptions = {
|
|
79
|
-
headers: {
|
|
80
|
-
Accept: 'application/vnd.github.v3+json',
|
|
81
|
-
'User-Agent': 'SpyglassMC',
|
|
82
|
-
},
|
|
78
|
+
headers: { Accept: 'application/vnd.github.v3+json', 'User-Agent': 'SpyglassMC' },
|
|
83
79
|
};
|
|
84
80
|
function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
|
|
85
81
|
return {
|
|
@@ -111,7 +107,7 @@ function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
|
|
|
111
107
|
*
|
|
112
108
|
* @returns The URI to the `.tar.gz` file.
|
|
113
109
|
*/
|
|
114
|
-
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version
|
|
110
|
+
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version }) {
|
|
115
111
|
const ref = getGitRef({ defaultBranch, getTag, isLatest, version });
|
|
116
112
|
const out = {};
|
|
117
113
|
await downloader.download({
|
|
@@ -142,10 +138,7 @@ export async function getVanillaDatapack(downloader, version, isLatest) {
|
|
|
142
138
|
isLatest,
|
|
143
139
|
version,
|
|
144
140
|
});
|
|
145
|
-
return {
|
|
146
|
-
info: { startDepth: 1 },
|
|
147
|
-
uri,
|
|
148
|
-
};
|
|
141
|
+
return { info: { startDepth: 1 }, uri };
|
|
149
142
|
}
|
|
150
143
|
/**
|
|
151
144
|
* @throws Network/file system errors.
|
|
@@ -167,9 +160,6 @@ export async function getVanillaMcdoc(downloader) {
|
|
|
167
160
|
options: GitHubApiDownloadOptions,
|
|
168
161
|
ttl: DownloaderTtl,
|
|
169
162
|
}, out);
|
|
170
|
-
return {
|
|
171
|
-
info: { startDepth: 1 },
|
|
172
|
-
uri: out.cacheUri,
|
|
173
|
-
};
|
|
163
|
+
return { info: { startDepth: 1 }, uri: out.cacheUri };
|
|
174
164
|
}
|
|
175
165
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,10 +3,7 @@ import type { PackMcmeta, VersionInfo } from './common.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
5
5
|
*/
|
|
6
|
-
export declare function resolveConfiguredVersion(inputVersion: string,
|
|
7
|
-
packMcmeta: PackMcmeta | undefined;
|
|
8
|
-
versions: McmetaVersions;
|
|
9
|
-
}): VersionInfo;
|
|
6
|
+
export declare function resolveConfiguredVersion(inputVersion: string, versions: McmetaVersions, getPackMcmeta: () => Promise<PackMcmeta | undefined>): Promise<VersionInfo>;
|
|
10
7
|
export declare function getMcmetaSummaryUris(version: string, isLatest: boolean, source: string): {
|
|
11
8
|
blocks: core.RemoteUriString;
|
|
12
9
|
commands: core.RemoteUriString;
|
|
@@ -36,14 +33,11 @@ export interface McmetaSummary {
|
|
|
36
33
|
registries: McmetaRegistries;
|
|
37
34
|
}
|
|
38
35
|
export interface McmetaStates {
|
|
39
|
-
[id: string]: [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[name: string]: string;
|
|
45
|
-
}
|
|
46
|
-
];
|
|
36
|
+
[id: string]: [{
|
|
37
|
+
[name: string]: string[];
|
|
38
|
+
}, {
|
|
39
|
+
[name: string]: string;
|
|
40
|
+
}];
|
|
47
41
|
}
|
|
48
42
|
export type McmetaCommands = RootTreeNode;
|
|
49
43
|
interface BaseTreeNode {
|