@pnnh/atom 0.6.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.
@@ -0,0 +1,220 @@
1
+ import { ParsedQuery } from 'query-string';
2
+ import parseUri from 'parse-uri';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { JSX } from 'react';
5
+ import { Token } from 'marked';
6
+
7
+ declare const langEn = "en";
8
+ declare const langZh = "zh";
9
+ declare const langZhant = "zhant";
10
+ declare const defaultLanguage = "en";
11
+ declare const supportedLanguages: string[];
12
+ declare function isSupportedLanguage(lang: string): boolean;
13
+ declare function isLangEn(lang: string): boolean;
14
+ declare function isLangZh(lang: string): boolean;
15
+ declare function getLangDefault(lang: string): string;
16
+ declare function getLanguageFromPathname(pathname: string): string | undefined;
17
+ declare function replaceLanguageInPathname(pathname: string, lang: string): string;
18
+ declare function localText(lang: string, zhText: string, enText: string): string;
19
+
20
+ declare function uuidV1(): string;
21
+ declare function isValidUUID(uuid: string): boolean;
22
+ declare function uuidV4(): string;
23
+ declare function uuidV6(): string;
24
+ declare function uuidV7(): string;
25
+ declare const EmptyUUID: "00000000-0000-0000-0000-000000000000";
26
+ declare function isEmptyUUID(uuid: string): boolean;
27
+
28
+ /**
29
+ * 将字符串转换为base64编码的字符串
30
+ * @param state - 待编码的字符串
31
+ * @returns base64编码的字符串
32
+ */
33
+ declare function encodeBase64String(state: string | unknown): string;
34
+ declare function encodeBase32String(state: string | unknown): string;
35
+ declare function decodeBase32String(base32State: string): string;
36
+ /**
37
+ * 将base64编码的字符串转换为字符串
38
+ * @param base64State - 待解码的base64编码的字符串
39
+ * @returns 解码后的字符串
40
+ */
41
+ declare function decodeBase64String(base64State: string): string;
42
+ declare function binaryToBase58String(data: Uint8Array): string;
43
+ declare function generateUuid(): string;
44
+ declare function generateUuidV7(): string;
45
+ declare function stringToUuid(uuidString: string): string;
46
+ declare function isValidUuid(uuidString: string): boolean;
47
+ declare function uuidToBase58(uuidString: string): string;
48
+ declare function tryBase58ToUuid(base58String: string): string | undefined;
49
+ declare function mustBase58ToUuid(base58String: string): string;
50
+ declare function stringToBase58(data: string, flavor?: string): string;
51
+ declare function encodeBase58String(state: string): string;
52
+ declare function decodeBase58String(base58State: string): string;
53
+ declare function base58ToString(data: string, flavor?: string): string;
54
+ /**
55
+ * 将字符串转换为md5字符串
56
+ * @param data - 待转换的字符串
57
+ * @returns md5字符串
58
+ */
59
+ declare function stringToMd5(data: string): string;
60
+
61
+ declare function convertToNumber(value: string | number | (string | null)[] | null | undefined): number | undefined;
62
+
63
+ declare function encodeSHA256(data: string): string;
64
+ declare function encodeSHA512(data: string): string;
65
+ declare function encodeMD5(data: string): string;
66
+
67
+ declare function formatRfc3339(date: string | Date): string;
68
+ declare function getTimestamp(): number;
69
+
70
+ declare function validateEmail(email: string): RegExpMatchArray | null;
71
+
72
+ declare function stringHashCode(str: string): number;
73
+
74
+ declare function encodeHtml(rawHtml: string | null | undefined): string;
75
+
76
+ declare function isScreenPhone(): boolean;
77
+ declare function isScreenTablet(): boolean;
78
+ declare function isScreenDesktop(): boolean;
79
+
80
+ declare function getMimeType(path: string): string;
81
+ type getType = typeof getMimeType;
82
+ declare function isImageType(type: string): boolean;
83
+
84
+ interface Pagination {
85
+ offset: number;
86
+ limit: number;
87
+ page: number;
88
+ size: number;
89
+ }
90
+ declare class FullPagination {
91
+ totalCount: number;
92
+ pageSize: number;
93
+ currentPage: number;
94
+ startPage: number;
95
+ endPage: number;
96
+ previousPage: number;
97
+ nextPage: number;
98
+ maxPage: number;
99
+ }
100
+ declare function calcPagination(currentPage: number, totalCount: number, pageSize: number): FullPagination;
101
+ declare function createPagination(offset: number, limit: number): Pagination;
102
+ declare function createPaginationByPage(page: number, limit: number): Pagination;
103
+
104
+ declare function replaceSearchParams(searchParams: Record<string, string>, key: string, value: string): string;
105
+ declare function replaceParsedQuery(parsedQuery: ParsedQuery<string>, key: string, value: string): string;
106
+ declare function replaceQueryString(rawQuery: string, key: string, value: string): string;
107
+ declare function replaceQueryStringNew(rawQuery: string, key: string, value: string): string;
108
+
109
+ declare function randomString(chars: string, length: number): string;
110
+ interface randomPasswordOptions {
111
+ number?: boolean;
112
+ letter?: boolean;
113
+ uppercaseLetter?: boolean;
114
+ symbol?: boolean;
115
+ }
116
+ declare function randomPassword(length: number, options: randomPasswordOptions): string;
117
+
118
+ declare function generatorRandomString(length: number): string;
119
+ declare function STSubString(str: string | undefined, length: number, suffix?: string): string;
120
+ declare function isValidName(s: string): boolean;
121
+
122
+ declare function stringToUri(value: string): parseUri.URI;
123
+ declare function isValidUrl(address: string): boolean;
124
+ declare function sanitizeUrl(src: string | undefined): string;
125
+
126
+ declare const CodeOk = 200;
127
+ declare const CodeFailed = 500;
128
+ declare const CodeBadRequest = 400;
129
+ declare const CodeNotFound = 404;
130
+ declare const CodeUnauthorized = 401;
131
+ interface PLBizError extends Error {
132
+ code: number;
133
+ message: string;
134
+ }
135
+ declare function PLParseBizError(error: Error): PLBizError;
136
+ interface PLSelectData<T> {
137
+ page: number;
138
+ size: number;
139
+ count: number;
140
+ range: T[];
141
+ }
142
+ type PLSelectResult<T> = CommonResult<PLSelectData<T>>;
143
+ type PLGetResult<T> = CommonResult<T>;
144
+ type PLInsertResult = CommonResult<string>;
145
+ type ATInsertResult<T> = CommonResult<T>;
146
+ type PLDeleteResult = CommonResult<string>;
147
+ type PLUpdateResult = CommonResult<string>;
148
+ declare function emptySelectResult(): {
149
+ code: number;
150
+ message: string;
151
+ data: {
152
+ page: number;
153
+ size: number;
154
+ count: number;
155
+ range: never[];
156
+ };
157
+ };
158
+ interface CommonResult<T> {
159
+ code: number;
160
+ message: string;
161
+ data: T;
162
+ }
163
+ declare const SymbolUnknown: unique symbol;
164
+
165
+ declare class TocItem {
166
+ title: string;
167
+ header: number;
168
+ id: string;
169
+ }
170
+
171
+ interface TextNode {
172
+ name: string;
173
+ text: string;
174
+ }
175
+ interface SteleNode {
176
+ id: string;
177
+ name: string;
178
+ text: string;
179
+ raw: string;
180
+ children?: SteleNode[];
181
+ }
182
+ interface HeadingNode extends SteleNode {
183
+ header: number;
184
+ }
185
+ interface ParagraphNode extends SteleNode {
186
+ }
187
+ interface CodeBlockNode extends SteleNode {
188
+ language: string;
189
+ }
190
+ interface ListNode extends SteleNode {
191
+ ordered: boolean;
192
+ start: number;
193
+ loose: boolean;
194
+ }
195
+ interface LinkNode extends SteleNode {
196
+ href: string;
197
+ }
198
+ interface ImageNode extends SteleNode {
199
+ href: string;
200
+ }
201
+ interface SteleBody {
202
+ name: string;
203
+ children: SteleNode[];
204
+ }
205
+ interface SteleBody extends SteleNode {
206
+ }
207
+ declare function buildText(node: SteleNode): string;
208
+
209
+ declare function buildNodeView(tocList: Array<TocItem>, node: SteleNode, assetsUrl: string): JSX.Element;
210
+ declare function buildCodeBlock(tocList: Array<TocItem>, node: CodeBlockNode): react_jsx_runtime.JSX.Element;
211
+ declare function buildImage(node: ImageNode, assetsUrl: string): react_jsx_runtime.JSX.Element;
212
+ declare function buildList(node: ListNode, assetsUrl: string): react_jsx_runtime.JSX.Element;
213
+
214
+ declare function tokenToNode(token: Token): SteleNode;
215
+ declare function markdownToStele(markdown: string): SteleBody;
216
+
217
+ declare function atomCommonHello(): Promise<string>;
218
+
219
+ export { CodeBadRequest, CodeFailed, CodeNotFound, CodeOk, CodeUnauthorized, EmptyUUID, FullPagination, PLParseBizError, STSubString, SymbolUnknown, TocItem, atomCommonHello, base58ToString, binaryToBase58String, buildCodeBlock, buildImage, buildList, buildNodeView, buildText, calcPagination, convertToNumber, createPagination, createPaginationByPage, decodeBase32String, decodeBase58String, decodeBase64String, defaultLanguage, emptySelectResult, encodeBase32String, encodeBase58String, encodeBase64String, encodeHtml, encodeMD5, encodeSHA256, encodeSHA512, formatRfc3339, generateUuid, generateUuidV7, generatorRandomString, getLangDefault, getLanguageFromPathname, getMimeType, getTimestamp, isEmptyUUID, isImageType, isLangEn, isLangZh, isScreenDesktop, isScreenPhone, isScreenTablet, isSupportedLanguage, isValidName, isValidUUID, isValidUrl, isValidUuid, langEn, langZh, langZhant, localText, markdownToStele, mustBase58ToUuid, randomPassword, randomString, replaceLanguageInPathname, replaceParsedQuery, replaceQueryString, replaceQueryStringNew, replaceSearchParams, sanitizeUrl, stringHashCode, stringToBase58, stringToMd5, stringToUri, stringToUuid, supportedLanguages, tokenToNode, tryBase58ToUuid, uuidToBase58, uuidV1, uuidV4, uuidV6, uuidV7, validateEmail };
220
+ export type { ATInsertResult, CodeBlockNode, CommonResult, HeadingNode, ImageNode, LinkNode, ListNode, PLBizError, PLDeleteResult, PLGetResult, PLInsertResult, PLSelectData, PLSelectResult, PLUpdateResult, Pagination, ParagraphNode, SteleBody, SteleNode, TextNode, getType };