mcutils-js-api 2.0.17 → 2.0.18

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/dist/index.d.ts CHANGED
@@ -132,12 +132,24 @@ export declare class McUtilsAPI {
132
132
  error?: ErrorResponse;
133
133
  }>;
134
134
  /**
135
- * Fetch a cape texture image by cape texture id.
135
+ * Fetch a cape texture image.
136
136
  *
137
- * @param id the cape texture id (eg: from player.cape or a texture hash)
137
+ * @param query player UUID/username or 64-char cape texture id
138
138
  * @returns the cape PNG image or the error (if one occurred)
139
139
  */
140
- fetchPlayerCapeTexture(id: string): Promise<{
140
+ fetchCapeTexture(query: string): Promise<{
141
+ image?: ArrayBuffer;
142
+ error?: ErrorResponse;
143
+ }>;
144
+ /**
145
+ * Fetch a rendered cape part (e.g. front).
146
+ *
147
+ * @param query player UUID/username or 64-char cape texture id
148
+ * @param type cape part (e.g. front) – see CapeRendererType
149
+ * @param size image height (default 768)
150
+ * @returns the cape part PNG image or the error (if one occurred)
151
+ */
152
+ fetchCapePart(query: string, type: string, size?: number): Promise<{
141
153
  image?: ArrayBuffer;
142
154
  error?: ErrorResponse;
143
155
  }>;
package/dist/index.js CHANGED
@@ -195,13 +195,30 @@ export class McUtilsAPI {
195
195
  };
196
196
  }
197
197
  /**
198
- * Fetch a cape texture image by cape texture id.
198
+ * Fetch a cape texture image.
199
199
  *
200
- * @param id the cape texture id (eg: from player.cape or a texture hash)
200
+ * @param query player UUID/username or 64-char cape texture id
201
201
  * @returns the cape PNG image or the error (if one occurred)
202
202
  */
203
- async fetchPlayerCapeTexture(id) {
204
- const response = await fetch(`${this.endpoint}/cape/${id}/texture.png`);
203
+ async fetchCapeTexture(query) {
204
+ const response = await fetch(`${this.endpoint}/cape/${query}/texture.png`);
205
+ if (response.ok) {
206
+ return { image: await response.arrayBuffer() };
207
+ }
208
+ return {
209
+ error: (await response.json()),
210
+ };
211
+ }
212
+ /**
213
+ * Fetch a rendered cape part (e.g. front).
214
+ *
215
+ * @param query player UUID/username or 64-char cape texture id
216
+ * @param type cape part (e.g. front) – see CapeRendererType
217
+ * @param size image height (default 768)
218
+ * @returns the cape part PNG image or the error (if one occurred)
219
+ */
220
+ async fetchCapePart(query, type, size = 768) {
221
+ const response = await fetch(`${this.endpoint}/cape/${query}/${type}.png${this.buildParams({ size: String(size) })}`);
205
222
  if (response.ok) {
206
223
  return { image: await response.arrayBuffer() };
207
224
  }
@@ -0,0 +1,5 @@
1
+ export type CapeRendererType = "FRONT";
2
+ export type Cape = {
3
+ textureUrl: string;
4
+ parts: Record<string, string>;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import { Cape } from "../cape/cape";
1
2
  export type SkinModel = "DEFAULT" | "SLIM";
2
3
  export type SkinPart = "HEAD" | "FULLBODY_FRONT" | "FULLBODY_BACK" | "FACE" | "BODY";
3
4
  export type SkinParts = Record<SkinPart, string>;
@@ -7,9 +8,6 @@ export type Skin = {
7
8
  textureUrl: string;
8
9
  parts: SkinParts;
9
10
  };
10
- export type Cape = {
11
- textureUrl: string;
12
- };
13
11
  export type ProfileProperty = {
14
12
  name: string;
15
13
  value: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcutils-js-api",
3
- "version": "2.0.17",
3
+ "version": "2.0.18",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",