@spyglassmc/java-edition 0.3.25 → 0.3.27
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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type { CheckerContext, Config, RootUriString, UriBinder, UriBinderContext } from '@spyglassmc/core';
|
|
1
|
+
import type { CheckerContext, Config, FileCategory, MetaRegistry, RootUriString, UriBinder, UriBinderContext } from '@spyglassmc/core';
|
|
2
|
+
import { ReleaseVersion } from '../dependency/index.js';
|
|
3
|
+
interface Resource {
|
|
4
|
+
path: string;
|
|
5
|
+
category: FileCategory;
|
|
6
|
+
ext: `.${string}`;
|
|
7
|
+
pack: 'data' | 'assets';
|
|
8
|
+
identifier?: string;
|
|
9
|
+
since?: ReleaseVersion;
|
|
10
|
+
until?: ReleaseVersion;
|
|
11
|
+
}
|
|
12
|
+
export declare function getResources(): Generator<Resource, undefined, undefined>;
|
|
2
13
|
export declare function getRels(uri: string, rootUris: readonly RootUriString[]): Generator<string, undefined, unknown>;
|
|
14
|
+
export declare function getRoots(uri: string, rootUris: readonly RootUriString[]): Generator<RootUriString, undefined, unknown>;
|
|
3
15
|
export declare function dissectUri(uri: string, ctx: UriBinderContext): {
|
|
4
16
|
namespace: string;
|
|
5
17
|
identifier: string;
|
|
@@ -15,4 +27,6 @@ export declare function dissectUri(uri: string, ctx: UriBinderContext): {
|
|
|
15
27
|
export declare const uriBinder: UriBinder;
|
|
16
28
|
export declare function registerCustomResources(config: Config): void;
|
|
17
29
|
export declare function reportDissectError(realPath: string, expectedPath: string | undefined, ctx: CheckerContext): void;
|
|
30
|
+
export declare function registerUriBuilders(meta: MetaRegistry): void;
|
|
31
|
+
export {};
|
|
18
32
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/binder/index.js
CHANGED
|
@@ -127,6 +127,12 @@ resource('', {
|
|
|
127
127
|
identifier: 'regional_compliancies',
|
|
128
128
|
});
|
|
129
129
|
resource('', { pack: 'assets', category: 'gpu_warnlist', identifier: 'gpu_warnlist' });
|
|
130
|
+
export function* getResources() {
|
|
131
|
+
for (const resources of Resources.values()) {
|
|
132
|
+
yield* resources;
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
130
136
|
export function* getRels(uri, rootUris) {
|
|
131
137
|
yield* fileUtil.getRels(uri, rootUris);
|
|
132
138
|
const parts = uri.split('/');
|
|
@@ -137,6 +143,16 @@ export function* getRels(uri, rootUris) {
|
|
|
137
143
|
}
|
|
138
144
|
return undefined;
|
|
139
145
|
}
|
|
146
|
+
export function* getRoots(uri, rootUris) {
|
|
147
|
+
yield* fileUtil.getRoots(uri, rootUris);
|
|
148
|
+
const parts = uri.split('/');
|
|
149
|
+
for (let i = parts.length - 2; i >= 0; i--) {
|
|
150
|
+
if (parts[i] === 'data' || parts[i] === 'assets') {
|
|
151
|
+
yield `${parts.slice(0, i).join('/')}/`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
140
156
|
export function dissectUri(uri, ctx) {
|
|
141
157
|
const rels = getRels(uri, ctx.roots);
|
|
142
158
|
const release = ctx.project['loadedVersion'];
|
|
@@ -249,4 +265,36 @@ export function reportDissectError(realPath, expectedPath, ctx) {
|
|
|
249
265
|
ctx.err.report(localize('java-edition.binder.wrong-version', localeQuote(realPath), release), Range.Beginning, 0 /* ErrorSeverity.Hint */);
|
|
250
266
|
}
|
|
251
267
|
}
|
|
268
|
+
function uriBuilder(resources) {
|
|
269
|
+
return (identifier, ctx) => {
|
|
270
|
+
const root = getRoots(ctx.doc.uri, ctx.roots).next().value;
|
|
271
|
+
if (!root) {
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
const release = ctx.project['loadedVersion'];
|
|
275
|
+
if (!release) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
const resource = resources.find(r => matchVersion(release, r.since, r.until));
|
|
279
|
+
if (!resource) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
const sepIndex = identifier.indexOf(':');
|
|
283
|
+
const namespace = sepIndex > 0 ? identifier.slice(0, sepIndex) : 'minecraft';
|
|
284
|
+
const path = identifier.slice(sepIndex + 1);
|
|
285
|
+
return `${root}${resource.pack}/${namespace}/${resource.path}/${path}${resource.ext}`;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
export function registerUriBuilders(meta) {
|
|
289
|
+
const resourcesByCategory = new Map();
|
|
290
|
+
for (const resource of getResources()) {
|
|
291
|
+
resourcesByCategory.set(resource.category, [
|
|
292
|
+
...resourcesByCategory.get(resource.category) ?? [],
|
|
293
|
+
resource,
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
for (const [category, resources] of resourcesByCategory.entries()) {
|
|
297
|
+
meta.registerUriBuilder(category, uriBuilder(resources));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
252
300
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as core from '@spyglassmc/core';
|
|
|
2
2
|
import * as json from '@spyglassmc/json';
|
|
3
3
|
import * as mcdoc from '@spyglassmc/mcdoc';
|
|
4
4
|
import * as nbt from '@spyglassmc/nbt';
|
|
5
|
-
import { uriBinder } from './binder/index.js';
|
|
5
|
+
import { registerUriBuilders, uriBinder } from './binder/index.js';
|
|
6
6
|
import { getMcmetaSummary, getVanillaDatapack, getVanillaMcdoc, getVanillaResourcepack, getVersions, PackMcmeta, resolveConfiguredVersion, symbolRegistrar, } from './dependency/index.js';
|
|
7
7
|
import * as jeJson from './json/index.js';
|
|
8
8
|
import { registerMcdocAttributes, registerPackFormatAttribute } from './mcdocAttributes.js';
|
|
@@ -52,6 +52,7 @@ export const initialize = async (ctx) => {
|
|
|
52
52
|
return packs;
|
|
53
53
|
}
|
|
54
54
|
meta.registerUriBinder(uriBinder);
|
|
55
|
+
registerUriBuilders(meta);
|
|
55
56
|
const versions = await getVersions(ctx.externals, ctx.downloader);
|
|
56
57
|
if (!versions) {
|
|
57
58
|
ctx.logger.error('[je-initialize] Failed loading game version list. Expect everything to be broken.');
|
|
@@ -150,10 +150,10 @@ const block = (node, ctx) => {
|
|
|
150
150
|
if (Range.contains(node.id, ctx.offset, true)) {
|
|
151
151
|
ans.push(...completer.resourceLocation(node.id, ctx));
|
|
152
152
|
}
|
|
153
|
-
if (node.states && Range.contains(
|
|
153
|
+
if (node.states?.innerRange && Range.contains(node.states.innerRange, ctx.offset, true)) {
|
|
154
154
|
ans.push(...blockStates(node.states, ctx));
|
|
155
155
|
}
|
|
156
|
-
if (node.nbt && Range.contains(
|
|
156
|
+
if (node.nbt?.innerRange && Range.contains(node.nbt.innerRange, ctx.offset, true)) {
|
|
157
157
|
ans.push(...completer.dispatch(node.nbt, ctx));
|
|
158
158
|
}
|
|
159
159
|
return ans;
|
|
@@ -183,7 +183,7 @@ const blockStates = (node, ctx) => {
|
|
|
183
183
|
})(node, ctx);
|
|
184
184
|
};
|
|
185
185
|
const componentList = (node, ctx) => {
|
|
186
|
-
if (!Range.contains(
|
|
186
|
+
if (!node.innerRange || !Range.contains(node.innerRange, ctx.offset, true)) {
|
|
187
187
|
return [];
|
|
188
188
|
}
|
|
189
189
|
const completeKey = (key) => {
|
|
@@ -326,7 +326,7 @@ const selector = (node, ctx) => {
|
|
|
326
326
|
if (Range.contains(node.children[0], ctx.offset, true)) {
|
|
327
327
|
return completer.literal(node.children[0], ctx);
|
|
328
328
|
}
|
|
329
|
-
if (node.arguments && Range.contains(
|
|
329
|
+
if (node.arguments?.innerRange && Range.contains(node.arguments.innerRange, ctx.offset, true)) {
|
|
330
330
|
return selectorArguments(node.arguments, ctx);
|
|
331
331
|
}
|
|
332
332
|
return [];
|
|
@@ -124,6 +124,7 @@ export declare namespace ItemStackNode {
|
|
|
124
124
|
export interface ComponentListNode extends core.AstNode {
|
|
125
125
|
type: 'mcfunction:component_list';
|
|
126
126
|
children: (ComponentNode | ComponentRemovalNode)[];
|
|
127
|
+
innerRange?: core.Range;
|
|
127
128
|
}
|
|
128
129
|
export declare namespace ComponentListNode {
|
|
129
130
|
function is(node: core.AstNode): node is ComponentListNode;
|
|
@@ -1085,6 +1085,7 @@ const components = (src, ctx) => {
|
|
|
1085
1085
|
if (!src.trySkip('[')) {
|
|
1086
1086
|
return core.Failure;
|
|
1087
1087
|
}
|
|
1088
|
+
ans.innerRange = core.Range.create(src);
|
|
1088
1089
|
src.skipWhitespace();
|
|
1089
1090
|
while (src.canRead() && src.peek() !== ']') {
|
|
1090
1091
|
const start = src.cursor;
|
|
@@ -1139,6 +1140,7 @@ const components = (src, ctx) => {
|
|
|
1139
1140
|
}
|
|
1140
1141
|
}
|
|
1141
1142
|
src.skipWhitespace();
|
|
1143
|
+
ans.innerRange.end = src.cursor;
|
|
1142
1144
|
core.literal(']')(src, ctx);
|
|
1143
1145
|
ans.range.end = src.cursor;
|
|
1144
1146
|
return ans;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/java-edition",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -17,16 +17,14 @@
|
|
|
17
17
|
"release:dry": "npm publish --dry-run"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@spyglassmc/core": "0.4.
|
|
21
|
-
"@spyglassmc/json": "0.3.
|
|
22
|
-
"@spyglassmc/locales": "0.3.
|
|
23
|
-
"@spyglassmc/mcfunction": "0.2.
|
|
24
|
-
"@spyglassmc/mcdoc": "0.3.
|
|
25
|
-
"@spyglassmc/nbt": "0.3.
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"fast-glob": "^3.2.5"
|
|
20
|
+
"@spyglassmc/core": "0.4.21",
|
|
21
|
+
"@spyglassmc/json": "0.3.24",
|
|
22
|
+
"@spyglassmc/locales": "0.3.12",
|
|
23
|
+
"@spyglassmc/mcfunction": "0.2.23",
|
|
24
|
+
"@spyglassmc/mcdoc": "0.3.25",
|
|
25
|
+
"@spyglassmc/nbt": "0.3.25"
|
|
29
26
|
},
|
|
27
|
+
"devDependencies": {},
|
|
30
28
|
"publishConfig": {
|
|
31
29
|
"access": "public"
|
|
32
30
|
},
|