@esposter/shared 2.36.0 → 2.38.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 +2 -2
- package/dist/index.d.ts +110 -99
- package/dist/index.js +275 -214
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -18,12 +18,12 @@ Shared TypeScript utilities, types, and error classes for the Esposter platform.
|
|
|
18
18
|
## <a name="getting-started">🚀 Getting Started</a>
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
pnpm i @esposter/shared
|
|
21
|
+
pnpm i @esposter/shared zod
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## <a name="documentation">📖 Documentation</a>
|
|
25
25
|
|
|
26
|
-
We highly recommend you take a look at the [documentation](https://esposter.com/docs/modules/
|
|
26
|
+
We highly recommend you take a look at the [documentation](https://esposter.com/docs/api/modules/_esposter_shared.html) to level up.
|
|
27
27
|
|
|
28
28
|
### Key Exports
|
|
29
29
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import baseSanitizeHtml from "sanitize-html";
|
|
3
|
-
declare const AllSpecialValues: {
|
|
3
|
+
export declare const AllSpecialValues: {
|
|
4
4
|
isPlainObject: boolean;
|
|
5
5
|
value: unknown;
|
|
6
6
|
}[];
|
|
7
|
-
declare class ForbiddenError extends Error {
|
|
7
|
+
export declare class ForbiddenError extends Error {
|
|
8
8
|
constructor(message: string);
|
|
9
9
|
}
|
|
10
|
-
declare enum Operation {
|
|
10
|
+
export declare enum Operation {
|
|
11
11
|
Create = "Create",
|
|
12
12
|
Delete = "Delete",
|
|
13
13
|
Push = "Push",
|
|
@@ -15,28 +15,28 @@ declare enum Operation {
|
|
|
15
15
|
Unshift = "Unshift",
|
|
16
16
|
Update = "Update"
|
|
17
17
|
}
|
|
18
|
-
declare class InvalidOperationError extends Error {
|
|
18
|
+
export declare class InvalidOperationError extends Error {
|
|
19
19
|
constructor(operation: Operation, name: string, message: string);
|
|
20
20
|
}
|
|
21
|
-
declare class NotFoundError<T extends string = string> extends Error {
|
|
21
|
+
export declare class NotFoundError<T extends string = string> extends Error {
|
|
22
22
|
constructor(name: T, id: string);
|
|
23
23
|
}
|
|
24
|
-
declare class NotInitializedError<T extends string = string> extends Error {
|
|
24
|
+
export declare class NotInitializedError<T extends string = string> extends Error {
|
|
25
25
|
constructor(name: T);
|
|
26
26
|
}
|
|
27
|
-
declare class WordFilteredError extends Error {
|
|
27
|
+
export declare class WordFilteredError extends Error {
|
|
28
28
|
constructor(message: string);
|
|
29
29
|
}
|
|
30
|
-
interface ClassifiedMentions {
|
|
30
|
+
export interface ClassifiedMentions {
|
|
31
31
|
broadcastIds: string[];
|
|
32
32
|
regularUserIds: string[];
|
|
33
33
|
roleIds: string[];
|
|
34
34
|
}
|
|
35
|
-
declare enum MentionType {
|
|
35
|
+
export declare enum MentionType {
|
|
36
36
|
Role = "role",
|
|
37
37
|
User = "user"
|
|
38
38
|
}
|
|
39
|
-
declare const RoutePath: {
|
|
39
|
+
export declare const RoutePath: {
|
|
40
40
|
readonly About: "/about";
|
|
41
41
|
readonly Achievements: "/achievements";
|
|
42
42
|
readonly Anime: "/anime";
|
|
@@ -55,65 +55,69 @@ declare const RoutePath: {
|
|
|
55
55
|
readonly MessagesIndex: "/messages";
|
|
56
56
|
readonly MessagesInvite: (code: string) => string;
|
|
57
57
|
readonly MessagesMessage: (id: string, rowKey: string) => string;
|
|
58
|
+
readonly MessagesThread: (id: string, rowKey: string) => string;
|
|
58
59
|
readonly Post: (id: string) => string;
|
|
59
60
|
readonly PostCreate: "/post/create";
|
|
60
61
|
readonly PostUpdate: (id: string) => string;
|
|
61
62
|
readonly PrivacyPolicy: "/privacy-policy";
|
|
62
63
|
readonly Resource: (id: string) => string;
|
|
64
|
+
readonly ResourceExplorer: "/resource-explorer";
|
|
65
|
+
readonly ResourceExplorerAll: "/resource-explorer/all";
|
|
66
|
+
readonly ResourceExplorerCreate: "/resource-explorer/create";
|
|
67
|
+
readonly ResourceExplorerCreateType: (type: string) => string;
|
|
68
|
+
readonly ResourceExplorerFavorites: "/resource-explorer/favorites";
|
|
69
|
+
readonly ResourceExplorerRecents: "/resource-explorer/recents";
|
|
70
|
+
readonly ResourceExplorerRecycleBin: "/resource-explorer/recycle-bin";
|
|
71
|
+
readonly ResourceExplorerTags: "/resource-explorer/tags";
|
|
63
72
|
readonly ResourceItems: (id: string) => string;
|
|
64
|
-
readonly Resources: "/resources";
|
|
65
|
-
readonly ResourcesAll: "/resources/all";
|
|
66
|
-
readonly ResourcesCreate: "/resources/create";
|
|
67
|
-
readonly ResourcesCreateType: (type: string) => string;
|
|
68
|
-
readonly ResourcesRecycleBin: "/resources/recycle-bin";
|
|
69
73
|
readonly User: (id: string) => string;
|
|
70
74
|
readonly UserSettings: "/user/settings";
|
|
71
75
|
readonly View: (type: string, id: string) => string;
|
|
72
76
|
};
|
|
73
|
-
type RoutePath = typeof RoutePath;
|
|
74
|
-
type GetArrayProps<T extends unknown[], P extends string, D extends unknown[], R extends boolean> = (D extends [unknown, ...infer Rest] ? GetProperties<T[number], R extends true ? `${P}[number]` : `${P}.[number]`, Rest, false> : never) | {
|
|
77
|
+
export type RoutePath = typeof RoutePath;
|
|
78
|
+
export type GetArrayProps<T extends unknown[], P extends string, D extends unknown[], R extends boolean> = (D extends [unknown, ...infer Rest] ? GetProperties<T[number], R extends true ? `${P}[number]` : `${P}.[number]`, Rest, false> : never) | {
|
|
75
79
|
path: R extends true ? "length" : `${P}.length`;
|
|
76
80
|
value: T["length"];
|
|
77
81
|
};
|
|
78
|
-
type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
|
|
79
|
-
type GetObjectProps<T, P extends string, D extends unknown[], R extends boolean> = { [K in keyof KnownKeys<T> & (number | string)]: K extends `${number}` ? never : NonNullable<T[K]> extends Function ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
|
|
82
|
+
export type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
|
|
83
|
+
export type GetObjectProps<T, P extends string, D extends unknown[], R extends boolean> = { [K in keyof KnownKeys<T> & (number | string)]: K extends `${number}` ? never : NonNullable<T[K]> extends Function ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
|
|
80
84
|
path: R extends true ? `${K}` : `${P}.${K}`;
|
|
81
85
|
value: T[K];
|
|
82
86
|
}; }[keyof KnownKeys<T> & (number | string)];
|
|
83
|
-
type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boolean> = T extends string ? {
|
|
87
|
+
export type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boolean> = T extends string ? {
|
|
84
88
|
path: R extends true ? "length" : `${P}.length`;
|
|
85
89
|
value: number;
|
|
86
90
|
} : T extends symbol ? (D extends [unknown, ...infer Rest] ? GetProperties<string | undefined, R extends true ? "description" : `${P}.description`, Rest, false> : never) | {
|
|
87
91
|
path: R extends true ? "description" : `${P}.description`;
|
|
88
92
|
value: string | undefined;
|
|
89
93
|
} : never;
|
|
90
|
-
type GetProperties<T, P extends string = "", D extends unknown[] = [unknown, unknown, unknown, unknown, unknown], R extends boolean = true> = [T] extends [never] ? never : D extends [] ? never : NonNullable<T> extends (infer O) ? O extends unknown[] ? GetArrayProps<O, P, D, R> : O extends object ? GetObjectProps<O, P, D, R> : GetPrimitiveProps<O, P, D, R> : never;
|
|
91
|
-
type GetPaths<T> = GetProperties<T> extends (infer U) ? (U extends {
|
|
94
|
+
export type GetProperties<T, P extends string = "", D extends unknown[] = [unknown, unknown, unknown, unknown, unknown], R extends boolean = true> = [T] extends [never] ? never : D extends [] ? never : NonNullable<T> extends (infer O) ? O extends unknown[] ? GetArrayProps<O, P, D, R> : O extends object ? GetObjectProps<O, P, D, R> : GetPrimitiveProps<O, P, D, R> : never;
|
|
95
|
+
export type GetPaths<T> = GetProperties<T> extends (infer U) ? (U extends {
|
|
92
96
|
path: infer Path;
|
|
93
97
|
} ? Path : never) : never;
|
|
94
|
-
type PropertyNames<T> = { [P in GetPaths<T>]: P; };
|
|
95
|
-
interface ItemEntityType<T extends string> {
|
|
98
|
+
export type PropertyNames<T> = { [P in GetPaths<T>]: P; };
|
|
99
|
+
export interface ItemEntityType<T extends string> {
|
|
96
100
|
type: T;
|
|
97
101
|
}
|
|
98
|
-
declare const ItemEntityTypePropertyNames: PropertyNames<ItemEntityType<string>>;
|
|
99
|
-
declare const createItemEntityTypeSchema: <T extends z.ZodType<string>>(schema: T) => z.ZodObject<{
|
|
102
|
+
export declare const ItemEntityTypePropertyNames: PropertyNames<ItemEntityType<string>>;
|
|
103
|
+
export declare const createItemEntityTypeSchema: <T extends z.ZodType<string>>(schema: T) => z.ZodObject<{
|
|
100
104
|
type: T;
|
|
101
105
|
}>;
|
|
102
|
-
declare class ItemMetadata {
|
|
106
|
+
export declare class ItemMetadata {
|
|
103
107
|
createdAt: Date;
|
|
104
108
|
deletedAt: Date | null;
|
|
105
109
|
updatedAt: Date;
|
|
106
110
|
}
|
|
107
|
-
declare const ItemMetadataPropertyNames: PropertyNames<ItemMetadata>;
|
|
108
|
-
declare const itemMetadataSchema: z.ZodObject<{
|
|
111
|
+
export declare const ItemMetadataPropertyNames: PropertyNames<ItemMetadata>;
|
|
112
|
+
export declare const itemMetadataSchema: z.ZodObject<{
|
|
109
113
|
createdAt: z.ZodDate;
|
|
110
114
|
deletedAt: z.ZodNullable<z.ZodDate>;
|
|
111
115
|
updatedAt: z.ZodDate;
|
|
112
116
|
}>;
|
|
113
|
-
declare abstract class Serializable {
|
|
117
|
+
export declare abstract class Serializable {
|
|
114
118
|
toJSON(): this;
|
|
115
119
|
}
|
|
116
|
-
interface TakeOne {
|
|
120
|
+
export interface TakeOne {
|
|
117
121
|
<T extends readonly unknown[]>(values: T, index?: number): T[number];
|
|
118
122
|
<T extends object | Record<PropertyKey, unknown>>(values: T, index: keyof T): T[keyof T];
|
|
119
123
|
}
|
|
@@ -1868,16 +1872,19 @@ const rawCliOptions: KebabCasedProperties<CliOptions> = {
|
|
|
1868
1872
|
@category Template literal
|
|
1869
1873
|
*/
|
|
1870
1874
|
type KebabCase<Value, Options extends WordsOptions = {}> = DelimiterCase<Value, '-', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
|
|
1871
|
-
type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | Function | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey>; } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey>; } : T;
|
|
1872
|
-
type DeepOptionalUndefined<T> = T extends Date | Function | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]>; } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]>; } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]>; } extends (infer O) ? { [K in keyof O]: O[K]; } : never : T;
|
|
1873
|
-
type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
|
|
1874
|
-
interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
|
|
1875
|
+
export type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | Function | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey>; } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey>; } : T;
|
|
1876
|
+
export type DeepOptionalUndefined<T> = T extends Date | Function | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]>; } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]>; } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]>; } extends (infer O) ? { [K in keyof O]: O[K]; } : never : T;
|
|
1877
|
+
export type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
|
|
1878
|
+
export interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
|
|
1875
1879
|
new (...args: ConstructorParameters<TBase>): InstanceType<TBase> & ItemMetadata;
|
|
1876
1880
|
prototype: InstanceType<TBase> & ItemMetadata;
|
|
1877
1881
|
}
|
|
1878
|
-
declare const MAX_READ_LIMIT =
|
|
1879
|
-
declare const SITE_NAME = "Esposter";
|
|
1880
|
-
declare const
|
|
1882
|
+
export declare const MAX_READ_LIMIT = 1e3;
|
|
1883
|
+
export declare const SITE_NAME = "Esposter";
|
|
1884
|
+
export declare const KIBIBYTE: number;
|
|
1885
|
+
export declare const MEGABYTE: number;
|
|
1886
|
+
export declare const GIBIBYTE: number;
|
|
1887
|
+
export declare const createExponentialBackoff: (baseDelayMs: number, maxDelayMs: number) => (<T>(operation: () => Promise<T>) => Promise<T>);
|
|
1881
1888
|
interface ErrorConfig {
|
|
1882
1889
|
withStackTrace: boolean;
|
|
1883
1890
|
}
|
|
@@ -2173,19 +2180,23 @@ declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [
|
|
|
2173
2180
|
declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result<infer Oks, infer Errs> ? Result<Oks, Errs[]> : never;
|
|
2174
2181
|
declare type CombineResults<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
|
|
2175
2182
|
declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
|
|
2176
|
-
declare const getResult: <T>(fn: () => T) => Result<T, Error>;
|
|
2177
|
-
declare const getResultAsync: <T>(fn: () => Promise<T>) => ResultAsync<T, Error>;
|
|
2178
|
-
declare const toAppError: (error: unknown) => Error;
|
|
2179
|
-
declare const withFinalizer: <T>(fn: () => T, finalizer?: () => void) => T;
|
|
2180
|
-
declare const withFinalizerAsync: <T>(fn: () => Promisable<T>, finalizer?: () => Promisable<void>) => Promise<T>;
|
|
2181
|
-
declare const classifyMentions: (message: string) => ClassifiedMentions;
|
|
2182
|
-
declare const MENTION_ID_ATTRIBUTE = "data-id";
|
|
2183
|
-
declare const MENTION_ITEM_TYPE_ATTRIBUTE = "data-mention-type";
|
|
2184
|
-
declare const MENTION_LABEL_ATTRIBUTE = "data-label";
|
|
2185
|
-
declare const MENTION_TYPE_ATTRIBUTE = "data-type";
|
|
2186
|
-
declare const MENTION_TYPE = "mention";
|
|
2187
|
-
declare const
|
|
2188
|
-
declare const
|
|
2183
|
+
export declare const getResult: <T>(fn: () => T) => Result<T, Error>;
|
|
2184
|
+
export declare const getResultAsync: <T>(fn: () => Promise<T>) => ResultAsync<T, Error>;
|
|
2185
|
+
export declare const toAppError: (error: unknown) => Error;
|
|
2186
|
+
export declare const withFinalizer: <T>(fn: () => T, finalizer?: () => void) => T;
|
|
2187
|
+
export declare const withFinalizerAsync: <T>(fn: () => Promisable<T>, finalizer?: () => Promisable<void>) => Promise<T>;
|
|
2188
|
+
export declare const classifyMentions: (message: string) => ClassifiedMentions;
|
|
2189
|
+
export declare const MENTION_ID_ATTRIBUTE = "data-id";
|
|
2190
|
+
export declare const MENTION_ITEM_TYPE_ATTRIBUTE = "data-mention-type";
|
|
2191
|
+
export declare const MENTION_LABEL_ATTRIBUTE = "data-label";
|
|
2192
|
+
export declare const MENTION_TYPE_ATTRIBUTE = "data-type";
|
|
2193
|
+
export declare const MENTION_TYPE = "mention";
|
|
2194
|
+
export declare const MENTION_SELECTOR: string;
|
|
2195
|
+
export declare const MENTION_HERE_ID = "@here";
|
|
2196
|
+
export declare const MENTION_EVERYONE_ID = "@everyone";
|
|
2197
|
+
export declare const CUSTOM_EMOJI_ID_ATTRIBUTE = "data-custom-emoji-id";
|
|
2198
|
+
export declare const CUSTOM_EMOJI_NAME_ATTRIBUTE = "data-custom-emoji-name";
|
|
2199
|
+
export declare const CUSTOM_EMOJI_TYPE = "customEmoji";
|
|
2189
2200
|
declare class VoidTag {
|
|
2190
2201
|
addClosingSlash: boolean;
|
|
2191
2202
|
private voidTags;
|
|
@@ -2477,51 +2488,51 @@ interface Options {
|
|
|
2477
2488
|
};
|
|
2478
2489
|
closeAllByClosing?: boolean;
|
|
2479
2490
|
}
|
|
2480
|
-
declare const getMentions: (message: string) => HTMLElement[];
|
|
2481
|
-
declare const css: typeof String.raw;
|
|
2482
|
-
declare const html: typeof String.raw;
|
|
2483
|
-
declare const sanitizeHtml: (...[html, options]: Parameters<typeof baseSanitizeHtml>) => string;
|
|
2484
|
-
declare const sanitizeTextHtml: (html: string) => string;
|
|
2485
|
-
declare const applyItemMetadataMixin: <TBase extends Class<NonNullable<unknown>>>(Base: TBase) => WithMetadata<TBase>;
|
|
2486
|
-
declare const chunk: <T>(array: T[], size: number) => T[][];
|
|
2487
|
-
declare const chunkBySerializedSize: <T>(items: T[], maxBytes: number, maxCount: number) => T[][];
|
|
2488
|
-
declare const takeOne: TakeOne;
|
|
2489
|
-
declare const getIsServer: () => boolean;
|
|
2490
|
-
declare const noop: () => void;
|
|
2491
|
-
declare const ID_SEPARATOR = "|";
|
|
2492
|
-
declare const UUID_LENGTH = 36;
|
|
2493
|
-
declare const getOrCreate: <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, create: () => TValue) => TValue;
|
|
2494
|
-
declare const checkIsPlainObject: (data: unknown) => data is object;
|
|
2495
|
-
declare const getPropertyNames: <T>() => PropertyNames<T>;
|
|
2496
|
-
declare const jsonDateParse: <T = any>(text: string) => T;
|
|
2497
|
-
type MergeObjectsStrict<T extends object[]> = T extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K]; } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T extends [infer TFirst] ? TFirst : never;
|
|
2498
|
-
declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
|
|
2499
|
-
declare const settleAll: <T>(tasks: (() => Promise<T>)[], concurrencyLimit?: number) => Promise<T[]>;
|
|
2500
|
-
declare const getRawData: <T>(data: T) => T;
|
|
2501
|
-
declare const toRawDeep: <T extends object>(data: T) => T;
|
|
2502
|
-
declare const capitalize: (string: string) => string;
|
|
2503
|
-
declare const encodeUrlSubDelimiters: (value: string) => string;
|
|
2504
|
-
declare const
|
|
2505
|
-
declare const
|
|
2506
|
-
declare const
|
|
2507
|
-
declare const
|
|
2508
|
-
declare const
|
|
2509
|
-
declare const
|
|
2510
|
-
declare const
|
|
2511
|
-
declare const
|
|
2512
|
-
declare const
|
|
2513
|
-
|
|
2514
|
-
type
|
|
2515
|
-
type
|
|
2516
|
-
type
|
|
2517
|
-
type
|
|
2518
|
-
type
|
|
2519
|
-
type
|
|
2520
|
-
type
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
type
|
|
2524
|
-
|
|
2525
|
-
declare const
|
|
2526
|
-
declare const
|
|
2527
|
-
export
|
|
2491
|
+
export declare const getMentions: (message: string) => HTMLElement[];
|
|
2492
|
+
export declare const css: typeof String.raw;
|
|
2493
|
+
export declare const html: typeof String.raw;
|
|
2494
|
+
export declare const sanitizeHtml: (...[html, options]: Parameters<typeof baseSanitizeHtml>) => string;
|
|
2495
|
+
export declare const sanitizeTextHtml: (html: string) => string;
|
|
2496
|
+
export declare const applyItemMetadataMixin: <TBase extends Class<NonNullable<unknown>>>(Base: TBase) => WithMetadata<TBase>;
|
|
2497
|
+
export declare const chunk: <T>(array: T[], size: number) => T[][];
|
|
2498
|
+
export declare const chunkBySerializedSize: <T>(items: T[], maxBytes: number, maxCount: number) => T[][];
|
|
2499
|
+
export declare const takeOne: TakeOne;
|
|
2500
|
+
export declare const getIsServer: () => boolean;
|
|
2501
|
+
export declare const noop: () => void;
|
|
2502
|
+
export declare const ID_SEPARATOR = "|";
|
|
2503
|
+
export declare const UUID_LENGTH = 36;
|
|
2504
|
+
export declare const getOrCreate: <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, create: () => TValue) => TValue;
|
|
2505
|
+
export declare const checkIsPlainObject: (data: unknown) => data is object;
|
|
2506
|
+
export declare const getPropertyNames: <T>() => PropertyNames<T>;
|
|
2507
|
+
export declare const jsonDateParse: <T = any>(text: string) => T;
|
|
2508
|
+
export type MergeObjectsStrict<T extends object[]> = T extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K]; } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T extends [infer TFirst] ? TFirst : never;
|
|
2509
|
+
export declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
|
|
2510
|
+
export declare const settleAll: <T>(tasks: (() => Promise<T>)[], concurrencyLimit?: number) => Promise<T[]>;
|
|
2511
|
+
export declare const getRawData: <T>(data: T) => T;
|
|
2512
|
+
export declare const toRawDeep: <T extends object>(data: T) => T;
|
|
2513
|
+
export declare const capitalize: (string: string) => string;
|
|
2514
|
+
export declare const encodeUrlSubDelimiters: (value: string) => string;
|
|
2515
|
+
export declare const getDecodedUriComponent: (value: string, fallback: string) => string;
|
|
2516
|
+
export declare const normalizeString: (value: null | string | undefined) => string;
|
|
2517
|
+
export declare const createNormalizedStringSchema: (maxLength: number, schema?: z.ZodString) => z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
2518
|
+
export declare const streamToText: (readable: NodeJS.ReadableStream) => Promise<string>;
|
|
2519
|
+
export declare const toKebabCase: <T extends string>(string: T) => KebabCase<T>;
|
|
2520
|
+
export declare const truncate: (string: string, length: number) => string;
|
|
2521
|
+
export declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
|
|
2522
|
+
export declare const hrtime: (previousHrTime?: [number, number]) => [number, number];
|
|
2523
|
+
export declare const now: () => string;
|
|
2524
|
+
export declare const sleep: (durationMs: number) => Promise<void>;
|
|
2525
|
+
export type BuildTuple<N extends number, T = unknown, R extends unknown[] = []> = R["length"] extends N ? R : BuildTuple<N, T, [...R, T]>;
|
|
2526
|
+
export type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never; };
|
|
2527
|
+
export type ExcludeFunctionProperties<T> = Except<T, FunctionProperties<T>[keyof T]>;
|
|
2528
|
+
export type MapValue<BaseType> = BaseType extends Map<unknown, infer ValueType> ? ValueType : never;
|
|
2529
|
+
export type TupleSplit<T extends unknown[], N extends number> = T extends [...BuildTuple<N>, ...infer R] ? [T extends [...infer H, ...R] ? H : BuildTuple<N, T[number]>, R] : [T, []];
|
|
2530
|
+
export type SkipFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[1];
|
|
2531
|
+
export type TakeFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[0];
|
|
2532
|
+
export type TupleSlice<T extends unknown[], S extends number, E extends number = T["length"]> = E extends T["length"] ? SkipFirst<T, S> : SkipFirst<TakeFirst<T, E>, S>;
|
|
2533
|
+
export declare const exhaustiveGuard: (value: never) => never;
|
|
2534
|
+
export type CreateUniqueArraySchema = (<TOutput extends object, TInput, TSchema extends z.ZodType<TOutput, TInput>>(schema: TSchema, key: UniqueArraySchemaKey<TSchema>) => z.ZodArray<TSchema>) & (<TSchema extends z.ZodType>(schema: TSchema) => z.ZodArray<TSchema>);
|
|
2535
|
+
export type UniqueArraySchemaKey<TSchema extends z.ZodType> = TSchema extends z.ZodObject ? keyof TSchema["shape"] & string : keyof z.output<TSchema> & string;
|
|
2536
|
+
export declare const createUniqueArraySchema: CreateUniqueArraySchema;
|
|
2537
|
+
export declare const UUIDV4_REGEX: RegExp;
|
|
2538
|
+
export declare const uuidValidateV4: (uuid: string) => boolean;
|
package/dist/index.js
CHANGED
|
@@ -122,6 +122,9 @@ let MentionType = /* @__PURE__ */ function(MentionType) {
|
|
|
122
122
|
}({});
|
|
123
123
|
const MAX_READ_LIMIT = 1e3;
|
|
124
124
|
const SITE_NAME = "Esposter";
|
|
125
|
+
const KIBIBYTE = 1024;
|
|
126
|
+
const MEGABYTE = KIBIBYTE ** 2;
|
|
127
|
+
const GIBIBYTE = MEGABYTE * KIBIBYTE;
|
|
125
128
|
const RoutePath = {
|
|
126
129
|
About: "/about",
|
|
127
130
|
Achievements: "/achievements",
|
|
@@ -141,17 +144,21 @@ const RoutePath = {
|
|
|
141
144
|
MessagesIndex: "/messages",
|
|
142
145
|
MessagesInvite: (code) => `/messages/invite/${code}`,
|
|
143
146
|
MessagesMessage: (id, rowKey) => `/messages/${id}/${rowKey}`,
|
|
147
|
+
MessagesThread: (id, rowKey) => `/messages/${id}/thread/${rowKey}`,
|
|
144
148
|
Post: (id) => `/post/${id}`,
|
|
145
149
|
PostCreate: "/post/create",
|
|
146
150
|
PostUpdate: (id) => `/post/update/${id}`,
|
|
147
151
|
PrivacyPolicy: "/privacy-policy",
|
|
148
|
-
Resource: (id) => `/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
Resource: (id) => `/resource-explorer/${id}`,
|
|
153
|
+
ResourceExplorer: "/resource-explorer",
|
|
154
|
+
ResourceExplorerAll: "/resource-explorer/all",
|
|
155
|
+
ResourceExplorerCreate: "/resource-explorer/create",
|
|
156
|
+
ResourceExplorerCreateType: (type) => `/resource-explorer/create/${type}`,
|
|
157
|
+
ResourceExplorerFavorites: "/resource-explorer/favorites",
|
|
158
|
+
ResourceExplorerRecents: "/resource-explorer/recents",
|
|
159
|
+
ResourceExplorerRecycleBin: "/resource-explorer/recycle-bin",
|
|
160
|
+
ResourceExplorerTags: "/resource-explorer/tags",
|
|
161
|
+
ResourceItems: (id) => `/resource-explorer/${id}/items`,
|
|
155
162
|
User: (id) => `/user/${id}`,
|
|
156
163
|
UserSettings: "/user/settings",
|
|
157
164
|
View: (type, id) => `/view/${type}/${id}`
|
|
@@ -711,8 +718,12 @@ const MENTION_ITEM_TYPE_ATTRIBUTE = "data-mention-type";
|
|
|
711
718
|
const MENTION_LABEL_ATTRIBUTE = "data-label";
|
|
712
719
|
const MENTION_TYPE_ATTRIBUTE = "data-type";
|
|
713
720
|
const MENTION_TYPE = "mention";
|
|
721
|
+
const MENTION_SELECTOR = `span[${MENTION_TYPE_ATTRIBUTE}='${MENTION_TYPE}']`;
|
|
714
722
|
const MENTION_HERE_ID = "@here";
|
|
715
723
|
const MENTION_EVERYONE_ID = "@everyone";
|
|
724
|
+
const CUSTOM_EMOJI_ID_ATTRIBUTE = "data-custom-emoji-id";
|
|
725
|
+
const CUSTOM_EMOJI_NAME_ATTRIBUTE = "data-custom-emoji-name";
|
|
726
|
+
const CUSTOM_EMOJI_TYPE = "customEmoji";
|
|
716
727
|
var __create = Object.create;
|
|
717
728
|
var __defProp = Object.defineProperty;
|
|
718
729
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5542,13 +5553,13 @@ parse.valid = valid;
|
|
|
5542
5553
|
parse.Node = Node$1;
|
|
5543
5554
|
parse.TextNode = TextNode;
|
|
5544
5555
|
parse.NodeType = NodeType;
|
|
5545
|
-
const getMentions = (message) => parse(message).querySelectorAll(
|
|
5556
|
+
const getMentions = (message) => parse(message).querySelectorAll(MENTION_SELECTOR);
|
|
5546
5557
|
const BROADCAST_MENTION_IDS = /* @__PURE__ */ new Set([MENTION_EVERYONE_ID, MENTION_HERE_ID]);
|
|
5547
5558
|
const classifyMentions = (message) => {
|
|
5548
|
-
const mentions = getMentions(message).map((
|
|
5549
|
-
id:
|
|
5550
|
-
type:
|
|
5551
|
-
})).filter((
|
|
5559
|
+
const mentions = getMentions(message).map((mention) => ({
|
|
5560
|
+
id: mention.getAttribute(MENTION_ID_ATTRIBUTE),
|
|
5561
|
+
type: mention.getAttribute(MENTION_ITEM_TYPE_ATTRIBUTE)
|
|
5562
|
+
})).filter((mention) => Boolean(mention.id));
|
|
5552
5563
|
return {
|
|
5553
5564
|
broadcastIds: mentions.filter(({ id }) => BROADCAST_MENTION_IDS.has(id)).map(({ id }) => id),
|
|
5554
5565
|
regularUserIds: mentions.filter(({ id, type }) => !BROADCAST_MENTION_IDS.has(id) && type !== "role").map(({ id }) => id),
|
|
@@ -6411,15 +6422,16 @@ var init_Tokenizer = __esmMin((() => {
|
|
|
6411
6422
|
if (c === CharCodes.ExclamationMark) {
|
|
6412
6423
|
this.state = State.BeforeDeclaration;
|
|
6413
6424
|
this.sectionStart = this.index + 1;
|
|
6414
|
-
} else if (c === CharCodes.Questionmark)
|
|
6415
|
-
this.
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6425
|
+
} else if (c === CharCodes.Questionmark) {
|
|
6426
|
+
if (this.xmlMode) {
|
|
6427
|
+
this.state = State.InProcessingInstruction;
|
|
6428
|
+
this.sequenceIndex = 0;
|
|
6429
|
+
this.sectionStart = this.index + 1;
|
|
6430
|
+
} else {
|
|
6431
|
+
this.state = State.InSpecialComment;
|
|
6432
|
+
this.sectionStart = this.index;
|
|
6433
|
+
}
|
|
6434
|
+
} else if (this.isTagStartChar(c)) {
|
|
6423
6435
|
this.sectionStart = this.index;
|
|
6424
6436
|
const special = this.xmlMode || this.cbs.isInForeignContext?.() ? void 0 : specialStartSequences.get(c | 32);
|
|
6425
6437
|
if (special === void 0) this.state = State.InTagName;
|
|
@@ -6444,11 +6456,12 @@ var init_Tokenizer = __esmMin((() => {
|
|
|
6444
6456
|
}
|
|
6445
6457
|
}
|
|
6446
6458
|
stateBeforeClosingTagName(c) {
|
|
6447
|
-
if (isWhitespace(c))
|
|
6448
|
-
this.
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6459
|
+
if (isWhitespace(c)) {
|
|
6460
|
+
if (this.xmlMode) {} else {
|
|
6461
|
+
this.state = State.InSpecialComment;
|
|
6462
|
+
this.sectionStart = this.index;
|
|
6463
|
+
}
|
|
6464
|
+
} else if (c === CharCodes.Gt) {
|
|
6452
6465
|
this.state = State.Text;
|
|
6453
6466
|
if (!this.xmlMode) this.sectionStart = this.index + 1;
|
|
6454
6467
|
} else {
|
|
@@ -6787,13 +6800,14 @@ var init_Tokenizer = __esmMin((() => {
|
|
|
6787
6800
|
}
|
|
6788
6801
|
handleTrailingCommentLikeData(endIndex) {
|
|
6789
6802
|
if (this.state !== State.InCommentLike) return false;
|
|
6790
|
-
if (this.currentSequence === Sequences.CdataEnd)
|
|
6791
|
-
if (this.
|
|
6803
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
6804
|
+
if (this.xmlMode) {
|
|
6805
|
+
if (this.sectionStart < endIndex) this.cbs.oncdata(this.sectionStart, endIndex, 0);
|
|
6806
|
+
} else {
|
|
6807
|
+
const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
|
|
6808
|
+
this.cbs.oncomment(cdataStart, endIndex, 0);
|
|
6809
|
+
}
|
|
6792
6810
|
} else {
|
|
6793
|
-
const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
|
|
6794
|
-
this.cbs.oncomment(cdataStart, endIndex, 0);
|
|
6795
|
-
}
|
|
6796
|
-
else {
|
|
6797
6811
|
const offset = this.xmlMode ? 0 : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);
|
|
6798
6812
|
this.cbs.oncomment(this.sectionStart, endIndex, offset);
|
|
6799
6813
|
}
|
|
@@ -8986,7 +9000,6 @@ var require_escape_string_regexp = /* @__PURE__ */ __commonJSMin$1(((exports, mo
|
|
|
8986
9000
|
};
|
|
8987
9001
|
}));
|
|
8988
9002
|
var require_is_plain_object = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
8989
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8990
9003
|
/*!
|
|
8991
9004
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
8992
9005
|
*
|
|
@@ -9141,39 +9154,43 @@ var require_parse_srcset = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
|
|
|
9141
9154
|
state = "in descriptor";
|
|
9142
9155
|
while (true) {
|
|
9143
9156
|
c = input.charAt(pos);
|
|
9144
|
-
if (state === "in descriptor")
|
|
9145
|
-
if (
|
|
9157
|
+
if (state === "in descriptor") {
|
|
9158
|
+
if (isSpace(c)) {
|
|
9159
|
+
if (currentDescriptor) {
|
|
9160
|
+
descriptors.push(currentDescriptor);
|
|
9161
|
+
currentDescriptor = "";
|
|
9162
|
+
state = "after descriptor";
|
|
9163
|
+
}
|
|
9164
|
+
} else if (c === ",") {
|
|
9165
|
+
pos += 1;
|
|
9166
|
+
if (currentDescriptor) descriptors.push(currentDescriptor);
|
|
9167
|
+
parseDescriptors();
|
|
9168
|
+
return;
|
|
9169
|
+
} else if (c === "(") {
|
|
9170
|
+
currentDescriptor = currentDescriptor + c;
|
|
9171
|
+
state = "in parens";
|
|
9172
|
+
} else if (c === "") {
|
|
9173
|
+
if (currentDescriptor) descriptors.push(currentDescriptor);
|
|
9174
|
+
parseDescriptors();
|
|
9175
|
+
return;
|
|
9176
|
+
} else currentDescriptor = currentDescriptor + c;
|
|
9177
|
+
} else if (state === "in parens") {
|
|
9178
|
+
if (c === ")") {
|
|
9179
|
+
currentDescriptor = currentDescriptor + c;
|
|
9180
|
+
state = "in descriptor";
|
|
9181
|
+
} else if (c === "") {
|
|
9146
9182
|
descriptors.push(currentDescriptor);
|
|
9147
|
-
|
|
9148
|
-
|
|
9183
|
+
parseDescriptors();
|
|
9184
|
+
return;
|
|
9185
|
+
} else currentDescriptor = currentDescriptor + c;
|
|
9186
|
+
} else if (state === "after descriptor") {
|
|
9187
|
+
if (isSpace(c)) {} else if (c === "") {
|
|
9188
|
+
parseDescriptors();
|
|
9189
|
+
return;
|
|
9190
|
+
} else {
|
|
9191
|
+
state = "in descriptor";
|
|
9192
|
+
pos -= 1;
|
|
9149
9193
|
}
|
|
9150
|
-
} else if (c === ",") {
|
|
9151
|
-
pos += 1;
|
|
9152
|
-
if (currentDescriptor) descriptors.push(currentDescriptor);
|
|
9153
|
-
parseDescriptors();
|
|
9154
|
-
return;
|
|
9155
|
-
} else if (c === "(") {
|
|
9156
|
-
currentDescriptor = currentDescriptor + c;
|
|
9157
|
-
state = "in parens";
|
|
9158
|
-
} else if (c === "") {
|
|
9159
|
-
if (currentDescriptor) descriptors.push(currentDescriptor);
|
|
9160
|
-
parseDescriptors();
|
|
9161
|
-
return;
|
|
9162
|
-
} else currentDescriptor = currentDescriptor + c;
|
|
9163
|
-
else if (state === "in parens") if (c === ")") {
|
|
9164
|
-
currentDescriptor = currentDescriptor + c;
|
|
9165
|
-
state = "in descriptor";
|
|
9166
|
-
} else if (c === "") {
|
|
9167
|
-
descriptors.push(currentDescriptor);
|
|
9168
|
-
parseDescriptors();
|
|
9169
|
-
return;
|
|
9170
|
-
} else currentDescriptor = currentDescriptor + c;
|
|
9171
|
-
else if (state === "after descriptor") if (isSpace(c)) {} else if (c === "") {
|
|
9172
|
-
parseDescriptors();
|
|
9173
|
-
return;
|
|
9174
|
-
} else {
|
|
9175
|
-
state = "in descriptor";
|
|
9176
|
-
pos -= 1;
|
|
9177
9194
|
}
|
|
9178
9195
|
pos += 1;
|
|
9179
9196
|
}
|
|
@@ -9278,14 +9295,16 @@ var require_css_syntax_error = /* @__PURE__ */ __commonJSMin$1(((exports, module
|
|
|
9278
9295
|
if (file) this.file = file;
|
|
9279
9296
|
if (source) this.source = source;
|
|
9280
9297
|
if (plugin) this.plugin = plugin;
|
|
9281
|
-
if (typeof line !== "undefined" && typeof column !== "undefined")
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9298
|
+
if (typeof line !== "undefined" && typeof column !== "undefined") {
|
|
9299
|
+
if (typeof line === "number") {
|
|
9300
|
+
this.line = line;
|
|
9301
|
+
this.column = column;
|
|
9302
|
+
} else {
|
|
9303
|
+
this.line = line.line;
|
|
9304
|
+
this.column = line.column;
|
|
9305
|
+
this.endLine = column.line;
|
|
9306
|
+
this.endColumn = column.column;
|
|
9307
|
+
}
|
|
9289
9308
|
}
|
|
9290
9309
|
this.setMessage();
|
|
9291
9310
|
if (Error.captureStackTrace) Error.captureStackTrace(this, CssSyntaxError);
|
|
@@ -9975,21 +9994,23 @@ var require_node = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
9975
9994
|
fixed[name] = fixedArray;
|
|
9976
9995
|
for (let i = 0; i < value.length; i++) {
|
|
9977
9996
|
let item = value[i];
|
|
9978
|
-
if (typeof item === "object" && item.toJSON)
|
|
9979
|
-
item
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9997
|
+
if (typeof item === "object" && item.toJSON) {
|
|
9998
|
+
if (item.toJSON === Node.prototype.toJSON) queue.push([
|
|
9999
|
+
item,
|
|
10000
|
+
fixedArray,
|
|
10001
|
+
i
|
|
10002
|
+
]);
|
|
10003
|
+
else fixedArray[i] = item.toJSON(null, inputs);
|
|
10004
|
+
} else fixedArray[i] = item;
|
|
9985
10005
|
}
|
|
9986
|
-
} else if (typeof value === "object" && value.toJSON)
|
|
9987
|
-
value
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
10006
|
+
} else if (typeof value === "object" && value.toJSON) {
|
|
10007
|
+
if (value.toJSON === Node.prototype.toJSON) queue.push([
|
|
10008
|
+
value,
|
|
10009
|
+
fixed,
|
|
10010
|
+
name
|
|
10011
|
+
]);
|
|
10012
|
+
else fixed[name] = value.toJSON(null, inputs);
|
|
10013
|
+
} else if (name === "source") {
|
|
9993
10014
|
if (value == null) continue;
|
|
9994
10015
|
let inputId = inputs.get(value.input);
|
|
9995
10016
|
if (inputId == null) {
|
|
@@ -10460,9 +10481,16 @@ var require_non_secure = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
10460
10481
|
}));
|
|
10461
10482
|
var require_lib = /* @__PURE__ */ __commonJSMin$1((() => {}));
|
|
10462
10483
|
var require_previous_map = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
10463
|
-
let { existsSync, readFileSync } = require_lib();
|
|
10484
|
+
let { existsSync, readFileSync, realpathSync } = require_lib();
|
|
10464
10485
|
let { dirname, isAbsolute, join, relative, sep } = require_lib();
|
|
10465
10486
|
let { SourceMapConsumer, SourceMapGenerator } = require_lib();
|
|
10487
|
+
function realPath(path) {
|
|
10488
|
+
try {
|
|
10489
|
+
return realpathSync(path);
|
|
10490
|
+
} catch {
|
|
10491
|
+
return path;
|
|
10492
|
+
}
|
|
10493
|
+
}
|
|
10466
10494
|
function fromBase64(str) {
|
|
10467
10495
|
if (Buffer) return Buffer.from(str, "base64").toString();
|
|
10468
10496
|
else
|
|
@@ -10514,7 +10542,7 @@ var require_previous_map = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
|
|
|
10514
10542
|
if (!trusted && !this.unsafeMap) {
|
|
10515
10543
|
if (!/\.map$/i.test(path)) return void 0;
|
|
10516
10544
|
if (!cssFile) return void 0;
|
|
10517
|
-
let rel = relative(dirname(cssFile), path);
|
|
10545
|
+
let rel = relative(realPath(dirname(cssFile)), realPath(path));
|
|
10518
10546
|
if (rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel)) return;
|
|
10519
10547
|
}
|
|
10520
10548
|
this.root = dirname(path);
|
|
@@ -10525,19 +10553,20 @@ var require_previous_map = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
|
|
|
10525
10553
|
}
|
|
10526
10554
|
loadMap(file, prev) {
|
|
10527
10555
|
if (prev === false) return false;
|
|
10528
|
-
if (prev)
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10556
|
+
if (prev) {
|
|
10557
|
+
if (typeof prev === "string") return prev;
|
|
10558
|
+
else if (typeof prev === "function") {
|
|
10559
|
+
let prevPath = prev(file);
|
|
10560
|
+
if (prevPath) {
|
|
10561
|
+
let map = this.loadFile(prevPath, file, true);
|
|
10562
|
+
if (!map) throw new Error("Unable to load previous source map: " + prevPath.toString());
|
|
10563
|
+
return map;
|
|
10564
|
+
}
|
|
10565
|
+
} else if (prev instanceof SourceMapConsumer) return SourceMapGenerator.fromSourceMap(prev).toString();
|
|
10566
|
+
else if (prev instanceof SourceMapGenerator) return prev.toString();
|
|
10567
|
+
else if (this.isMap(prev)) return JSON.stringify(prev);
|
|
10568
|
+
else throw new Error("Unsupported previous source map format: " + prev.toString());
|
|
10569
|
+
} else if (this.inline) return this.decodeInline(this.annotation);
|
|
10541
10570
|
else if (this.annotation) {
|
|
10542
10571
|
let map = this.annotation;
|
|
10543
10572
|
if (file) map = join(dirname(file), map);
|
|
@@ -10598,8 +10627,10 @@ var require_input = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
10598
10627
|
} else this.hasBOM = false;
|
|
10599
10628
|
this.document = this.css;
|
|
10600
10629
|
if (opts.document) this.document = opts.document.toString();
|
|
10601
|
-
if (opts.from)
|
|
10602
|
-
|
|
10630
|
+
if (opts.from) {
|
|
10631
|
+
if (!pathAvailable || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) this.file = opts.from;
|
|
10632
|
+
else this.file = resolve(opts.from);
|
|
10633
|
+
}
|
|
10603
10634
|
if (pathAvailable && sourceMapAvailable) {
|
|
10604
10635
|
let map = new PreviousMap(this.css, opts);
|
|
10605
10636
|
if (map.text) {
|
|
@@ -10728,10 +10759,12 @@ var require_input = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
10728
10759
|
line: from.line,
|
|
10729
10760
|
url: fromUrl.toString()
|
|
10730
10761
|
};
|
|
10731
|
-
if (fromUrl.protocol === "file:")
|
|
10732
|
-
|
|
10762
|
+
if (fromUrl.protocol === "file:") {
|
|
10763
|
+
if (fileURLToPath) result.file = fileURLToPath(fromUrl);
|
|
10764
|
+
else
|
|
10733
10765
|
/* c8 ignore next 2 */
|
|
10734
|
-
|
|
10766
|
+
throw new Error(`file: protocol is not available in this PostCSS build`);
|
|
10767
|
+
}
|
|
10735
10768
|
let source = consumer.sourceContentFor(from.source);
|
|
10736
10769
|
if (source) result.source = source;
|
|
10737
10770
|
return result;
|
|
@@ -10770,9 +10803,10 @@ var require_root = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
10770
10803
|
for (let node of Array.isArray(child) ? child : [child]) if (node && typeof node === "object" && !node.parent && node.raws && typeof node.raws.before !== "undefined") keepBefore.add(node.raws);
|
|
10771
10804
|
let nodes = super.normalize(child);
|
|
10772
10805
|
if (sample) {
|
|
10773
|
-
if (type === "prepend")
|
|
10774
|
-
|
|
10775
|
-
|
|
10806
|
+
if (type === "prepend") {
|
|
10807
|
+
if (this.nodes.length > 1) sample.raws.before = this.nodes[1].raws.before;
|
|
10808
|
+
else delete sample.raws.before;
|
|
10809
|
+
} else if (this.first !== sample) {
|
|
10776
10810
|
for (let node of nodes) if (!keepBefore.has(node.raws)) node.raws.before = sample.raws.before;
|
|
10777
10811
|
}
|
|
10778
10812
|
}
|
|
@@ -10810,7 +10844,7 @@ var require_list = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
10810
10844
|
]);
|
|
10811
10845
|
},
|
|
10812
10846
|
split(string, separators, last) {
|
|
10813
|
-
if (
|
|
10847
|
+
if (typeof string !== "string") return [];
|
|
10814
10848
|
let array = [];
|
|
10815
10849
|
let current = "";
|
|
10816
10850
|
let split = false;
|
|
@@ -11091,20 +11125,22 @@ var require_map_generator = /* @__PURE__ */ __commonJSMin$1(((exports, module) =
|
|
|
11091
11125
|
} else column += str.length;
|
|
11092
11126
|
if (node && type !== "start") {
|
|
11093
11127
|
let p = node.parent || { raws: {} };
|
|
11094
|
-
if (!(node.type === "decl" || node.type === "atrule" && !node.nodes) || node !== p.last || p.raws.semicolon)
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11128
|
+
if (!(node.type === "decl" || node.type === "atrule" && !node.nodes) || node !== p.last || p.raws.semicolon) {
|
|
11129
|
+
if (node.source && node.source.end) {
|
|
11130
|
+
mapping.source = this.sourcePath(node);
|
|
11131
|
+
mapping.original.line = node.source.end.line;
|
|
11132
|
+
mapping.original.column = node.source.end.column - 1;
|
|
11133
|
+
mapping.generated.line = line;
|
|
11134
|
+
mapping.generated.column = column - 2;
|
|
11135
|
+
this.map.addMapping(mapping);
|
|
11136
|
+
} else {
|
|
11137
|
+
mapping.source = noSource;
|
|
11138
|
+
mapping.original.line = 1;
|
|
11139
|
+
mapping.original.column = 0;
|
|
11140
|
+
mapping.generated.line = line;
|
|
11141
|
+
mapping.generated.column = column - 1;
|
|
11142
|
+
this.map.addMapping(mapping);
|
|
11143
|
+
}
|
|
11108
11144
|
}
|
|
11109
11145
|
}
|
|
11110
11146
|
});
|
|
@@ -11295,10 +11331,12 @@ var require_tokenize = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11295
11331
|
do {
|
|
11296
11332
|
escaped = false;
|
|
11297
11333
|
next = css.indexOf(")", next + 1);
|
|
11298
|
-
if (next === -1)
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11334
|
+
if (next === -1) {
|
|
11335
|
+
if (ignore || ignoreUnclosed) {
|
|
11336
|
+
next = pos;
|
|
11337
|
+
break;
|
|
11338
|
+
} else unclosed("bracket");
|
|
11339
|
+
}
|
|
11302
11340
|
escapePos = next;
|
|
11303
11341
|
while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
|
|
11304
11342
|
escapePos -= 1;
|
|
@@ -11345,10 +11383,12 @@ var require_tokenize = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11345
11383
|
do {
|
|
11346
11384
|
escaped = false;
|
|
11347
11385
|
next = css.indexOf(quote, next + 1);
|
|
11348
|
-
if (next === -1)
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11386
|
+
if (next === -1) {
|
|
11387
|
+
if (ignore || ignoreUnclosed) {
|
|
11388
|
+
next = pos + 1;
|
|
11389
|
+
break;
|
|
11390
|
+
} else unclosed("string");
|
|
11391
|
+
}
|
|
11352
11392
|
escapePos = next;
|
|
11353
11393
|
while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
|
|
11354
11394
|
escapePos -= 1;
|
|
@@ -11401,8 +11441,10 @@ var require_tokenize = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11401
11441
|
break;
|
|
11402
11442
|
default: if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
|
|
11403
11443
|
next = css.indexOf("*/", pos + 2) + 1;
|
|
11404
|
-
if (next === 0)
|
|
11405
|
-
|
|
11444
|
+
if (next === 0) {
|
|
11445
|
+
if (ignore || ignoreUnclosed) next = css.length;
|
|
11446
|
+
else unclosed("comment");
|
|
11447
|
+
}
|
|
11406
11448
|
currentToken = [
|
|
11407
11449
|
"comment",
|
|
11408
11450
|
css.slice(pos, next + 1),
|
|
@@ -11497,28 +11539,29 @@ var require_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11497
11539
|
if (type === "(" || type === "[") brackets.push(type === "(" ? ")" : "]");
|
|
11498
11540
|
else if (type === "{" && brackets.length > 0) brackets.push("}");
|
|
11499
11541
|
else if (type === brackets[brackets.length - 1]) brackets.pop();
|
|
11500
|
-
if (brackets.length === 0)
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
if (
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11542
|
+
if (brackets.length === 0) {
|
|
11543
|
+
if (type === ";") {
|
|
11544
|
+
node.source.end = this.getPosition(token[2]);
|
|
11545
|
+
node.source.end.offset++;
|
|
11546
|
+
this.semicolon = true;
|
|
11547
|
+
break;
|
|
11548
|
+
} else if (type === "{") {
|
|
11549
|
+
open = true;
|
|
11550
|
+
break;
|
|
11551
|
+
} else if (type === "}") {
|
|
11552
|
+
if (params.length > 0) {
|
|
11553
|
+
shift = params.length - 1;
|
|
11554
|
+
prev = params[shift];
|
|
11555
|
+
while (prev && prev[0] === "space") prev = params[--shift];
|
|
11556
|
+
if (prev) {
|
|
11557
|
+
node.source.end = this.getPosition(prev[3] || prev[2]);
|
|
11558
|
+
node.source.end.offset++;
|
|
11559
|
+
}
|
|
11516
11560
|
}
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11561
|
+
this.end(token);
|
|
11562
|
+
break;
|
|
11563
|
+
} else params.push(token);
|
|
11520
11564
|
} else params.push(token);
|
|
11521
|
-
else params.push(token);
|
|
11522
11565
|
if (this.tokenizer.endOfFile()) {
|
|
11523
11566
|
last = true;
|
|
11524
11567
|
break;
|
|
@@ -11566,9 +11609,11 @@ var require_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11566
11609
|
type = token[0];
|
|
11567
11610
|
if (type === "(") brackets += 1;
|
|
11568
11611
|
if (type === ")") brackets -= 1;
|
|
11569
|
-
if (brackets === 0 && type === ":")
|
|
11570
|
-
|
|
11571
|
-
|
|
11612
|
+
if (brackets === 0 && type === ":") {
|
|
11613
|
+
if (!prev) this.doubleColon(token);
|
|
11614
|
+
else if (prev[0] === "word" && prev[1] === "progid") continue;
|
|
11615
|
+
else return i;
|
|
11616
|
+
}
|
|
11572
11617
|
prev = token;
|
|
11573
11618
|
}
|
|
11574
11619
|
return false;
|
|
@@ -11746,11 +11791,12 @@ var require_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11746
11791
|
if (!bracket) bracket = token;
|
|
11747
11792
|
brackets.push("}");
|
|
11748
11793
|
} else if (brackets.length === 0) {
|
|
11749
|
-
if (type === ";")
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11794
|
+
if (type === ";") {
|
|
11795
|
+
if (colon) {
|
|
11796
|
+
this.decl(tokens, customProperty);
|
|
11797
|
+
return;
|
|
11798
|
+
} else break;
|
|
11799
|
+
} else if (type === "{") {
|
|
11754
11800
|
this.rule(tokens);
|
|
11755
11801
|
return;
|
|
11756
11802
|
} else if (type === "}") {
|
|
@@ -11817,9 +11863,10 @@ var require_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
11817
11863
|
else if (type === "comment") {
|
|
11818
11864
|
prev = tokens[i - 1] ? tokens[i - 1][0] : "empty";
|
|
11819
11865
|
next = tokens[i + 1] ? tokens[i + 1][0] : "empty";
|
|
11820
|
-
if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next])
|
|
11821
|
-
|
|
11822
|
-
|
|
11866
|
+
if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
|
|
11867
|
+
if (value.slice(-1) === ",") clean = false;
|
|
11868
|
+
else value += token[1];
|
|
11869
|
+
} else clean = false;
|
|
11823
11870
|
} else value += token[1];
|
|
11824
11871
|
}
|
|
11825
11872
|
if (!clean) {
|
|
@@ -12302,8 +12349,10 @@ var require_lazy_result = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
|
|
|
12302
12349
|
root[isClean] = true;
|
|
12303
12350
|
this.walkSync(root);
|
|
12304
12351
|
}
|
|
12305
|
-
if (this.listeners.OnceExit)
|
|
12306
|
-
|
|
12352
|
+
if (this.listeners.OnceExit) {
|
|
12353
|
+
if (root.type === "document") for (let subRoot of root.nodes) this.visitSync(this.listeners.OnceExit, subRoot);
|
|
12354
|
+
else this.visitSync(this.listeners.OnceExit, root);
|
|
12355
|
+
}
|
|
12307
12356
|
}
|
|
12308
12357
|
return this.result;
|
|
12309
12358
|
}
|
|
@@ -12552,7 +12601,7 @@ var require_processor = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
12552
12601
|
let Root = require_root();
|
|
12553
12602
|
var Processor = class {
|
|
12554
12603
|
constructor(plugins = []) {
|
|
12555
|
-
this.version = "8.5.
|
|
12604
|
+
this.version = "8.5.26";
|
|
12556
12605
|
this.plugins = this.normalize(plugins);
|
|
12557
12606
|
}
|
|
12558
12607
|
normalize(plugins) {
|
|
@@ -12995,8 +13044,10 @@ var require_launder = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
12995
13044
|
return tag.toLowerCase();
|
|
12996
13045
|
};
|
|
12997
13046
|
self.string = function(s, def) {
|
|
12998
|
-
if (typeof s !== "string")
|
|
12999
|
-
|
|
13047
|
+
if (typeof s !== "string") {
|
|
13048
|
+
if (typeof s === "number" || typeof s === "boolean") s += "";
|
|
13049
|
+
else s = "";
|
|
13050
|
+
}
|
|
13000
13051
|
s = s.trim();
|
|
13001
13052
|
if (def !== void 0) {
|
|
13002
13053
|
if (s === "") s = def;
|
|
@@ -13214,6 +13265,14 @@ var import_sanitize_html = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJS
|
|
|
13214
13265
|
"embed"
|
|
13215
13266
|
];
|
|
13216
13267
|
const vulnerableTags = ["script", "style"];
|
|
13268
|
+
const svgAnimationTags = [
|
|
13269
|
+
"animate",
|
|
13270
|
+
"animatecolor",
|
|
13271
|
+
"animatemotion",
|
|
13272
|
+
"animatetransform",
|
|
13273
|
+
"set"
|
|
13274
|
+
];
|
|
13275
|
+
const alwaysUrlAttributes = ["href"];
|
|
13217
13276
|
function each(obj, cb) {
|
|
13218
13277
|
if (obj) Object.keys(obj).forEach(function(key) {
|
|
13219
13278
|
cb(obj[key], key);
|
|
@@ -13362,7 +13421,7 @@ var import_sanitize_html = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJS
|
|
|
13362
13421
|
transformMap[depth] = transformedTag.tagName;
|
|
13363
13422
|
}
|
|
13364
13423
|
}
|
|
13365
|
-
if (!tagAllowed(name) || options.disallowedTagsMode === "recursiveEscape" && !isEmptyObject(skipMap) || options.nestingLimit != null && depth >= options.nestingLimit) {
|
|
13424
|
+
if (!tagAllowed(name) || animatesUrlAttribute(name, attribs) || options.disallowedTagsMode === "recursiveEscape" && !isEmptyObject(skipMap) || options.nestingLimit != null && depth >= options.nestingLimit) {
|
|
13366
13425
|
skip = true;
|
|
13367
13426
|
skipMap[depth] = true;
|
|
13368
13427
|
if (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") {
|
|
@@ -13410,8 +13469,10 @@ var import_sanitize_html = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJS
|
|
|
13410
13469
|
let newValue = "";
|
|
13411
13470
|
if (o.multiple === true) {
|
|
13412
13471
|
const splitStrArray = value.split(" ");
|
|
13413
|
-
for (const s of splitStrArray) if (o.values.indexOf(s) !== -1)
|
|
13414
|
-
|
|
13472
|
+
for (const s of splitStrArray) if (o.values.indexOf(s) !== -1) {
|
|
13473
|
+
if (newValue === "") newValue = s;
|
|
13474
|
+
else newValue += " " + s;
|
|
13475
|
+
}
|
|
13415
13476
|
} else if (o.values.indexOf(value) >= 0) newValue = value;
|
|
13416
13477
|
value = newValue;
|
|
13417
13478
|
}
|
|
@@ -13548,9 +13609,10 @@ var import_sanitize_html = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJS
|
|
|
13548
13609
|
}
|
|
13549
13610
|
if (options.disallowedTagsMode === "completelyDiscard" && !tagAllowed(tag)) text = "";
|
|
13550
13611
|
else if (tag && tagAllowed(tag) && (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") && (tag === "script" || tag === "style")) result += text;
|
|
13551
|
-
else if (tag && tagAllowed(tag) && (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") && (tag === "textarea" || tag === "xmp"))
|
|
13552
|
-
|
|
13553
|
-
|
|
13612
|
+
else if (tag && tagAllowed(tag) && (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") && (tag === "textarea" || tag === "xmp")) {
|
|
13613
|
+
if (tag === "xmp") result += text.replace(/</g, "<").replace(/>/g, ">");
|
|
13614
|
+
else result += escapeHtml(text, false);
|
|
13615
|
+
} else if (!addedText) {
|
|
13554
13616
|
const escaped = escapeHtml(text, false);
|
|
13555
13617
|
if (options.textFilter) result += options.textFilter(escaped, tag);
|
|
13556
13618
|
else result += escaped;
|
|
@@ -13656,6 +13718,16 @@ var import_sanitize_html = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJS
|
|
|
13656
13718
|
allowProtocolRelative: options.allowProtocolRelative
|
|
13657
13719
|
});
|
|
13658
13720
|
}
|
|
13721
|
+
function animatesUrlAttribute(name, attribs) {
|
|
13722
|
+
if (svgAnimationTags.indexOf(name.toLowerCase()) === -1) return false;
|
|
13723
|
+
const schemeCheckedAttributes = options.allowedSchemesAppliedToAttributes || [];
|
|
13724
|
+
return Object.keys(attribs || {}).some(function(attributeName) {
|
|
13725
|
+
if (attributeName.toLowerCase() !== "attributename") return false;
|
|
13726
|
+
const target = (attribs[attributeName] || "").trim().toLowerCase();
|
|
13727
|
+
const localName = target.slice(target.lastIndexOf(":") + 1);
|
|
13728
|
+
return alwaysUrlAttributes.indexOf(localName) !== -1 || schemeCheckedAttributes.indexOf(target) !== -1 || schemeCheckedAttributes.indexOf(localName) !== -1;
|
|
13729
|
+
});
|
|
13730
|
+
}
|
|
13659
13731
|
function parseUrl(value) {
|
|
13660
13732
|
value = value.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/, "$1//");
|
|
13661
13733
|
if (value.startsWith("relative:")) throw new Error("relative: exploit attempt");
|
|
@@ -14081,6 +14153,17 @@ var import_sanitize_html = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJS
|
|
|
14081
14153
|
};
|
|
14082
14154
|
};
|
|
14083
14155
|
})))(), 1);
|
|
14156
|
+
const appendStyle = (style, declarations) => style ? `${style}; ${declarations}` : declarations;
|
|
14157
|
+
const transformCellAlign = (tagName, attribs) => {
|
|
14158
|
+
if (attribs.align) {
|
|
14159
|
+
attribs.style = appendStyle(attribs.style, `text-align:${attribs.align}`);
|
|
14160
|
+
delete attribs.align;
|
|
14161
|
+
}
|
|
14162
|
+
return {
|
|
14163
|
+
attribs,
|
|
14164
|
+
tagName
|
|
14165
|
+
};
|
|
14166
|
+
};
|
|
14084
14167
|
const sanitizeHtml = (...[html, options]) => (0, import_sanitize_html.default)(html, {
|
|
14085
14168
|
...options,
|
|
14086
14169
|
allowedAttributes: {
|
|
@@ -14094,30 +14177,12 @@ const sanitizeHtml = (...[html, options]) => (0, import_sanitize_html.default)(h
|
|
|
14094
14177
|
table: (tagName, attribs) => ({
|
|
14095
14178
|
attribs: {
|
|
14096
14179
|
...attribs,
|
|
14097
|
-
style:
|
|
14180
|
+
style: appendStyle(attribs.style, "width:100%; border-collapse: collapse;")
|
|
14098
14181
|
},
|
|
14099
14182
|
tagName
|
|
14100
14183
|
}),
|
|
14101
|
-
td:
|
|
14102
|
-
|
|
14103
|
-
attribs.style = `${attribs.style ? `${attribs.style}; ` : ""}text-align:${attribs.align}`;
|
|
14104
|
-
delete attribs.align;
|
|
14105
|
-
}
|
|
14106
|
-
return {
|
|
14107
|
-
attribs,
|
|
14108
|
-
tagName
|
|
14109
|
-
};
|
|
14110
|
-
},
|
|
14111
|
-
th: (tagName, attribs) => {
|
|
14112
|
-
if (attribs.align) {
|
|
14113
|
-
attribs.style = `${attribs.style ? `${attribs.style}; ` : ""}text-align:${attribs.align}`;
|
|
14114
|
-
delete attribs.align;
|
|
14115
|
-
}
|
|
14116
|
-
return {
|
|
14117
|
-
attribs,
|
|
14118
|
-
tagName
|
|
14119
|
-
};
|
|
14120
|
-
}
|
|
14184
|
+
td: transformCellAlign,
|
|
14185
|
+
th: transformCellAlign
|
|
14121
14186
|
}
|
|
14122
14187
|
});
|
|
14123
14188
|
const sanitizeTextHtml = (html) => sanitizeHtml(html, {
|
|
@@ -14131,6 +14196,8 @@ const sanitizeTextHtml = (html) => sanitizeHtml(html, {
|
|
|
14131
14196
|
pre: ["class"],
|
|
14132
14197
|
span: [
|
|
14133
14198
|
"class",
|
|
14199
|
+
CUSTOM_EMOJI_ID_ATTRIBUTE,
|
|
14200
|
+
CUSTOM_EMOJI_NAME_ATTRIBUTE,
|
|
14134
14201
|
MENTION_ID_ATTRIBUTE,
|
|
14135
14202
|
MENTION_ITEM_TYPE_ATTRIBUTE,
|
|
14136
14203
|
MENTION_LABEL_ATTRIBUTE,
|
|
@@ -14201,19 +14268,12 @@ const checkIsPlainObject = (data) => {
|
|
|
14201
14268
|
const ISO_DATE_REGEX = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<hours>\d{2}):(?<minutes>\d{2}):(?<seconds>\d{2}(?:\.{0,1}\d*))(?:Z|(?<sign>\+|-)(?<offset>[\d|:]*))?$/u;
|
|
14202
14269
|
const MS_AJAX_DATE_REGEX = /^\/Date\((?<timestamp>-?\d+(?:[-+]\d+)?)\)[/\\]$/u;
|
|
14203
14270
|
const jsonDateParse = (text) => JSON.parse(text, (_key, value) => {
|
|
14204
|
-
|
|
14205
|
-
if (
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
if (a) {
|
|
14211
|
-
const b = takeOne(a, 1).split(/[-+,.]/u);
|
|
14212
|
-
parsedValue = new Date(b[0] ? Number(b[0]) : 0 - Number(b[1]));
|
|
14213
|
-
}
|
|
14214
|
-
}
|
|
14215
|
-
}
|
|
14216
|
-
return parsedValue;
|
|
14271
|
+
if (typeof value !== "string") return value;
|
|
14272
|
+
else if (ISO_DATE_REGEX.test(value)) return new Date(value);
|
|
14273
|
+
const msAjaxDateMatch = MS_AJAX_DATE_REGEX.exec(value);
|
|
14274
|
+
if (!msAjaxDateMatch) return value;
|
|
14275
|
+
const timestampParts = takeOne(msAjaxDateMatch, 1).split(/[-+,.]/u);
|
|
14276
|
+
return new Date(timestampParts[0] ? Number(timestampParts[0]) : 0 - Number(timestampParts[1]));
|
|
14217
14277
|
});
|
|
14218
14278
|
const mergeObjectsStrict = (...objects) => Object.assign({}, ...objects);
|
|
14219
14279
|
const settleAll = async (tasks, concurrencyLimit = tasks.length) => {
|
|
@@ -14238,6 +14298,7 @@ const EncodedSubDelimiterMap = {
|
|
|
14238
14298
|
"*": "%2A"
|
|
14239
14299
|
};
|
|
14240
14300
|
const encodeUrlSubDelimiters = (value) => Object.entries(EncodedSubDelimiterMap).reduce((encoded, [subDelimiter, encodedSubDelimiter]) => encoded.replaceAll(subDelimiter, encodedSubDelimiter), value);
|
|
14301
|
+
const getDecodedUriComponent = (value, fallback) => getResult(() => decodeURIComponent(value)).unwrapOr(fallback);
|
|
14241
14302
|
const normalizeString = (value) => value?.trim() ?? "";
|
|
14242
14303
|
const createNormalizedStringSchema = (maxLength, schema = z.string()) => schema.transform(normalizeString).pipe(z.string().max(maxLength));
|
|
14243
14304
|
const streamToText = async (readable) => {
|
|
@@ -14247,11 +14308,11 @@ const streamToText = async (readable) => {
|
|
|
14247
14308
|
return data;
|
|
14248
14309
|
};
|
|
14249
14310
|
const toKebabCase = (string) => string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/gu)?.map((x) => x.toLowerCase()).join("-") ?? "";
|
|
14250
|
-
const SUFFIX = "
|
|
14311
|
+
const SUFFIX = "...";
|
|
14251
14312
|
const truncate = (string, length) => {
|
|
14252
14313
|
if (string.length <= length) return string;
|
|
14253
|
-
if (length <
|
|
14254
|
-
return `${string.slice(0, length -
|
|
14314
|
+
if (length < 3) return string.slice(0, length);
|
|
14315
|
+
return `${string.slice(0, length - 3)}${SUFFIX}`;
|
|
14255
14316
|
};
|
|
14256
14317
|
const uncapitalize = (string) => `${string.charAt(0).toLowerCase()}${string.slice(1)}`;
|
|
14257
14318
|
const hrtime = (previousHrTime) => {
|
|
@@ -14281,4 +14342,4 @@ const exhaustiveGuard = (value) => {
|
|
|
14281
14342
|
const createUniqueArraySchema = (schema, key) => schema.array().refine((array) => new Set(key === void 0 ? array : array.map((item) => item[key])).size === array.length, "Array items must be unique");
|
|
14282
14343
|
const UUIDV4_REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/iu;
|
|
14283
14344
|
const uuidValidateV4 = (uuid) => UUIDV4_REGEX.test(uuid);
|
|
14284
|
-
export { AllSpecialValues, ForbiddenError, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, MAX_READ_LIMIT, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MentionType, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, Serializable, UUIDV4_REGEX, UUID_LENGTH, WordFilteredError, applyItemMetadataMixin, capitalize, checkIsPlainObject, chunk, chunkBySerializedSize, classifyMentions, createExponentialBackoff, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, encodeUrlSubDelimiters, exhaustiveGuard, getIsServer, getMentions, getOrCreate, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, settleAll, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };
|
|
14345
|
+
export { AllSpecialValues, CUSTOM_EMOJI_ID_ATTRIBUTE, CUSTOM_EMOJI_NAME_ATTRIBUTE, CUSTOM_EMOJI_TYPE, ForbiddenError, GIBIBYTE, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KIBIBYTE, MAX_READ_LIMIT, MEGABYTE, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_SELECTOR, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MentionType, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, Serializable, UUIDV4_REGEX, UUID_LENGTH, WordFilteredError, applyItemMetadataMixin, capitalize, checkIsPlainObject, chunk, chunkBySerializedSize, classifyMentions, createExponentialBackoff, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, encodeUrlSubDelimiters, exhaustiveGuard, getDecodedUriComponent, getIsServer, getMentions, getOrCreate, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, settleAll, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esposter/shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.0",
|
|
4
4
|
"description": "A library that contains shared typescript code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"error-handling",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"neverthrow": "^8.2.0",
|
|
46
46
|
"node-html-parser": "^9.0.1",
|
|
47
|
-
"sanitize-html": "^2.17.
|
|
47
|
+
"sanitize-html": "^2.17.7"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@azure/data-tables": "^13.3.2",
|
|
51
|
-
"@esposter/configuration": "2.
|
|
52
|
-
"@types/node": "^26.
|
|
51
|
+
"@esposter/configuration": "2.38.0",
|
|
52
|
+
"@types/node": "^26.2.0",
|
|
53
53
|
"@types/sanitize-html": "^2.16.1",
|
|
54
54
|
"ctix": "^2.8.2",
|
|
55
|
-
"rolldown": "^1.2.
|
|
55
|
+
"rolldown": "^1.2.5",
|
|
56
56
|
"type-fest": "^5.8.0",
|
|
57
|
-
"vitest": "^4.1.
|
|
58
|
-
"vue": "^3.5.
|
|
57
|
+
"vitest": "^4.1.11",
|
|
58
|
+
"vue": "^3.5.41"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"zod": "^4.4.3"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "41f54a9cc8f41c4c1d2ee1fa3214d144ee52c4ad"
|
|
64
64
|
}
|