@spyglassmc/core 0.4.6 → 0.4.7

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.
@@ -12,16 +12,19 @@ export type ResourceLocationOptions = {
12
12
  category: ResourceLocationCategory;
13
13
  pool?: undefined;
14
14
  allowTag?: false;
15
+ requireTag?: false;
15
16
  allowUnknown?: false;
16
17
  } | {
17
18
  category: TaggableResourceLocationCategory;
18
19
  pool?: undefined;
19
20
  allowTag?: boolean;
21
+ requireTag?: boolean;
20
22
  allowUnknown?: false;
21
23
  } | {
22
24
  category?: undefined;
23
25
  pool: string[];
24
26
  allowTag?: false;
27
+ requireTag?: false;
25
28
  allowUnknown?: boolean;
26
29
  });
27
30
  export interface ResourceLocationBaseNode extends AstNode, Partial<ResourceLocation> {
@@ -100,6 +100,9 @@ export function resourceLocation(options) {
100
100
  if (ans.isTag && !options.allowTag) {
101
101
  ctx.err.report(localize('parser.resource-location.tag-disallowed'), ans);
102
102
  }
103
+ if (!ans.isTag && options.requireTag) {
104
+ ctx.err.report(localize('parser.resource-location.tag-required'), ans);
105
+ }
103
106
  if (!ans.namespace && options.requireCanonical) {
104
107
  ctx.err.report(localize('parser.resource-location.namespace-expected'), ans);
105
108
  }
@@ -139,7 +139,9 @@ export const resourceLocation = (node, ctx) => {
139
139
  const pool = node.options.pool
140
140
  ? optimizePool(node.options.pool)
141
141
  : [
142
- ...getPool(node.options.category),
142
+ ...(!node.options.requireTag
143
+ ? getPool(node.options.category)
144
+ : []),
143
145
  ...(node.options.allowTag
144
146
  ? getPool(`tag/${node.options.category}`).map((v) => `${ResourceLocation.TagPrefix}${v}`)
145
147
  : []),
@@ -125,7 +125,7 @@ export class Project {
125
125
  return this.#cacheRoot;
126
126
  }
127
127
  updateRoots() {
128
- const rawRoots = [...this.#dependencyRoots, this.projectRoot];
128
+ const rawRoots = [...this.#dependencyRoots ?? [], this.projectRoot];
129
129
  const ans = new Set(rawRoots);
130
130
  // Identify roots indicated by `pack.mcmeta`.
131
131
  for (const file of this.getTrackedFiles()) {
@@ -155,7 +155,8 @@ export class Project {
155
155
  */
156
156
  getTrackedFiles() {
157
157
  const extensions = this.meta.getSupportedFileExtensions();
158
- const supportedFiles = [...this.#dependencyFiles, ...this.#watchedFiles].filter((file) => extensions.includes(fileUtil.extname(file) ?? ''));
158
+ const supportedFiles = [...this.#dependencyFiles ?? [], ...this.#watchedFiles]
159
+ .filter((file) => extensions.includes(fileUtil.extname(file) ?? ''));
159
160
  const filteredFiles = this.ignore.filter(supportedFiles);
160
161
  return filteredFiles;
161
162
  }
@@ -726,13 +727,13 @@ export class Project {
726
727
  }
727
728
  shouldRemove(uri) {
728
729
  return (!this.#clientManagedUris.has(uri)
729
- && !this.#dependencyFiles.has(uri)
730
+ && !this.#dependencyFiles?.has(uri)
730
731
  && !this.#watchedFiles.has(uri));
731
732
  }
732
733
  isOnlyWatched(uri) {
733
734
  return (this.#watchedFiles.has(uri)
734
735
  && !this.#clientManagedUris.has(uri)
735
- && !this.#dependencyFiles.has(uri));
736
+ && !this.#dependencyFiles?.has(uri));
736
737
  }
737
738
  }
738
739
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/core",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "rfdc": "^1.3.0",
26
26
  "vscode-languageserver-textdocument": "^1.0.4",
27
27
  "whatwg-url": "^14.0.0",
28
- "@spyglassmc/locales": "0.3.6"
28
+ "@spyglassmc/locales": "0.3.7"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/decompress": "^4.2.3",