@discordeno/utils 19.0.0-next.3ebcce8 → 19.0.0-next.40c19da
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 +1 -1
- package/dist/Collection.js +113 -2
- package/dist/Collection.js.map +1 -0
- package/dist/base64.js +262 -2
- package/dist/base64.js.map +1 -0
- package/dist/bucket.d.ts +34 -48
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +67 -2
- package/dist/bucket.js.map +1 -0
- package/dist/casing.d.ts.map +1 -1
- package/dist/casing.js +51 -2
- package/dist/casing.js.map +1 -0
- package/dist/colors.js +471 -2
- package/dist/colors.js.map +1 -0
- package/dist/files.js +41 -2
- package/dist/files.js.map +1 -0
- package/dist/hash.js +19 -2
- package/dist/hash.js.map +1 -0
- package/dist/images.js +66 -2
- package/dist/images.js.map +1 -0
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +130 -2
- package/dist/logger.js.map +1 -0
- package/dist/permissions.js +17 -2
- package/dist/permissions.js.map +1 -0
- package/dist/reactions.js +11 -2
- package/dist/reactions.js.map +1 -0
- package/dist/token.js +16 -2
- package/dist/token.js.map +1 -0
- package/dist/typeguards.js +15 -2
- package/dist/typeguards.js.map +1 -0
- package/dist/urlToBase64.d.ts.map +1 -1
- package/dist/urlToBase64.js +10 -2
- package/dist/urlToBase64.js.map +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -2
- package/dist/utils.js.map +1 -0
- package/package.json +13 -12
package/dist/images.js
CHANGED
|
@@ -1,2 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */ import { iconBigintToHash } from './hash.js';
|
|
2
|
+
/** Help format an image url. */ export function formatImageUrl(url, size = 128, format) {
|
|
3
|
+
return `${url}.${format ?? (url.includes('/a_') ? 'gif' : 'jpg')}?size=${size}`;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Get the url for an emoji.
|
|
7
|
+
*
|
|
8
|
+
* @param emojiId The id of the emoji
|
|
9
|
+
* @param animated Whether or not the emoji is animated
|
|
10
|
+
* @returns string
|
|
11
|
+
*/ export function emojiUrl(emojiId, animated = false) {
|
|
12
|
+
return `https://cdn.discordapp.com/emojis/${emojiId}.${animated ? 'gif' : 'png'}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds a URL to a user's avatar stored in the Discord CDN.
|
|
16
|
+
*
|
|
17
|
+
* @param userId - The ID of the user to get the avatar of.
|
|
18
|
+
* @param discriminator - The user's discriminator. (4-digit tag after the hashtag.)
|
|
19
|
+
* @param options - The parameters for the building of the URL.
|
|
20
|
+
* @returns The link to the resource.
|
|
21
|
+
*/ export function avatarUrl(userId, discriminator, options) {
|
|
22
|
+
return options?.avatar ? formatImageUrl(`https://cdn.discordapp.com/avatars/${userId}/${typeof options.avatar === 'string' ? options.avatar : iconBigintToHash(options.avatar)}`, options?.size ?? 128, options?.format) : `https://cdn.discordapp.com/embed/avatars/${Number(discriminator) % 5}.png`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Builds a URL to the guild banner stored in the Discord CDN.
|
|
26
|
+
*
|
|
27
|
+
* @param guildId - The ID of the guild to get the link to the banner for.
|
|
28
|
+
* @param options - The parameters for the building of the URL.
|
|
29
|
+
* @returns The link to the resource or `undefined` if no banner has been set.
|
|
30
|
+
*/ export function guildBannerUrl(guildId, options) {
|
|
31
|
+
return options.banner ? formatImageUrl(`https://cdn.discordapp.com/banners/${guildId}/${typeof options.banner === 'string' ? options.banner : iconBigintToHash(options.banner)}`, options.size ?? 128, options.format) : undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Builds a URL to the guild icon stored in the Discord CDN.
|
|
35
|
+
*
|
|
36
|
+
* @param guildId - The ID of the guild to get the link to the banner for.
|
|
37
|
+
* @param options - The parameters for the building of the URL.
|
|
38
|
+
* @returns The link to the resource or `undefined` if no banner has been set.
|
|
39
|
+
*/ export function guildIconUrl(guildId, imageHash, options) {
|
|
40
|
+
return imageHash ? formatImageUrl(`https://cdn.discordapp.com/icons/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`, options?.size ?? 128, options?.format) : undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Builds the URL to a guild splash stored in the Discord CDN.
|
|
44
|
+
*
|
|
45
|
+
* @param guildId - The ID of the guild to get the splash of.
|
|
46
|
+
* @param imageHash - The hash identifying the splash image.
|
|
47
|
+
* @param options - The parameters for the building of the URL.
|
|
48
|
+
* @returns The link to the resource or `undefined` if the guild does not have a splash image set.
|
|
49
|
+
*/ export function guildSplashUrl(guildId, imageHash, options) {
|
|
50
|
+
return imageHash ? formatImageUrl(`https://cdn.discordapp.com/splashes/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`, options?.size ?? 128, options?.format) : undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Builds a URL to the guild widget image stored in the Discord CDN.
|
|
54
|
+
*
|
|
55
|
+
* @param guildId - The ID of the guild to get the link to the widget image for.
|
|
56
|
+
* @param options - The parameters for the building of the URL.
|
|
57
|
+
* @returns The link to the resource.
|
|
58
|
+
*/ export function getWidgetImageUrl(guildId, options) {
|
|
59
|
+
let url = `https://discordapp.com/api/guilds/${guildId}/widget.png`;
|
|
60
|
+
if (options?.style) {
|
|
61
|
+
url += `?style=${options.style}`;
|
|
62
|
+
}
|
|
63
|
+
return url;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/images.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-template-expressions */\nimport type { BigString, GetGuildWidgetImageQuery, ImageFormat, ImageSize } from '@discordeno/types'\nimport { iconBigintToHash } from './hash.js'\n\n/** Help format an image url. */\nexport function formatImageUrl(url: string, size: ImageSize = 128, format?: ImageFormat): string {\n return `${url}.${format ?? (url.includes('/a_') ? 'gif' : 'jpg')}?size=${size}`\n}\n\n/**\n * Get the url for an emoji.\n *\n * @param emojiId The id of the emoji\n * @param animated Whether or not the emoji is animated\n * @returns string\n */\nexport function emojiUrl(emojiId: BigString, animated = false): string {\n return `https://cdn.discordapp.com/emojis/${emojiId}.${animated ? 'gif' : 'png'}`\n}\n\n/**\n * Builds a URL to a user's avatar stored in the Discord CDN.\n *\n * @param userId - The ID of the user to get the avatar of.\n * @param discriminator - The user's discriminator. (4-digit tag after the hashtag.)\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource.\n */\nexport function avatarUrl(\n userId: BigString,\n discriminator: string,\n options?: {\n avatar: BigString | undefined\n size?: ImageSize\n format?: ImageFormat\n },\n): string {\n return options?.avatar\n ? formatImageUrl(\n `https://cdn.discordapp.com/avatars/${userId}/${typeof options.avatar === 'string' ? options.avatar : iconBigintToHash(options.avatar)}`,\n options?.size ?? 128,\n options?.format,\n )\n : `https://cdn.discordapp.com/embed/avatars/${Number(discriminator) % 5}.png`\n}\n\n/**\n * Builds a URL to the guild banner stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the banner for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if no banner has been set.\n */\nexport function guildBannerUrl(\n guildId: BigString,\n options: {\n banner?: string | bigint\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return options.banner\n ? formatImageUrl(\n `https://cdn.discordapp.com/banners/${guildId}/${typeof options.banner === 'string' ? options.banner : iconBigintToHash(options.banner)}`,\n options.size ?? 128,\n options.format,\n )\n : undefined\n}\n\n/**\n * Builds a URL to the guild icon stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the banner for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if no banner has been set.\n */\nexport function guildIconUrl(\n guildId: BigString,\n imageHash: BigString | undefined,\n options?: {\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return imageHash\n ? formatImageUrl(\n `https://cdn.discordapp.com/icons/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`,\n options?.size ?? 128,\n options?.format,\n )\n : undefined\n}\n\n/**\n * Builds the URL to a guild splash stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the splash of.\n * @param imageHash - The hash identifying the splash image.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if the guild does not have a splash image set.\n */\nexport function guildSplashUrl(\n guildId: BigString,\n imageHash: BigString | undefined,\n options?: {\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return imageHash\n ? formatImageUrl(\n `https://cdn.discordapp.com/splashes/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`,\n options?.size ?? 128,\n options?.format,\n )\n : undefined\n}\n\n/**\n * Builds a URL to the guild widget image stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the widget image for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource.\n */\nexport function getWidgetImageUrl(guildId: BigString, options?: GetGuildWidgetImageQuery): string {\n let url = `https://discordapp.com/api/guilds/${guildId}/widget.png`\n\n if (options?.style) {\n url += `?style=${options.style}`\n }\n\n return url\n}\n"],"names":["iconBigintToHash","formatImageUrl","url","size","format","includes","emojiUrl","emojiId","animated","avatarUrl","userId","discriminator","options","avatar","Number","guildBannerUrl","guildId","banner","undefined","guildIconUrl","imageHash","guildSplashUrl","getWidgetImageUrl","style"],"mappings":"AAAA,mEAAmE,GAEnE,SAASA,gBAAgB,QAAQ,YAAW;AAE5C,8BAA8B,GAC9B,OAAO,SAASC,eAAeC,GAAW,EAAEC,OAAkB,GAAG,EAAEC,MAAoB,EAAU;IAC/F,OAAO,CAAC,EAAEF,IAAI,CAAC,EAAEE,UAAWF,CAAAA,IAAI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EAClBI,SAAgC,EAChCR,OAGC,EACmB;IACpB,OAAOQ,YACHnB,eACE,CAAC,oCAAoC,EAAEe,QAAQ,CAAC,EAAE,OAAOI,cAAc,WAAWA,YAAYpB,iBAAiBoB,UAAU,CAAC,CAAC,EAC3HR,SAAST,QAAQ,KACjBS,SAASR,UAEXc,SAAS;AACf,CAAC;AAED;;;;;;CAMC,GACD,OAAO,SAASI,kBAAkBN,OAAkB,EAAEJ,OAAkC,EAAU;IAChG,IAAIV,MAAM,CAAC,kCAAkC,EAAEc,QAAQ,WAAW,CAAC;IAEnE,IAAIJ,SAASW,OAAO;QAClBrB,OAAO,CAAC,OAAO,EAAEU,QAAQW,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,OAAOrB;AACT,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
export*from
|
|
2
|
-
|
|
1
|
+
export * from './base64.js';
|
|
2
|
+
export * from './bucket.js';
|
|
3
|
+
export * from './casing.js';
|
|
4
|
+
export * from './Collection.js';
|
|
5
|
+
export * from './colors.js';
|
|
6
|
+
export * from './files.js';
|
|
7
|
+
export * from './hash.js';
|
|
8
|
+
export * from './images.js';
|
|
9
|
+
export * from './logger.js';
|
|
10
|
+
export * from './permissions.js';
|
|
11
|
+
export * from './reactions.js';
|
|
12
|
+
export * from './token.js';
|
|
13
|
+
export * from './typeguards.js';
|
|
14
|
+
export * from './urlToBase64.js';
|
|
15
|
+
export * from './utils.js';
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './base64.js'\nexport * from './bucket.js'\nexport * from './casing.js'\nexport * from './Collection.js'\nexport * from './colors.js'\nexport * from './files.js'\nexport * from './hash.js'\nexport * from './images.js'\nexport * from './logger.js'\nexport * from './permissions.js'\nexport * from './reactions.js'\nexport * from './token.js'\nexport * from './typeguards.js'\nexport * from './urlToBase64.js'\nexport * from './utils.js'\n"],"names":[],"mappings":"AAAA,cAAc,cAAa;AAC3B,cAAc,cAAa;AAC3B,cAAc,cAAa;AAC3B,cAAc,kBAAiB;AAC/B,cAAc,cAAa;AAC3B,cAAc,aAAY;AAC1B,cAAc,YAAW;AACzB,cAAc,cAAa;AAC3B,cAAc,cAAa;AAC3B,cAAc,mBAAkB;AAChC,cAAc,iBAAgB;AAC9B,cAAc,aAAY;AAC1B,cAAc,kBAAiB;AAC/B,cAAc,mBAAkB;AAChC,cAAc,aAAY"}
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAIA,oBAAY,SAAS;IACnB,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,KAAK,IAAA;CACN;AAED,oBAAY,QAAQ;IAClB,OAAO,IAAA;IACP,IAAI,IAAA;CACL;AAmBD,wBAAgB,YAAY,CAAC,EAC3B,QAAyB,EACzB,IAAI,GACL,GAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;CACT;iBAGgB,SAAS,WAAW,GAAG,EAAE;sBAkCpB,QAAQ;sBAJR,SAAS;qBAQV,GAAG,EAAE;oBAKN,GAAG,EAAE;oBAKL,GAAG,EAAE;qBAKJ,GAAG,EAAE;qBAKL,GAAG,EAAE;EAe9B;AAED,eAAO,MAAM,MAAM;iBA3EG,SAAS,WAAW,GAAG,EAAE;sBAkCpB,QAAQ;sBAJR,SAAS;qBAQV,GAAG,EAAE;oBAKN,GAAG,EAAE;oBAKL,GAAG,EAAE;qBAKJ,GAAG,EAAE;qBAKL,GAAG,EAAE;CAiB2B,CAAA;AAC1D,eAAe,MAAM,CAAA"}
|
package/dist/logger.js
CHANGED
|
@@ -1,2 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-confusing-void-expression */ /* eslint-disable @typescript-eslint/explicit-function-return-type */ import { bgBrightMagenta, black, bold, cyan, gray, italic, red, yellow } from './colors.js';
|
|
2
|
+
export var LogLevels;
|
|
3
|
+
(function(LogLevels) {
|
|
4
|
+
LogLevels[LogLevels["Debug"] = 0] = "Debug";
|
|
5
|
+
LogLevels[LogLevels["Info"] = 1] = "Info";
|
|
6
|
+
LogLevels[LogLevels["Warn"] = 2] = "Warn";
|
|
7
|
+
LogLevels[LogLevels["Error"] = 3] = "Error";
|
|
8
|
+
LogLevels[LogLevels["Fatal"] = 4] = "Fatal";
|
|
9
|
+
})(LogLevels || (LogLevels = {}));
|
|
10
|
+
export var LogDepth;
|
|
11
|
+
(function(LogDepth) {
|
|
12
|
+
LogDepth[LogDepth["Minimal"] = 0] = "Minimal";
|
|
13
|
+
LogDepth[LogDepth["Full"] = 1] = "Full";
|
|
14
|
+
})(LogDepth || (LogDepth = {}));
|
|
15
|
+
const prefixes = new Map([
|
|
16
|
+
[
|
|
17
|
+
0,
|
|
18
|
+
'DEBUG'
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
1,
|
|
22
|
+
'INFO'
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
2,
|
|
26
|
+
'WARN'
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
3,
|
|
30
|
+
'ERROR'
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
4,
|
|
34
|
+
'FATAL'
|
|
35
|
+
]
|
|
36
|
+
]);
|
|
37
|
+
const noColor = (msg)=>msg;
|
|
38
|
+
const colorFunctions = new Map([
|
|
39
|
+
[
|
|
40
|
+
0,
|
|
41
|
+
gray
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
1,
|
|
45
|
+
cyan
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
2,
|
|
49
|
+
yellow
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
3,
|
|
53
|
+
(str)=>red(str)
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
4,
|
|
57
|
+
(str)=>red(bold(italic(str)))
|
|
58
|
+
]
|
|
59
|
+
]);
|
|
60
|
+
export function createLogger({ logLevel =1 , name } = {}) {
|
|
61
|
+
let depth = 0;
|
|
62
|
+
function log(level, ...args) {
|
|
63
|
+
if (level < logLevel) return;
|
|
64
|
+
let color = colorFunctions.get(level);
|
|
65
|
+
if (!color) color = noColor;
|
|
66
|
+
const date = new Date();
|
|
67
|
+
const log1 = [
|
|
68
|
+
bgBrightMagenta(black(`[${date.toLocaleDateString()} ${date.toLocaleTimeString()}]`)),
|
|
69
|
+
color(prefixes.get(level) ?? 'DEBUG'),
|
|
70
|
+
name ? `${name} >` : '>',
|
|
71
|
+
...args
|
|
72
|
+
];
|
|
73
|
+
switch(level){
|
|
74
|
+
case 0:
|
|
75
|
+
return console.debug(...log1);
|
|
76
|
+
case 1:
|
|
77
|
+
return console.info(...log1);
|
|
78
|
+
case 2:
|
|
79
|
+
return console.warn(...log1);
|
|
80
|
+
case 3:
|
|
81
|
+
return console.error(...log1);
|
|
82
|
+
case 4:
|
|
83
|
+
return console.error(...log1);
|
|
84
|
+
default:
|
|
85
|
+
return console.log(...log1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function setLevel(level) {
|
|
89
|
+
logLevel = level;
|
|
90
|
+
}
|
|
91
|
+
function setDepth(level) {
|
|
92
|
+
depth = level;
|
|
93
|
+
}
|
|
94
|
+
function debug(...args) {
|
|
95
|
+
if (0 === depth) log(0, args[0]);
|
|
96
|
+
else log(0, ...args);
|
|
97
|
+
}
|
|
98
|
+
function info(...args) {
|
|
99
|
+
if (0 === depth) log(1, args[0]);
|
|
100
|
+
else log(1, ...args);
|
|
101
|
+
}
|
|
102
|
+
function warn(...args) {
|
|
103
|
+
if (0 === depth) log(2, args[0]);
|
|
104
|
+
else log(2, ...args);
|
|
105
|
+
}
|
|
106
|
+
function error(...args) {
|
|
107
|
+
if (0 === depth) log(3, args[0]);
|
|
108
|
+
else log(3, ...args);
|
|
109
|
+
}
|
|
110
|
+
function fatal(...args) {
|
|
111
|
+
if (0 === depth) log(4, args[0]);
|
|
112
|
+
else log(4, ...args);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
log,
|
|
116
|
+
setDepth,
|
|
117
|
+
setLevel,
|
|
118
|
+
debug,
|
|
119
|
+
info,
|
|
120
|
+
warn,
|
|
121
|
+
error,
|
|
122
|
+
fatal
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export const logger = createLogger({
|
|
126
|
+
name: 'Discordeno'
|
|
127
|
+
});
|
|
128
|
+
export default logger;
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/logger.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-confusing-void-expression */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { bgBrightMagenta, black, bold, cyan, gray, italic, red, yellow } from './colors.js'\n\nexport enum LogLevels {\n Debug,\n Info,\n Warn,\n Error,\n Fatal,\n}\n\nexport enum LogDepth {\n Minimal,\n Full,\n}\n\nconst prefixes = new Map<LogLevels, string>([\n [LogLevels.Debug, 'DEBUG'],\n [LogLevels.Info, 'INFO'],\n [LogLevels.Warn, 'WARN'],\n [LogLevels.Error, 'ERROR'],\n [LogLevels.Fatal, 'FATAL'],\n])\n\nconst noColor: (str: string) => string = (msg) => msg\nconst colorFunctions = new Map<LogLevels, (str: string) => string>([\n [LogLevels.Debug, gray],\n [LogLevels.Info, cyan],\n [LogLevels.Warn, yellow],\n [LogLevels.Error, (str: string) => red(str)],\n [LogLevels.Fatal, (str: string) => red(bold(italic(str)))],\n])\n\nexport function createLogger({\n logLevel = LogLevels.Info,\n name,\n}: {\n logLevel?: LogLevels\n name?: string\n} = {}) {\n let depth = LogDepth.Minimal\n\n function log(level: LogLevels, ...args: any[]) {\n if (level < logLevel) return\n\n let color = colorFunctions.get(level)\n if (!color) color = noColor\n\n const date = new Date()\n const log = [\n bgBrightMagenta(black(`[${date.toLocaleDateString()} ${date.toLocaleTimeString()}]`)),\n color(prefixes.get(level) ?? 'DEBUG'),\n name ? `${name} >` : '>',\n ...args,\n ]\n\n switch (level) {\n case LogLevels.Debug:\n return console.debug(...log)\n case LogLevels.Info:\n return console.info(...log)\n case LogLevels.Warn:\n return console.warn(...log)\n case LogLevels.Error:\n return console.error(...log)\n case LogLevels.Fatal:\n return console.error(...log)\n default:\n return console.log(...log)\n }\n }\n\n function setLevel(level: LogLevels) {\n logLevel = level\n }\n\n function setDepth(level: LogDepth) {\n depth = level\n }\n\n function debug(...args: any[]) {\n if (LogDepth.Minimal === depth) log(LogLevels.Debug, args[0])\n else log(LogLevels.Debug, ...args)\n }\n\n function info(...args: any[]) {\n if (LogDepth.Minimal === depth) log(LogLevels.Info, args[0])\n else log(LogLevels.Info, ...args)\n }\n\n function warn(...args: any[]) {\n if (LogDepth.Minimal === depth) log(LogLevels.Warn, args[0])\n else log(LogLevels.Warn, ...args)\n }\n\n function error(...args: any[]) {\n if (LogDepth.Minimal === depth) log(LogLevels.Error, args[0])\n else log(LogLevels.Error, ...args)\n }\n\n function fatal(...args: any[]) {\n if (LogDepth.Minimal === depth) log(LogLevels.Fatal, args[0])\n else log(LogLevels.Fatal, ...args)\n }\n\n return {\n log,\n setDepth,\n setLevel,\n debug,\n info,\n warn,\n error,\n fatal,\n }\n}\n\nexport const logger = createLogger({ name: 'Discordeno' })\nexport default logger\n"],"names":["bgBrightMagenta","black","bold","cyan","gray","italic","red","yellow","LogLevels","Debug","Info","Warn","Error","Fatal","LogDepth","Minimal","Full","prefixes","Map","noColor","msg","colorFunctions","str","createLogger","logLevel","name","depth","log","level","args","color","get","date","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,IAAIf,AApFNC,MAoF2BW,OAAOC,IAzFlCf,GAyFuDiB,IAAI,CAAC,EAAE;aACvDF,IA1FPf,MA0F+BiB;IAC/B;IAEA,SAASc,MAAM,GAAGd,IAAW,EAAE;QAC7B,IAAIf,AAzFNC,MAyF2BW,OAAOC,IA7FlCd,GA6FuDgB,IAAI,CAAC,EAAE;aACvDF,IA9FPd,MA8F+BgB;IAC/B;IAEA,OAAO;QACLF;QACAe;QACAD;QACAJ;QACAC;QACAC;QACAC;QACAG;IACF;AACF,CAAC;AAED,OAAO,MAAMC,SAASrB,aAAa;IAAEE,MAAM;AAAa,GAAE;AAC1D,eAAemB,OAAM"}
|
package/dist/permissions.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import{BitwisePermissionFlags
|
|
2
|
-
|
|
1
|
+
import { BitwisePermissionFlags } from '@discordeno/types';
|
|
2
|
+
/** This function converts a bitwise string to permission strings */ export function calculatePermissions(permissionBits) {
|
|
3
|
+
return Object.keys(BitwisePermissionFlags).filter((permission)=>{
|
|
4
|
+
// Since Object.keys() not only returns the permission names but also the bit values we need to return false if it is a Number
|
|
5
|
+
if (Number(permission)) return false;
|
|
6
|
+
// Check if permissionBits has this permission
|
|
7
|
+
return permissionBits & BigInt(BitwisePermissionFlags[permission]);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/** This function converts an array of permissions into the bitwise string. */ export function calculateBits(permissions) {
|
|
11
|
+
return permissions.reduce((bits, perm)=>{
|
|
12
|
+
bits |= BigInt(BitwisePermissionFlags[perm]);
|
|
13
|
+
return bits;
|
|
14
|
+
}, 0n).toString();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/permissions.ts"],"sourcesContent":["import type { PermissionStrings } from '@discordeno/types'\nimport { BitwisePermissionFlags } from '@discordeno/types'\n\n/** This function converts a bitwise string to permission strings */\nexport function calculatePermissions(permissionBits: bigint): PermissionStrings[] {\n return Object.keys(BitwisePermissionFlags).filter((permission) => {\n // Since Object.keys() not only returns the permission names but also the bit values we need to return false if it is a Number\n if (Number(permission)) return false\n // Check if permissionBits has this permission\n return permissionBits & BigInt(BitwisePermissionFlags[permission as PermissionStrings])\n }) as PermissionStrings[]\n}\n\n/** This function converts an array of permissions into the bitwise string. */\nexport function calculateBits(permissions: PermissionStrings[]): string {\n return permissions\n .reduce((bits, perm) => {\n bits |= BigInt(BitwisePermissionFlags[perm])\n return bits\n }, 0n)\n .toString()\n}\n"],"names":["BitwisePermissionFlags","calculatePermissions","permissionBits","Object","keys","filter","permission","Number","BigInt","calculateBits","permissions","reduce","bits","perm","toString"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,oBAAmB;AAE1D,kEAAkE,GAClE,OAAO,SAASC,qBAAqBC,cAAsB,EAAuB;IAChF,OAAOC,OAAOC,IAAI,CAACJ,wBAAwBK,MAAM,CAAC,CAACC,aAAe;QAChE,8HAA8H;QAC9H,IAAIC,OAAOD,aAAa,OAAO,KAAK;QACpC,8CAA8C;QAC9C,OAAOJ,iBAAiBM,OAAOR,sBAAsB,CAACM,WAAgC;IACxF;AACF,CAAC;AAED,4EAA4E,GAC5E,OAAO,SAASG,cAAcC,WAAgC,EAAU;IACtE,OAAOA,YACJC,MAAM,CAAC,CAACC,MAAMC,OAAS;QACtBD,QAAQJ,OAAOR,sBAAsB,CAACa,KAAK;QAC3C,OAAOD;IACT,GAAG,EAAE,EACJE,QAAQ;AACb,CAAC"}
|
package/dist/reactions.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export function processReactionString(
|
|
2
|
-
|
|
1
|
+
/** Converts an reaction emoji unicode string to the discord required form of name:id */ export function processReactionString(reaction) {
|
|
2
|
+
if (reaction.startsWith('<:')) {
|
|
3
|
+
return reaction.substring(2, reaction.length - 1);
|
|
4
|
+
}
|
|
5
|
+
if (reaction.startsWith('<a:')) {
|
|
6
|
+
return reaction.substring(3, reaction.length - 1);
|
|
7
|
+
}
|
|
8
|
+
return reaction;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=reactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/reactions.ts"],"sourcesContent":["/** Converts an reaction emoji unicode string to the discord required form of name:id */\nexport function processReactionString(reaction: string): string {\n if (reaction.startsWith('<:')) {\n return reaction.substring(2, reaction.length - 1)\n }\n\n if (reaction.startsWith('<a:')) {\n return reaction.substring(3, reaction.length - 1)\n }\n\n return reaction\n}\n"],"names":["processReactionString","reaction","startsWith","substring","length"],"mappings":"AAAA,sFAAsF,GACtF,OAAO,SAASA,sBAAsBC,QAAgB,EAAU;IAC9D,IAAIA,SAASC,UAAU,CAAC,OAAO;QAC7B,OAAOD,SAASE,SAAS,CAAC,GAAGF,SAASG,MAAM,GAAG;IACjD,CAAC;IAED,IAAIH,SAASC,UAAU,CAAC,QAAQ;QAC9B,OAAOD,SAASE,SAAS,CAAC,GAAGF,SAASG,MAAM,GAAG;IACjD,CAAC;IAED,OAAOH;AACT,CAAC"}
|
package/dist/token.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import{Buffer
|
|
2
|
-
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/** Removes the Bot before the token. */ export function removeTokenPrefix(token, type = 'REST') {
|
|
3
|
+
// If no token is provided, throw an error
|
|
4
|
+
if (token === undefined) {
|
|
5
|
+
throw new Error(`The ${type} was not given a token. Please provide a token and try again.`);
|
|
6
|
+
}
|
|
7
|
+
// If the token does not have a prefix just return token
|
|
8
|
+
if (!token.startsWith('Bot ')) return token;
|
|
9
|
+
// Remove the prefix and return only the token.
|
|
10
|
+
return token.substring(token.indexOf(' ') + 1);
|
|
11
|
+
}
|
|
12
|
+
/** Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken. */ export function getBotIdFromToken(token) {
|
|
13
|
+
return BigInt(Buffer.from(token.split('.')[0], 'base64').toString());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/token.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\n\n/** Removes the Bot before the token. */\nexport function removeTokenPrefix(token?: string, type: 'GATEWAY' | 'REST' = 'REST'): string {\n // If no token is provided, throw an error\n if (token === undefined) {\n throw new Error(`The ${type} was not given a token. Please provide a token and try again.`)\n }\n // If the token does not have a prefix just return token\n if (!token.startsWith('Bot ')) return token\n // Remove the prefix and return only the token.\n return token.substring(token.indexOf(' ') + 1)\n}\n\n/** Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken. */\nexport function getBotIdFromToken(token: string): bigint {\n return BigInt(Buffer.from(token.split('.')[0], 'base64').toString())\n}\n"],"names":["Buffer","removeTokenPrefix","token","type","undefined","Error","startsWith","substring","indexOf","getBotIdFromToken","BigInt","from","split","toString"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAa;AAEpC,sCAAsC,GACtC,OAAO,SAASC,kBAAkBC,KAAc,EAAEC,OAA2B,MAAM,EAAU;IAC3F,0CAA0C;IAC1C,IAAID,UAAUE,WAAW;QACvB,MAAM,IAAIC,MAAM,CAAC,IAAI,EAAEF,KAAK,6DAA6D,CAAC,EAAC;IAC7F,CAAC;IACD,wDAAwD;IACxD,IAAI,CAACD,MAAMI,UAAU,CAAC,SAAS,OAAOJ;IACtC,+CAA+C;IAC/C,OAAOA,MAAMK,SAAS,CAACL,MAAMM,OAAO,CAAC,OAAO;AAC9C,CAAC;AAED,wLAAwL,GACxL,OAAO,SAASC,kBAAkBP,KAAa,EAAU;IACvD,OAAOQ,OAAOV,OAAOW,IAAI,CAACT,MAAMU,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAUC,QAAQ;AACnE,CAAC"}
|
package/dist/typeguards.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import{hasProperty
|
|
2
|
-
|
|
1
|
+
import { hasProperty } from './utils.js';
|
|
2
|
+
export function isGetMessagesAfter(options) {
|
|
3
|
+
return hasProperty(options, 'after');
|
|
4
|
+
}
|
|
5
|
+
export function isGetMessagesBefore(options) {
|
|
6
|
+
return hasProperty(options, 'before');
|
|
7
|
+
}
|
|
8
|
+
export function isGetMessagesAround(options) {
|
|
9
|
+
return hasProperty(options, 'around');
|
|
10
|
+
}
|
|
11
|
+
export function isGetMessagesLimit(options) {
|
|
12
|
+
return hasProperty(options, 'limit');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=typeguards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/typeguards.ts"],"sourcesContent":["import type { GetMessagesAfter, GetMessagesAround, GetMessagesBefore, GetMessagesLimit, GetMessagesOptions } from '@discordeno/types'\nimport { hasProperty } from './utils.js'\n\nexport function isGetMessagesAfter(options: GetMessagesOptions): options is GetMessagesAfter {\n return hasProperty(options, 'after')\n}\n\nexport function isGetMessagesBefore(options: GetMessagesOptions): options is GetMessagesBefore {\n return hasProperty(options, 'before')\n}\n\nexport function isGetMessagesAround(options: GetMessagesOptions): options is GetMessagesAround {\n return hasProperty(options, 'around')\n}\n\nexport function isGetMessagesLimit(options: GetMessagesOptions): options is GetMessagesLimit {\n return hasProperty(options, 'limit')\n}\n"],"names":["hasProperty","isGetMessagesAfter","options","isGetMessagesBefore","isGetMessagesAround","isGetMessagesLimit"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAY;AAExC,OAAO,SAASC,mBAAmBC,OAA2B,EAA+B;IAC3F,OAAOF,YAAYE,SAAS;AAC9B,CAAC;AAED,OAAO,SAASC,oBAAoBD,OAA2B,EAAgC;IAC7F,OAAOF,YAAYE,SAAS;AAC9B,CAAC;AAED,OAAO,SAASE,oBAAoBF,OAA2B,EAAgC;IAC7F,OAAOF,YAAYE,SAAS;AAC9B,CAAC;AAED,OAAO,SAASG,mBAAmBH,OAA2B,EAA+B;IAC3F,OAAOF,YAAYE,SAAS;AAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlToBase64.d.ts","sourceRoot":"","sources":["../src/urlToBase64.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"urlToBase64.d.ts","sourceRoot":"","sources":["../src/urlToBase64.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9D"}
|
package/dist/urlToBase64.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
import { encode } from './base64.js';
|
|
3
|
+
/** Converts a url to base 64. Useful for example, uploading/creating server emojis. */ export async function urlToBase64(url) {
|
|
4
|
+
const buffer = await fetch(url).then(async (res)=>await res.arrayBuffer());
|
|
5
|
+
const imageStr = encode(buffer);
|
|
6
|
+
const type = url.substring(url.lastIndexOf('.') + 1);
|
|
7
|
+
return `data:image/${type};base64,${imageStr}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=urlToBase64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/urlToBase64.ts"],"sourcesContent":["import fetch from 'node-fetch'\nimport { encode } from './base64.js'\n\n/** Converts a url to base 64. Useful for example, uploading/creating server emojis. */\nexport async function urlToBase64(url: string): Promise<string> {\n const buffer = await fetch(url).then(async (res) => await res.arrayBuffer())\n const imageStr = encode(buffer)\n const type = url.substring(url.lastIndexOf('.') + 1)\n return `data:image/${type};base64,${imageStr}`\n}\n"],"names":["fetch","encode","urlToBase64","url","buffer","then","res","arrayBuffer","imageStr","type","substring","lastIndexOf"],"mappings":"AAAA,OAAOA,WAAW,aAAY;AAC9B,SAASC,MAAM,QAAQ,cAAa;AAEpC,qFAAqF,GACrF,OAAO,eAAeC,YAAYC,GAAW,EAAmB;IAC9D,MAAMC,SAAS,MAAMJ,MAAMG,KAAKE,IAAI,CAAC,OAAOC,MAAQ,MAAMA,IAAIC,WAAW;IACzE,MAAMC,WAAWP,OAAOG;IACxB,MAAMK,OAAON,IAAIO,SAAS,CAACP,IAAIQ,WAAW,CAAC,OAAO;IAClD,OAAO,CAAC,WAAW,EAAEF,KAAK,QAAQ,EAAED,SAAS,CAAC;AAChD,CAAC"}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQrD;AAID,6DAA6D;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQrD;AAID,6DAA6D;AAE7D,wBAAgB,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,WAAW,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAGxH"}
|
package/dist/utils.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** Pause the execution for a given amount of milliseconds. */ export async function delay(ms) {
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/return-await
|
|
3
|
+
return new Promise((resolve)=>setTimeout(()=>{
|
|
4
|
+
resolve();
|
|
5
|
+
}, ms));
|
|
6
|
+
}
|
|
7
|
+
// Typescript is not so good as we developers so we need this little utility function to help it out
|
|
8
|
+
// Taken from https://fettblog.eu/typescript-hasownproperty/
|
|
9
|
+
/** TS save way to check if a property exists in an object */ // eslint-disable-next-line @typescript-eslint/ban-types
|
|
10
|
+
export function hasProperty(obj, prop) {
|
|
11
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
12
|
+
return obj.hasOwnProperty(prop);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["/** Pause the execution for a given amount of milliseconds. */\nexport async function delay(ms: number): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/return-await\n return new Promise(\n (resolve): NodeJS.Timeout =>\n setTimeout((): void => {\n resolve()\n }, ms),\n )\n}\n\n// Typescript is not so good as we developers so we need this little utility function to help it out\n// Taken from https://fettblog.eu/typescript-hasownproperty/\n/** TS save way to check if a property exists in an object */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasProperty<T extends {}, Y extends PropertyKey = string>(obj: T, prop: Y): obj is T & Record<Y, unknown> {\n // eslint-disable-next-line no-prototype-builtins\n return obj.hasOwnProperty(prop)\n}\n"],"names":["delay","ms","Promise","resolve","setTimeout","hasProperty","obj","prop","hasOwnProperty"],"mappings":"AAAA,4DAA4D,GAC5D,OAAO,eAAeA,MAAMC,EAAU,EAAiB;IACrD,2DAA2D;IAC3D,OAAO,IAAIC,QACT,CAACC,UACCC,WAAW,IAAY;YACrBD;QACF,GAAGF;AAET,CAAC;AAED,oGAAoG;AACpG,4DAA4D;AAC5D,2DAA2D,GAC3D,wDAAwD;AACxD,OAAO,SAASI,YAA0DC,GAAM,EAAEC,IAAO,EAAiC;IACxH,iDAAiD;IACjD,OAAOD,IAAIE,cAAc,CAACD;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordeno/utils",
|
|
3
|
-
"version": "19.0.0-next.
|
|
3
|
+
"version": "19.0.0-next.40c19da",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -23,24 +23,25 @@
|
|
|
23
23
|
"test:test-type": "tsc --project tsconfig.test.json"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@discordeno/types": "19.0.0-next.
|
|
26
|
+
"@discordeno/types": "19.0.0-next.40c19da",
|
|
27
|
+
"node-fetch": "^3.3.1",
|
|
27
28
|
"tweetnacl": "^1.0.3"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@swc/cli": "^0.1.
|
|
31
|
-
"@swc/core": "^1.3.
|
|
32
|
-
"@types/chai": "^4",
|
|
33
|
-
"@types/mocha": "^10",
|
|
34
|
-
"@types/node": "^18.
|
|
31
|
+
"@swc/cli": "^0.1.62",
|
|
32
|
+
"@swc/core": "^1.3.40",
|
|
33
|
+
"@types/chai": "^4.3.4",
|
|
34
|
+
"@types/mocha": "^10.0.1",
|
|
35
|
+
"@types/node": "^18.15.3",
|
|
35
36
|
"@types/sinon": "^10.0.13",
|
|
36
|
-
"c8": "^7.
|
|
37
|
+
"c8": "^7.13.0",
|
|
37
38
|
"chai": "^4.3.7",
|
|
38
|
-
"eslint": "^8.0
|
|
39
|
+
"eslint": "^8.36.0",
|
|
39
40
|
"eslint-config-discordeno": "*",
|
|
40
|
-
"mocha": "^10.
|
|
41
|
-
"sinon": "^15.0.
|
|
41
|
+
"mocha": "^10.2.0",
|
|
42
|
+
"sinon": "^15.0.2",
|
|
42
43
|
"ts-node": "^10.9.1",
|
|
43
44
|
"tsconfig": "*",
|
|
44
|
-
"typescript": "^4.9.
|
|
45
|
+
"typescript": "^4.9.5"
|
|
45
46
|
}
|
|
46
47
|
}
|