mowojang 0.4.4 → 0.4.6-dev.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # mowojang-js
1
+ # mowojang
2
2
 
3
3
  ![NPM Version](https://img.shields.io/npm/v/mowojang?label=NPM)
4
4
  ![NPM Downloads](https://img.shields.io/npm/dm/mowojang?label=Downloads)
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { LoggerConfig } from '@pixelic/logger';
2
1
  import { CacheOptions, CacheRequestConfig, buildStorage, buildMemoryStorage } from 'axios-cache-interceptor';
2
+ import { LoggerConfig } from '@pixelic/logger';
3
3
 
4
4
  /**
5
5
  * Minecraft Username or UUIDv4 (both undashed and dashed will be accepted)
@@ -28,6 +28,11 @@ type ClientOptions = {
28
28
  baseURL?: string;
29
29
  fallback?: boolean;
30
30
  };
31
+ type AxiosOptions = {
32
+ timeout?: number;
33
+ cache?: CacheOptions;
34
+ fallback: boolean;
35
+ };
31
36
  type ValidationOptions = {
32
37
  enabled?: boolean;
33
38
  minimumUsernameLength?: 1 | 2;
@@ -90,12 +95,12 @@ declare class Client {
90
95
  */
91
96
  getProfile(player: Player, config?: MowojangRequestConfig): MowojangResponse<MowojangProfile, "INVALID_PLAYER">;
92
97
  /**
93
- * A Simple Wrapper to Retrieve Only the UUID of a Player's Profile
98
+ * A simple Wrapper to retrieve only the UUID of a Player's Profile
94
99
  *
95
100
  */
96
101
  getUUID(username: Username, config?: MowojangRequestConfig): Promise<null | UUID>;
97
102
  /**
98
- * A Simple Wrapper to Retrieve Only the Username of a Player's Profile
103
+ * A simple Wrapper to retrieve only the Username of a Player's Profile
99
104
  *
100
105
  */
101
106
  getUsername(UUID: UUID, config?: MowojangRequestConfig): Promise<null | Username>;
@@ -111,22 +116,22 @@ declare class Client {
111
116
  */
112
117
  getSession(player: Player, config?: MowojangRequestConfig): MowojangResponse<MowojangSession, "INVALID_PLAYER">;
113
118
  /**
114
- * A Simple Wrapper to Retrieve Only the Skin from a Player's Session
119
+ * A simple Wrapper to retrieve only the Skin from a Player's Session
115
120
  *
116
121
  */
117
122
  getSkin(player: Player, config?: MowojangRequestConfig): Promise<null | MowojangSkin>;
118
123
  /**
119
- * A Simple Wrapper to Retrieve Only the Player's Skin from their Session Data Loaded into a Buffer
124
+ * A simple Wrapper to retrieve only the Player's Skin from their Session Data loaded into a Buffer
120
125
  *
121
126
  */
122
127
  getSkinBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
123
128
  /**
124
- * A Simple Wrapper to Retrieve Only the Cape Data from a Player's Session
129
+ * A simple Wrapper to retrieve only the Cape Data from a Player's Session
125
130
  *
126
131
  */
127
132
  getCape(player: Player, config?: MowojangRequestConfig): Promise<null | MowojangCape>;
128
133
  /**
129
- * A Simple Wrapper to Retrieve Only the Player's Cape from their Session Data Loaded into a Buffer
134
+ * A simple Wrapper to retrieve only the Player's Cape from their Session Data loaded into a Buffer
130
135
  *
131
136
  */
132
137
  getCapeBuffer(player: Player, config?: MowojangRequestConfig): Promise<null | Buffer>;
@@ -146,4 +151,4 @@ declare const cache: {
146
151
  buildMemoryStorage: typeof buildMemoryStorage;
147
152
  };
148
153
 
149
- export { Client, cache, utils, validate };
154
+ export { type AxiosOptions, Client, type ClientOptions, type MowojangCape, type MowojangError, type MowojangProfile, type MowojangRequestConfig, type MowojangResponse, type MowojangSession, type MowojangSkin, type Player, type UUID, type Username, type ValidationOptions, cache, utils, validate };
package/dist/index.js CHANGED
@@ -1,6 +1,32 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/utils.ts
5
+ var undashUUID = /* @__PURE__ */ __name((UUID) => UUID.replace(/-/g, "").toLowerCase(), "undashUUID");
6
+ var dashUUID = /* @__PURE__ */ __name((UUID) => undashUUID(UUID).replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5"), "dashUUID");
7
+
8
+ // src/validators.ts
9
+ var validateUUID = /* @__PURE__ */ __name((UUID) => {
10
+ if (typeof UUID !== "string") return false;
11
+ UUID = undashUUID(UUID);
12
+ if (UUID.length !== 32) return false;
13
+ return /[0-9a-f]{12}4[0-9a-f]{19}/.test(UUID);
14
+ }, "validateUUID");
15
+ var validateUsername = /* @__PURE__ */ __name((username, minimumLength) => {
16
+ if (typeof username !== "string") return false;
17
+ if (minimumLength === 1) return /^[a-zA-Z0-9_]{1,16}$/.test(username);
18
+ if (minimumLength === 2) return /^[a-zA-Z0-9_]{2,16}$/.test(username);
19
+ return /^[a-zA-Z0-9_]{3,16}$/.test(username);
20
+ }, "validateUsername");
21
+ var validatePlayer = /* @__PURE__ */ __name((player, minimumUsernameLength) => validateUUID(player) || validateUsername(player, minimumUsernameLength), "validatePlayer");
22
+ var validateArray = /* @__PURE__ */ __name((array, validatorFunction, ...params) => {
23
+ if (!Array.isArray(array)) return false;
24
+ return array.every((item) => validatorFunction(item, ...params));
25
+ }, "validateArray");
26
+
27
+ // src/index.ts
28
+ import { buildStorage, buildMemoryStorage } from "axios-cache-interceptor";
29
+
4
30
  // src/client.ts
5
31
  import { isAxiosError } from "axios";
6
32
 
@@ -11,7 +37,7 @@ import { setupCache } from "axios-cache-interceptor";
11
37
  // package.json
12
38
  var package_default = {
13
39
  name: "mowojang",
14
- version: "0.4.4",
40
+ version: "0.4.6-dev.0",
15
41
  description: "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
16
42
  exports: {
17
43
  ".": {
@@ -32,7 +58,7 @@ var package_default = {
32
58
  },
33
59
  repository: {
34
60
  type: "git",
35
- url: "https://github.com/Pixelicc/mowojang-js"
61
+ url: "https://github.com/Pixelicc/mowojang"
36
62
  },
37
63
  keywords: [
38
64
  "Minecraft",
@@ -124,29 +150,6 @@ var axiosInstance_default = /* @__PURE__ */ __name((options, logger) => {
124
150
  return instance;
125
151
  }, "default");
126
152
 
127
- // src/utils.ts
128
- var undashUUID = /* @__PURE__ */ __name((UUID) => UUID.replace(/-/g, "").toLowerCase(), "undashUUID");
129
- var dashUUID = /* @__PURE__ */ __name((UUID) => undashUUID(UUID).replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5"), "dashUUID");
130
-
131
- // src/validators.ts
132
- var validateUUID = /* @__PURE__ */ __name((UUID) => {
133
- if (typeof UUID !== "string") return false;
134
- UUID = undashUUID(UUID);
135
- if (UUID.length !== 32) return false;
136
- return /[0-9a-f]{12}4[0-9a-f]{19}/.test(UUID);
137
- }, "validateUUID");
138
- var validateUsername = /* @__PURE__ */ __name((username, minimumLength) => {
139
- if (typeof username !== "string") return false;
140
- if (minimumLength === 1) return /^[a-zA-Z0-9_]{1,16}$/.test(username);
141
- if (minimumLength === 2) return /^[a-zA-Z0-9_]{2,16}$/.test(username);
142
- return /^[a-zA-Z0-9_]{3,16}$/.test(username);
143
- }, "validateUsername");
144
- var validatePlayer = /* @__PURE__ */ __name((player, minimumUsernameLength) => validateUUID(player) || validateUsername(player, minimumUsernameLength), "validatePlayer");
145
- var validateArray = /* @__PURE__ */ __name((array, validatorFunction, ...params) => {
146
- if (!Array.isArray(array)) return false;
147
- return array.every((item) => validatorFunction(item, ...params));
148
- }, "validateArray");
149
-
150
153
  // node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
151
154
  var ANSI_BACKGROUND_OFFSET = 10;
152
155
  var wrapAnsi16 = /* @__PURE__ */ __name((offset = 0) => (code) => `\x1B[${code + offset}m`, "wrapAnsi16");
@@ -827,7 +830,6 @@ var Client = class {
827
830
  });
828
831
  const profiles = (await Promise.all(profilePromises)).filter((p) => p.data !== null).map((p) => p.data);
829
832
  return {
830
- // @ts-ignore
831
833
  data: profiles,
832
834
  error: null
833
835
  };
@@ -858,7 +860,7 @@ var Client = class {
858
860
  }
859
861
  }
860
862
  /**
861
- * A Simple Wrapper to Retrieve Only the UUID of a Player's Profile
863
+ * A simple Wrapper to retrieve only the UUID of a Player's Profile
862
864
  *
863
865
  */
864
866
  async getUUID(username, config) {
@@ -867,7 +869,7 @@ var Client = class {
867
869
  return profile.data.UUID;
868
870
  }
869
871
  /**
870
- * A Simple Wrapper to Retrieve Only the Username of a Player's Profile
872
+ * A simple Wrapper to retrieve only the Username of a Player's Profile
871
873
  *
872
874
  */
873
875
  async getUsername(UUID, config) {
@@ -894,7 +896,6 @@ var Client = class {
894
896
  });
895
897
  const sessions = (await Promise.all(sessionsPromises)).filter((session) => session.data !== null).map((session) => session.data);
896
898
  return {
897
- // @ts-ignore
898
899
  data: sessions,
899
900
  error: null
900
901
  };
@@ -953,7 +954,7 @@ var Client = class {
953
954
  });
954
955
  }
955
956
  /**
956
- * A Simple Wrapper to Retrieve Only the Skin from a Player's Session
957
+ * A simple Wrapper to retrieve only the Skin from a Player's Session
957
958
  *
958
959
  */
959
960
  async getSkin(player, config) {
@@ -962,7 +963,7 @@ var Client = class {
962
963
  return session.data.skin;
963
964
  }
964
965
  /**
965
- * A Simple Wrapper to Retrieve Only the Player's Skin from their Session Data Loaded into a Buffer
966
+ * A simple Wrapper to retrieve only the Player's Skin from their Session Data loaded into a Buffer
966
967
  *
967
968
  */
968
969
  async getSkinBuffer(player, config) {
@@ -975,7 +976,7 @@ var Client = class {
975
976
  return Buffer.from(fetchResponse.data, "base64");
976
977
  }
977
978
  /**
978
- * A Simple Wrapper to Retrieve Only the Cape Data from a Player's Session
979
+ * A simple Wrapper to retrieve only the Cape Data from a Player's Session
979
980
  *
980
981
  */
981
982
  async getCape(player, config) {
@@ -984,7 +985,7 @@ var Client = class {
984
985
  return session.data.cape;
985
986
  }
986
987
  /**
987
- * A Simple Wrapper to Retrieve Only the Player's Cape from their Session Data Loaded into a Buffer
988
+ * A simple Wrapper to retrieve only the Player's Cape from their Session Data loaded into a Buffer
988
989
  *
989
990
  */
990
991
  async getCapeBuffer(player, config) {
@@ -999,7 +1000,6 @@ var Client = class {
999
1000
  };
1000
1001
 
1001
1002
  // src/index.ts
1002
- import { buildStorage, buildMemoryStorage } from "axios-cache-interceptor";
1003
1003
  var validate = {
1004
1004
  player: validatePlayer,
1005
1005
  UUID: validateUUID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mowojang",
3
- "version": "0.4.4",
3
+ "version": "0.4.6-dev.0",
4
4
  "description": "A simple JavaScript and TypeScript compatible wrapper for the Mowojang-API.",
5
5
  "exports": {
6
6
  ".": {
@@ -14,7 +14,7 @@
14
14
  "type": "module",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://github.com/Pixelicc/mowojang-js"
17
+ "url": "https://github.com/Pixelicc/mowojang"
18
18
  },
19
19
  "keywords": [
20
20
  "Minecraft",