@spyglassmc/java-edition 0.1.1 → 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.
Files changed (87) hide show
  1. package/lib/binder/index.d.ts +3 -3
  2. package/lib/binder/index.js +11 -17
  3. package/lib/common/index.js +4 -28
  4. package/lib/dependency/common.d.ts +8 -5
  5. package/lib/dependency/common.js +18 -18
  6. package/lib/dependency/index.d.ts +6 -6
  7. package/lib/dependency/index.js +21 -48
  8. package/lib/dependency/mcmeta.d.ts +2 -3
  9. package/lib/dependency/mcmeta.js +28 -100
  10. package/lib/index.d.ts +3 -3
  11. package/lib/index.js +27 -50
  12. package/lib/json/checker/data/advancement.d.ts +13 -13
  13. package/lib/json/checker/data/advancement.js +259 -262
  14. package/lib/json/checker/data/biome.d.ts +3 -3
  15. package/lib/json/checker/data/biome.js +98 -101
  16. package/lib/json/checker/data/common.d.ts +2 -2
  17. package/lib/json/checker/data/common.js +145 -152
  18. package/lib/json/checker/data/dimension.d.ts +3 -3
  19. package/lib/json/checker/data/dimension.js +148 -151
  20. package/lib/json/checker/data/feature.d.ts +8 -8
  21. package/lib/json/checker/data/feature.js +369 -372
  22. package/lib/json/checker/data/index.d.ts +2 -2
  23. package/lib/json/checker/data/index.js +36 -39
  24. package/lib/json/checker/data/loot_table.d.ts +7 -7
  25. package/lib/json/checker/data/loot_table.js +125 -128
  26. package/lib/json/checker/data/recipe.d.ts +1 -1
  27. package/lib/json/checker/data/recipe.js +25 -28
  28. package/lib/json/checker/data/structure.d.ts +7 -7
  29. package/lib/json/checker/data/structure.js +80 -83
  30. package/lib/json/checker/data/tag.js +23 -26
  31. package/lib/json/checker/data/text_component.d.ts +1 -1
  32. package/lib/json/checker/data/text_component.js +61 -64
  33. package/lib/json/checker/index.js +14 -19
  34. package/lib/json/checker/util/advancement.d.ts +1 -1
  35. package/lib/json/checker/util/advancement.js +4 -8
  36. package/lib/json/checker/util/block_states.d.ts +1 -1
  37. package/lib/json/checker/util/block_states.js +21 -45
  38. package/lib/json/checker/util/color.d.ts +1 -1
  39. package/lib/json/checker/util/color.js +20 -25
  40. package/lib/json/checker/util/index.d.ts +7 -7
  41. package/lib/json/checker/util/index.js +7 -19
  42. package/lib/json/checker/util/nbt.d.ts +2 -3
  43. package/lib/json/checker/util/nbt.js +17 -22
  44. package/lib/json/checker/util/recipe.d.ts +1 -1
  45. package/lib/json/checker/util/recipe.js +4 -8
  46. package/lib/json/checker/util/uuid.d.ts +1 -1
  47. package/lib/json/checker/util/uuid.js +4 -7
  48. package/lib/json/checker/util/version.d.ts +13 -13
  49. package/lib/json/checker/util/version.js +7 -13
  50. package/lib/json/index.d.ts +1 -1
  51. package/lib/json/index.js +4 -27
  52. package/lib/mcfunction/checker/index.d.ts +1 -1
  53. package/lib/mcfunction/checker/index.js +79 -103
  54. package/lib/mcfunction/colorizer/index.d.ts +1 -1
  55. package/lib/mcfunction/colorizer/index.js +6 -31
  56. package/lib/mcfunction/common/index.js +7 -29
  57. package/lib/mcfunction/completer/argument.js +95 -119
  58. package/lib/mcfunction/completer/index.d.ts +1 -1
  59. package/lib/mcfunction/completer/index.js +1 -13
  60. package/lib/mcfunction/index.d.ts +6 -6
  61. package/lib/mcfunction/index.js +19 -54
  62. package/lib/mcfunction/inlayHintProvider.js +3 -26
  63. package/lib/mcfunction/node/argument.d.ts +3 -3
  64. package/lib/mcfunction/node/argument.js +47 -69
  65. package/lib/mcfunction/node/index.d.ts +1 -1
  66. package/lib/mcfunction/node/index.js +1 -13
  67. package/lib/mcfunction/parser/argument.d.ts +1 -1
  68. package/lib/mcfunction/parser/argument.js +76 -101
  69. package/lib/mcfunction/parser/index.d.ts +1 -1
  70. package/lib/mcfunction/parser/index.js +1 -13
  71. package/lib/mcfunction/signatureHelpProvider.js +3 -26
  72. package/lib/mcfunction/tree/argument.js +1 -2
  73. package/lib/mcfunction/tree/index.d.ts +1 -6
  74. package/lib/mcfunction/tree/index.js +1 -18
  75. package/lib/mcfunction/tree/patch.d.ts +4 -0
  76. package/lib/mcfunction/tree/patch.js +748 -0
  77. package/package.json +8 -7
  78. package/lib/mcfunction/tree/1.15.d.ts +0 -9
  79. package/lib/mcfunction/tree/1.15.js +0 -542
  80. package/lib/mcfunction/tree/1.16.d.ts +0 -10
  81. package/lib/mcfunction/tree/1.16.js +0 -77
  82. package/lib/mcfunction/tree/1.17.d.ts +0 -12
  83. package/lib/mcfunction/tree/1.17.js +0 -166
  84. package/lib/mcfunction/tree/1.18.d.ts +0 -26
  85. package/lib/mcfunction/tree/1.18.js +0 -6
  86. package/lib/mcfunction/tree/1.19.d.ts +0 -26
  87. package/lib/mcfunction/tree/1.19.js +0 -6
