@ovencord/formatters 0.6.2 → 0.6.4
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/package.json +7 -18
- package/src/escapers.ts +4 -6
- package/src/formatters.ts +4 -3
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@ovencord/formatters",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.4",
|
|
5
5
|
"description": "A set of functions to format strings for Discord.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "bun test",
|
|
8
8
|
"typecheck": "tsc --noEmit",
|
|
9
|
-
"lint": "
|
|
9
|
+
"lint": "biome check .",
|
|
10
|
+
"format": "biome format --write .",
|
|
11
|
+
"check": "biome check --write ."
|
|
10
12
|
},
|
|
11
13
|
"exports": "./src/index.ts",
|
|
12
14
|
"main": "./src/index.ts",
|
|
@@ -31,24 +33,11 @@
|
|
|
31
33
|
"homepage": "https://ovencord.dev",
|
|
32
34
|
"funding": "https://github.com/ovencord/ovencord?sponsor",
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"discord-api-types": "^0.38.
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@favware/cliff-jumper": "^6.0.0",
|
|
38
|
-
"@vitest/coverage-v8": "^4.0.15",
|
|
39
|
-
"cross-env": "^10.1.0",
|
|
40
|
-
"esbuild-plugin-version-injector": "^1.2.1",
|
|
41
|
-
"eslint": "^9.39.2",
|
|
42
|
-
"eslint-formatter-compact": "^9.0.1",
|
|
43
|
-
"eslint-formatter-pretty": "^7.0.0",
|
|
44
|
-
"prettier": "^3.7.4",
|
|
45
|
-
"typescript": "^5.9.3",
|
|
46
|
-
"vitest": "^4.0.15",
|
|
47
|
-
"@types/bun": "latest",
|
|
48
|
-
"typescript-eslint": "^8.54.0"
|
|
36
|
+
"discord-api-types": "^0.38.40"
|
|
49
37
|
},
|
|
38
|
+
"devDependencies": {},
|
|
50
39
|
"engines": {
|
|
51
|
-
"bun": ">=1.
|
|
40
|
+
"bun": ">=1.3.0"
|
|
52
41
|
},
|
|
53
42
|
"publishConfig": {
|
|
54
43
|
"access": "public"
|
package/src/escapers.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable prefer-named-capture-group */
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* The options that affect what will be escaped.
|
|
5
3
|
*/
|
|
@@ -133,7 +131,7 @@ export function escapeMarkdown(text: string, options: EscapeMarkdownOptions = {}
|
|
|
133
131
|
spoiler = true,
|
|
134
132
|
codeBlockContent = true,
|
|
135
133
|
inlineCodeContent = true,
|
|
136
|
-
escape = true,
|
|
134
|
+
escape: shouldEscape = true,
|
|
137
135
|
heading = true,
|
|
138
136
|
bulletedList = true,
|
|
139
137
|
numberedList = true,
|
|
@@ -155,7 +153,7 @@ export function escapeMarkdown(text: string, options: EscapeMarkdownOptions = {}
|
|
|
155
153
|
strikethrough,
|
|
156
154
|
spoiler,
|
|
157
155
|
inlineCodeContent,
|
|
158
|
-
escape,
|
|
156
|
+
escape: shouldEscape,
|
|
159
157
|
heading,
|
|
160
158
|
bulletedList,
|
|
161
159
|
numberedList,
|
|
@@ -179,7 +177,7 @@ export function escapeMarkdown(text: string, options: EscapeMarkdownOptions = {}
|
|
|
179
177
|
underline,
|
|
180
178
|
strikethrough,
|
|
181
179
|
spoiler,
|
|
182
|
-
escape,
|
|
180
|
+
escape: shouldEscape,
|
|
183
181
|
heading,
|
|
184
182
|
bulletedList,
|
|
185
183
|
numberedList,
|
|
@@ -192,7 +190,7 @@ export function escapeMarkdown(text: string, options: EscapeMarkdownOptions = {}
|
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
let res = text;
|
|
195
|
-
if (
|
|
193
|
+
if (shouldEscape) res = escapeEscape(res);
|
|
196
194
|
if (inlineCode) res = escapeInlineCode(res);
|
|
197
195
|
if (codeBlock) res = escapeCodeBlock(res);
|
|
198
196
|
if (italic) res = escapeItalic(res);
|
package/src/formatters.ts
CHANGED
|
@@ -520,7 +520,6 @@ export function heading<Content extends string>(content: Content, level: Heading
|
|
|
520
520
|
export function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
|
521
521
|
|
|
522
522
|
export function heading(content: string, level?: HeadingLevel) {
|
|
523
|
-
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
524
523
|
switch (level) {
|
|
525
524
|
case HeadingLevel.Three:
|
|
526
525
|
return `### ${content}`;
|
|
@@ -617,7 +616,6 @@ export function time<Seconds extends number, Style extends TimestampStylesString
|
|
|
617
616
|
|
|
618
617
|
export function time(timeOrSeconds?: Date | number, style?: TimestampStylesString): string {
|
|
619
618
|
if (typeof timeOrSeconds !== 'number') {
|
|
620
|
-
// eslint-disable-next-line no-param-reassign
|
|
621
619
|
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1_000);
|
|
622
620
|
}
|
|
623
621
|
|
|
@@ -687,7 +685,10 @@ export function email<Email extends string>(
|
|
|
687
685
|
export function email<Email extends string>(email: Email, headers?: Record<string, string | readonly string[]>) {
|
|
688
686
|
if (headers) {
|
|
689
687
|
const searchParams = new URLSearchParams(
|
|
690
|
-
Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value])) as Record<
|
|
688
|
+
Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value])) as Record<
|
|
689
|
+
string,
|
|
690
|
+
string
|
|
691
|
+
>,
|
|
691
692
|
);
|
|
692
693
|
|
|
693
694
|
return `<${email}?${searchParams.toString()}>` as const;
|