@@ -2,12 +2,12 @@ import type { ContextBase, FileCategory, RootUriString, UriBinder } from '@spygl
2
2
  export declare const Categories: Map<string, {
3
3
  category: FileCategory;
4
4
  extname: string;
5
- since?: `1.${bigint}` | undefined;
6
- until?: `1.${bigint}` | undefined;
5
+ since?: `1.${number}` | undefined;
6
+ until?: `1.${number}` | undefined;
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" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure";
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;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uriBinder = exports.dissectUri = exports.getRels = exports.Categories = void 0;
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 core_1.RegistryCategories) {
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* core_1.fileUtil.getRels(uri, rootUris);
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
- exports.getRels = getRels;
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 = exports.Categories.get(match[2]);
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
- exports.dissectUri = dissectUri;
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 && dependency_1.MajorVersion.cmp(target, since) < 0)
90
+ if (since && ReleaseVersion.cmp(target, since) < 0)
97
91
  return false;
98
- if (until && dependency_1.MajorVersion.cmp(until, target) < 0)
92
+ if (until && ReleaseVersion.cmp(until, target) < 0)
99
93
  return false;
100
94
  return true;
101
95
  }
@@ -1,37 +1,14 @@
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.getTagValues = exports.getUris = void 0;
23
- const core = __importStar(require("@spyglassmc/core"));
24
- const json = __importStar(require("@spyglassmc/json"));
1
+ import * as core from '@spyglassmc/core';
2
+ import * as json from '@spyglassmc/json';
25
3
  /**
26
4
  * @returns An array of URIs corresponding to the specified resource.
27
5
  */
28
- function getUris(category, id, ctx) {
6
+ export function getUris(category, id, ctx) {
29
7
  return ctx.symbols
30
8
  .query(ctx.doc, category, core.ResourceLocation.lengthen(id))
31
9
  .symbol?.definition?.map(v => v.uri) ?? [];
32
10
  }
33
- exports.getUris = getUris;
34
- function getTagValues(category, id, ctx) {
11
+ export function getTagValues(category, id, ctx) {
35
12
  const resolveValueNode = (node) => json.JsonStringNode.is(node)
36
13
  ? node.value
37
14
  : node.children.find(n => n.key?.value === 'id').value.value;
@@ -56,5 +33,4 @@ function getTagValues(category, id, ctx) {
56
33
  }, new Set());
57
34
  return [...set];
58
35
  }
59
- exports.getTagValues = getTagValues;
60
36
  //# sourceMappingURL=index.js.map
@@ -1,20 +1,23 @@
1
- export declare type MajorVersion = `1.${bigint}`;
2
- export declare namespace MajorVersion {
1
+ export declare type ReleaseVersion = `1.${number}`;
2
+ export declare namespace ReleaseVersion {
3
3
  /**
4
4
  * @returns
5
5
  * * `-1` if `a` is older than `b`.
6
6
  * * `0` if `a` is the same as `b`.
7
7
  * * `1` if `a` is newer than `b`.
8
8
  */
9
- function cmp(a: MajorVersion, b: MajorVersion): number;
9
+ function cmp(a: ReleaseVersion, b: ReleaseVersion): number;
10
10
  }
11
11
  export interface VersionInfo {
12
- major: MajorVersion;
12
+ release: ReleaseVersion;
13
13
  id: string;
14
14
  name: string;
15
15
  isLatest: boolean;
16
16
  }
17
- export declare const PackVersionMap: Record<number, MajorVersion | undefined>;
17
+ /**
18
+ * A map from `pack_format` numbers to a RegExp. The latest version whose `release_target` matches the RegExp should be used.
19
+ */
20
+ export declare const PackVersionMap: Record<number, RegExp | undefined>;
18
21
  export interface PackMcmeta {
19
22
  pack: {
20
23
  pack_format: number;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PackMcmeta = exports.PackVersionMap = exports.MajorVersion = void 0;
4
- var MajorVersion;
5
- (function (MajorVersion) {
1
+ export var ReleaseVersion;
2
+ (function (ReleaseVersion) {
6
3
  /**
7
4
  * @returns
8
5
  * * `-1` if `a` is older than `b`.
@@ -10,30 +7,33 @@ var MajorVersion;
10
7
  * * `1` if `a` is newer than `b`.
11
8
  */
12
9
  function cmp(a, b) {
13
- return Math.sign(Number(a) - Number(b));
10
+ return Math.sign(Number(a.slice(2)) - Number(b.slice(2)));
14
11
  }
15
- MajorVersion.cmp = cmp;
16
- })(MajorVersion = exports.MajorVersion || (exports.MajorVersion = {}));
12
+ ReleaseVersion.cmp = cmp;
13
+ })(ReleaseVersion || (ReleaseVersion = {}));
17
14
  // DOCS: Update here when format_version is changed.
18
- exports.PackVersionMap = {
19
- 5: '1.15',
20
- 6: '1.16',
21
- 7: '1.17',
22
- 8: '1.18',
23
- 9: '1.18',
24
- 10: '1.19',
15
+ /**
16
+ * A map from `pack_format` numbers to a RegExp. The latest version whose `release_target` matches the RegExp should be used.
17
+ */
18
+ export const PackVersionMap = {
19
+ 5: /^1\.15.*$/,
20
+ 6: /^1\.16.*$/,
21
+ 7: /^1\.17.*$/,
22
+ 8: /^1\.18(\.1)?$/,
23
+ 9: /^1\.18.*$/,
24
+ 10: /^1\.19.*$/,
25
25
  };
26
- var PackMcmeta;
26
+ export var PackMcmeta;
27
27
  (function (PackMcmeta) {
28
28
  function assert(data) {
29
29
  const format = data?.pack?.pack_format?.toString();
30
30
  if (!format) {
31
31
  throw new Error('“pack.pack_format” undefined');
32
32
  }
33
- if (!Object.keys(exports.PackVersionMap).includes(format)) {
33
+ if (!Object.keys(PackVersionMap).includes(format)) {
34
34
  throw new Error(`Unknown pack_format “${format}”`);
35
35
  }
36
36
  }
37
37
  PackMcmeta.assert = assert;
38
- })(PackMcmeta = exports.PackMcmeta || (exports.PackMcmeta = {}));
38
+ })(PackMcmeta || (PackMcmeta = {}));
39
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,7 +16,7 @@ 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
21
  * @param version An already resolved version identifier.
22
22
  *
@@ -26,5 +26,5 @@ export declare function getMcmetaSummary(downloader: core.Downloader, logger: co
26
26
  * - `startDepth`: The amount of level to skip when unzipping the tarball.
27
27
  * - `uri`: URI to the `.tar.gz` file.
28
28
  */
29
- export declare function getMcNbtdoc(downloader: core.Downloader, version: string, isLatest: boolean): Promise<core.Dependency>;
29
+ export declare function getVanillaMcdoc(externals: core.Externals, downloader: core.Downloader, version: string, isLatest: boolean): Promise<core.Dependency>;
30
30
  //# sourceMappingURL=index.d.ts.map
@@ -1,32 +1,7 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- var __importStar = (this && this.__importStar) || function (mod) {
18
- if (mod && mod.__esModule) return mod;
19
- var result = {};
20
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
- __setModuleDefault(result, mod);
22
- return result;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.getMcNbtdoc = exports.getMcmetaSummary = exports.getVersions = void 0;
26
- __exportStar(require("./common"), exports);
27
- __exportStar(require("./mcmeta"), exports);
28
- const core = __importStar(require("@spyglassmc/core"));
29
- 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';
30
5
  const DownloaderTtl = 15000;
31
6
  /* istanbul ignore next */
32
7
  /**
@@ -34,35 +9,34 @@ const DownloaderTtl = 15000;
34
9
  *
35
10
  * [versions.json]: https://github.com/misode/mcmeta/blob/summary/versions/data.json
36
11
  */
37
- async function getVersions(downloader) {
12
+ export async function getVersions(externals, downloader) {
38
13
  return downloader.download({
39
14
  id: 'mc-je/versions.json.gz',
40
15
  uri: 'https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json.gz',
41
- transformer: buffer => core.parseGzippedJson(buffer),
16
+ transformer: buffer => core.parseGzippedJson(externals, buffer),
42
17
  cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', 'refs/heads/summary'),
43
18
  ttl: DownloaderTtl,
44
19
  });
45
20
  }
46
- exports.getVersions = getVersions;
47
21
  /* istanbul ignore next */
48
22
  /**
49
23
  * Get vanilla resources, including block definitions, fluid definitions, command tree, and registries.
50
24
  *
51
25
  * @throws Network/file system errors.
52
26
  */
53
- async function getMcmetaSummary(downloader, logger, version, isLatest, source, overridePaths = {}) {
27
+ export async function getMcmetaSummary(externals, downloader, logger, version, isLatest, source, overridePaths = {}) {
54
28
  const ref = getGitRef({
55
29
  defaultBranch: 'summary',
56
30
  getTag: v => `${v}-summary`,
57
31
  isLatest,
58
32
  version,
59
33
  });
60
- const uris = (0, mcmeta_1.getMcmetaSummaryUris)(version, isLatest, source);
34
+ const uris = getMcmetaSummaryUris(version, isLatest, source);
61
35
  let checksum;
62
- const handleOverride = async (currentValue, overrideConfig) => {
36
+ async function handleOverride(currentValue, overrideConfig) {
63
37
  if (overrideConfig) {
64
38
  try {
65
- const override = await core.fileUtil.readJson(core.fileUtil.pathToFileUri(overrideConfig.path));
39
+ const override = await core.fileUtil.readJson(externals, overrideConfig.path);
66
40
  if (overrideConfig.replace) {
67
41
  return override;
68
42
  }
@@ -75,28 +49,27 @@ async function getMcmetaSummary(downloader, logger, version, isLatest, source, o
75
49
  }
76
50
  }
77
51
  return currentValue;
78
- };
52
+ }
79
53
  const getResource = async (type, overrideConfig) => {
80
54
  const out = {};
81
55
  const data = await downloader.download({
82
56
  id: `mc-je/${version}/${type}.json.gz`,
83
57
  uri: uris[type],
84
- transformer: buffer => core.parseGzippedJson(buffer),
58
+ transformer: buffer => core.parseGzippedJson(externals, buffer),
85
59
  cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', ref),
86
60
  ttl: DownloaderTtl,
87
61
  }, out);
88
- checksum || (checksum = out.checksum);
62
+ checksum ||= out.checksum;
89
63
  return handleOverride(data, overrideConfig);
90
64
  };
91
65
  const [blocks, commands, fluids, registries] = [
92
66
  await getResource('blocks', overridePaths.blocks),
93
67
  await getResource('commands', overridePaths.commands),
94
- await handleOverride(mcmeta_1.Fluids, overridePaths.fluids),
68
+ await handleOverride(Fluids, overridePaths.fluids),
95
69
  await getResource('registries', overridePaths.registries),
96
70
  ];
97
71
  return { blocks, commands, fluids, registries, checksum };
98
72
  }
99
- exports.getMcmetaSummary = getMcmetaSummary;
100
73
  function getGitRef({ defaultBranch, getTag, isLatest, version }) {
101
74
  return isLatest ? `refs/heads/${defaultBranch}` : `refs/tags/${getTag(version)}`;
102
75
  }
@@ -131,7 +104,7 @@ function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
131
104
  /**
132
105
  * @returns The URI to the `.tar.gz` file.
133
106
  */
134
- async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version }) {
107
+ async function downloadGitHubRepo({ defaultBranch, downloader, externals, getTag, repo, isLatest, owner, version }) {
135
108
  const ref = getGitRef({ defaultBranch, getTag, isLatest, version });
136
109
  const out = {};
137
110
  await downloader.download({
@@ -142,7 +115,7 @@ async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isL
142
115
  options: GitHubApiDownloadOptions,
143
116
  ttl: DownloaderTtl,
144
117
  }, out);
145
- return core.fileUtil.pathToFileUri(out.cachePath);
118
+ return out.cacheUri;
146
119
  }
147
120
  /* istanbul ignore next */
148
121
  /**
@@ -154,19 +127,19 @@ async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isL
154
127
  * - `startDepth`: The amount of level to skip when unzipping the tarball.
155
128
  * - `uri`: URI to the `.tar.gz` file.
156
129
  */
157
- async function getMcNbtdoc(downloader, version, isLatest) {
130
+ export async function getVanillaMcdoc(externals, downloader, version, isLatest) {
158
131
  return {
159
132
  info: { startDepth: 1 },
160
133
  uri: await downloadGitHubRepo({
161
- defaultBranch: 'master',
134
+ defaultBranch: 'main',
162
135
  downloader,
136
+ externals,
163
137
  getTag: v => v,
164
138
  isLatest,
165
- owner: 'Yurihaia',
166
- repo: 'mc-nbtdoc',
139
+ owner: 'SpyglassMC',
140
+ repo: 'vanila-mcdoc',
167
141
  version,
168
142
  }),
169
143
  };
170
144
  }
171
- exports.getMcNbtdoc = getMcNbtdoc;
172
145
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,7 @@
1
1
  import * as core from '@spyglassmc/core';
2
- import type { MajorVersion, PackMcmeta, VersionInfo } from './common';
3
- export declare function getMajorVersion(version: McmetaVersion): MajorVersion;
2
+ import type { PackMcmeta, VersionInfo } from './common.js';
4
3
  /**
5
- * @param inputVersion {@link Config.env.gameVersion}
4
+ * @param inputVersion {@link core.Config.env.gameVersion}
6
5
  */
7
6
  export declare function resolveConfiguredVersion(inputVersion: string, { packMcmeta, versions }: {
8
7
  packMcmeta: PackMcmeta | undefined;
@@ -1,36 +1,9 @@
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.Fluids = exports.symbolRegistrar = exports.getMcmetaSummaryUris = exports.resolveConfiguredVersion = exports.getMajorVersion = void 0;
23
- const core = __importStar(require("@spyglassmc/core"));
24
- const common_1 = require("./common");
25
- function getMajorVersion(version) {
26
- const dotIndex = version.release_target.indexOf('.', 2);
27
- return (dotIndex > 2 ? version.release_target.slice(0, dotIndex) : version.release_target);
28
- }
29
- exports.getMajorVersion = getMajorVersion;
1
+ import * as core from '@spyglassmc/core';
2
+ import { PackVersionMap } from './common.js';
30
3
  /**
31
- * @param inputVersion {@link Config.env.gameVersion}
4
+ * @param inputVersion {@link core.Config.env.gameVersion}
32
5
  */
33
- function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
6
+ export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
34
7
  function toVersionInfo(index) {
35
8
  if (index < 0) {
36
9
  index = 0;
@@ -39,7 +12,7 @@ function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
39
12
  return {
40
13
  id: version.id,
41
14
  name: version.name,
42
- major: getMajorVersion(version),
15
+ release: version.release_target,
43
16
  isLatest: index === 0,
44
17
  };
45
18
  }
@@ -50,9 +23,9 @@ function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
50
23
  versions = versions.sort((a, b) => b.data_version - a.data_version);
51
24
  if (inputVersion === 'auto') {
52
25
  if (packMcmeta) {
53
- const major = common_1.PackVersionMap[packMcmeta.pack.pack_format];
54
- if (major) {
55
- return toVersionInfo(versions.findIndex(v => getMajorVersion(v) === major));
26
+ const regex = PackVersionMap[packMcmeta.pack.pack_format];
27
+ if (regex) {
28
+ return toVersionInfo(versions.findIndex(v => regex.test(v.release_target)));
56
29
  }
57
30
  }
58
31
  return toVersionInfo(0);
@@ -65,13 +38,24 @@ function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
65
38
  }
66
39
  return toVersionInfo(versions.findIndex(v => inputVersion === v.id.toLowerCase() || inputVersion === v.name.toLowerCase()));
67
40
  }
68
- exports.resolveConfiguredVersion = resolveConfiguredVersion;
69
- function getMcmetaSummaryUris(version, isLatest, source) {
41
+ const DataSources = {
42
+ fastly: 'https://fastly.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}',
43
+ github: 'https://raw.githubusercontent.com/${user}/${repo}/${tag}/${path}',
44
+ jsdelivr: 'https://cdn.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}',
45
+ };
46
+ export function getMcmetaSummaryUris(version, isLatest, source) {
70
47
  const tag = isLatest ? 'summary' : `${version}-summary`;
71
48
  function getUri(path) {
72
- return source.toLowerCase() === 'jsdelivr'
73
- ? `https://cdn.jsdelivr.net/gh/misode/mcmeta@${tag}/${path}`
74
- : `https://raw.githubusercontent.com/misode/mcmeta/${tag}/${path}`;
49
+ const template = DataSources[source.toLowerCase()] ?? source;
50
+ const ans = template
51
+ .replace(/\${user}/g, 'misode')
52
+ .replace(/\${repo}/g, 'mcmeta')
53
+ .replace(/\${tag}/g, tag)
54
+ .replace(/\${path}/g, path);
55
+ if (!core.RemoteUriString.is(ans)) {
56
+ throw new Error(`Expected a remote URI from data source template but got ${ans}`);
57
+ }
58
+ return ans;
75
59
  }
76
60
  return {
77
61
  blocks: getUri('blocks/data.json.gz'),
@@ -79,19 +63,15 @@ function getMcmetaSummaryUris(version, isLatest, source) {
79
63
  registries: getUri('registries/data.json.gz'),
80
64
  };
81
65
  }
82
- exports.getMcmetaSummaryUris = getMcmetaSummaryUris;
83
- function symbolRegistrar(summary) {
66
+ export function symbolRegistrar(summary) {
84
67
  const McmetaSummaryUri = 'mcmeta://summary/registries.json';
85
- const SoundsBaseUri = 'https://misode.github.io/sounds/';
86
- const WikiBaseUri = 'https://minecraft.fandom.com/wiki/';
87
- const getWikiPageName = (id) => id === 'empty' ? 'Air' : id.split('_').map(v => `${v.charAt(0).toUpperCase()}${v.slice(1)}`).join('_');
88
68
  /**
89
69
  * Add states of blocks or fluids to the symbol table.
90
70
  */
91
71
  function addStatesSymbols(category, states, symbols) {
92
72
  const capitalizedCategory = `${category[0].toUpperCase()}${category.slice(1)}`;
93
73
  for (const [id, [properties, defaults]] of Object.entries(states)) {
94
- const uri = `${WikiBaseUri}${getWikiPageName(id)}`;
74
+ const uri = McmetaSummaryUri;
95
75
  symbols
96
76
  .query(uri, category, core.ResourceLocation.lengthen(id))
97
77
  .onEach(Object.entries(properties), ([state, values], blockQuery) => {
@@ -127,62 +107,11 @@ function symbolRegistrar(summary) {
127
107
  function isCategory(str) {
128
108
  return (core.FileCategories.includes(str) || core.RegistryCategories.includes(str));
129
109
  }
130
- const getUri = (registryId, entryId) => {
131
- /* istanbul ignore next */
132
- switch (registryId) {
133
- case 'attribute':
134
- return `${WikiBaseUri}Attribute#Attributes`;
135
- case 'block':
136
- case 'enchantment':
137
- case 'entity_type':
138
- case 'fluid':
139
- case 'item':
140
- case 'mob_effect':
141
- return `${WikiBaseUri}${getWikiPageName(entryId)}`;
142
- case 'block_entity_type':
143
- return `${WikiBaseUri}${getWikiPageName(entryId)}#Block_data`;
144
- case 'custom_stat':
145
- return `${WikiBaseUri}Statistics#List_of_custom_statistic_names`;
146
- case 'game_event':
147
- return `${WikiBaseUri}Game_event`;
148
- case 'loot_condition_type':
149
- return `${WikiBaseUri}Predicate#JSON_structure`;
150
- case 'loot_function_type':
151
- return `${WikiBaseUri}Item_modifier#JSON_structure`;
152
- case 'loot_number_provider_type':
153
- case 'loot_score_provider_type':
154
- return `${WikiBaseUri}Loot_table#Number_Providers`;
155
- case 'loot_pool_entry_type':
156
- return `${WikiBaseUri}Loot_table#Tags`;
157
- case 'motive':
158
- return `${WikiBaseUri}Painting#Canvases`;
159
- case 'potion':
160
- return `${WikiBaseUri}Potion#Item_data`;
161
- case 'particle_type':
162
- return `${WikiBaseUri}Java_Edition_data_values#Particles`;
163
- case 'recipe_serializer':
164
- return `${WikiBaseUri}Recipe#${entryId}`;
165
- case 'sound_event':
166
- return `${SoundsBaseUri}?sound=${entryId}`;
167
- case 'stat_type':
168
- return `${WikiBaseUri}Statistics#Statistic_types_and_names`;
169
- case 'villager_profession':
170
- return `${WikiBaseUri}Villager#Villager_profession`;
171
- case 'villager_type':
172
- return `${WikiBaseUri}Villager#Villager_type`;
173
- case 'worldgen/biome_source':
174
- return `${WikiBaseUri}Java_Edition_data_values#Biome_sources`;
175
- case 'worldgen/chunk_generator':
176
- return `${WikiBaseUri}Java_Edition_data_values#Chunk_generators`;
177
- default:
178
- return McmetaSummaryUri;
179
- }
180
- };
181
110
  for (const [registryId, registry] of Object.entries(registries)) {
182
111
  if (isCategory(registryId)) {
183
112
  for (const entryId of registry) {
184
113
  symbols
185
- .query(getUri(registryId, entryId), registryId, core.ResourceLocation.lengthen(entryId))
114
+ .query(McmetaSummaryUri, registryId, core.ResourceLocation.lengthen(entryId))
186
115
  .enter({ usage: { type: 'declaration' } });
187
116
  }
188
117
  }
@@ -194,8 +123,7 @@ function symbolRegistrar(summary) {
194
123
  addStatesSymbols('fluid', summary.fluids, symbols);
195
124
  };
196
125
  }
197
- exports.symbolRegistrar = symbolRegistrar;
198
- exports.Fluids = {
126
+ export const Fluids = {
199
127
  flowing_lava: [{ falling: ['false', 'true'], level: ['1', '2', '3', '4', '5', '6', '7', '8'] }, { falling: 'false', level: '1' }],
200
128
  flowing_water: [{ falling: ['false', 'true'], level: ['1', '2', '3', '4', '5', '6', '7', '8'] }, { falling: 'false', level: '1' }],
201
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