alemonjs 2.1.24 → 2.1.26
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/lib/app/hook-use-api.d.ts +1 -1
- package/lib/app/message-format-old.d.ts +4 -1
- package/lib/app/message-format-old.js +22 -0
- package/lib/app/message-format.d.ts +6 -4
- package/lib/app/message-format.js +25 -17
- package/lib/core/variable.d.ts +18 -0
- package/lib/core/variable.js +59 -1
- package/lib/types/message/button.d.ts +2 -10
- package/lib/types/message/markdown.d.ts +22 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ export declare const useMention: <T extends EventKeys>(event: Events[T]) => [{
|
|
|
17
17
|
}>;
|
|
18
18
|
}];
|
|
19
19
|
export declare const useMessage: <T extends EventKeys>(event: Events[T]) => readonly [{
|
|
20
|
-
"__#
|
|
20
|
+
"__#11@#format": DataEnums[];
|
|
21
21
|
readonly currentFormat: DataEnums[];
|
|
22
22
|
addText(val: string, options?: {
|
|
23
23
|
style?: "none" | "bold" | "block" | "strikethrough" | "boldItalic" | "italic";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataMention, DataImage, DataText, DataImageURL, DataImageFile, ButtonRow, DataButtonGroup, DataButton, DataArkList, DataArkListTip, DataArkListContent, DataArkListItem, DataArkCard, DataArkBigCard, DataMarkdownTemplate, DataMarkDown, DataMarkdownTitle, DataMarkdownSubtitle, DataMarkdownBold, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownStrikethrough, DataMarkdownLink, DataMarkdownImage, DataMarkdownList, DataMarkdownListItem, DataMarkdownBlockquote, DataMarkdownDivider, DataMarkdownNewline, DataLink, DataMarkdownText, DataButtonTemplate, DataMarkdownCode, DataCustom, DataMarkdownOriginal, DataAttachment, DataAudio, DataVideo } from '../types';
|
|
1
|
+
import { DataMention, DataImage, DataText, DataImageURL, DataImageFile, ButtonRow, DataButtonGroup, DataButton, DataArkList, DataArkListTip, DataArkListContent, DataArkListItem, DataArkCard, DataArkBigCard, DataMarkdownTemplate, DataMarkDown, DataMarkdownTitle, DataMarkdownSubtitle, DataMarkdownBold, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownStrikethrough, DataMarkdownLink, DataMarkdownImage, DataMarkdownList, DataMarkdownListItem, DataMarkdownBlockquote, DataMarkdownDivider, DataMarkdownNewline, DataLink, DataMarkdownText, DataButtonTemplate, DataMarkdownCode, DataCustom, DataMarkdownOriginal, DataAttachment, DataAudio, DataVideo, DataMarkdownMention, DataMarkdownContent, DataMarkdownButton } from '../types';
|
|
2
2
|
export declare const Custom: (value: DataCustom["value"], options?: DataCustom["options"], type?: DataCustom["type"]) => DataCustom;
|
|
3
3
|
export declare const Text: (val: DataText["value"], options?: DataText["options"]) => DataText;
|
|
4
4
|
export declare const Link: (val: DataLink["value"], options?: DataText["options"]) => DataText;
|
|
@@ -30,6 +30,9 @@ declare const MD: {
|
|
|
30
30
|
(...values: DataMarkDown["value"]): DataMarkDown;
|
|
31
31
|
template(templateId: DataMarkdownTemplate["value"], params?: DataMarkdownTemplate["options"]["params"]): DataMarkdownTemplate;
|
|
32
32
|
text(text: string): DataMarkdownText;
|
|
33
|
+
mention(uid?: string, options?: DataMarkdownMention["options"]): DataMarkdownMention;
|
|
34
|
+
button(title: string, data: DataMarkdownButton["options"]): DataMarkdownButton;
|
|
35
|
+
content(text: string): DataMarkdownContent;
|
|
33
36
|
title(text: string): DataMarkdownTitle;
|
|
34
37
|
subtitle(text: string): DataMarkdownSubtitle;
|
|
35
38
|
bold(text: string): DataMarkdownBold;
|
|
@@ -135,6 +135,28 @@ MD.text = (text) => {
|
|
|
135
135
|
value: text
|
|
136
136
|
};
|
|
137
137
|
};
|
|
138
|
+
MD.mention = (uid, options) => {
|
|
139
|
+
return {
|
|
140
|
+
type: 'MD.mention',
|
|
141
|
+
value: uid || '',
|
|
142
|
+
options: options ?? {
|
|
143
|
+
belong: 'all'
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
MD.button = (title, data) => {
|
|
148
|
+
return {
|
|
149
|
+
type: 'MD.button',
|
|
150
|
+
value: title,
|
|
151
|
+
options: data
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
MD.content = (text) => {
|
|
155
|
+
return {
|
|
156
|
+
type: 'MD.content',
|
|
157
|
+
value: text
|
|
158
|
+
};
|
|
159
|
+
};
|
|
138
160
|
MD.title = (text) => {
|
|
139
161
|
return {
|
|
140
162
|
type: 'MD.title',
|
|
@@ -11,6 +11,7 @@ declare class FormatButtonGroup {
|
|
|
11
11
|
declare class FormatMarkDown {
|
|
12
12
|
#private;
|
|
13
13
|
get value(): DataMarkDown;
|
|
14
|
+
addContent(...args: Parameters<typeof MD.content>): this;
|
|
14
15
|
addText(...args: Parameters<typeof MD.text>): this;
|
|
15
16
|
addTitle(...args: Parameters<typeof MD.title>): this;
|
|
16
17
|
addSubtitle(...args: Parameters<typeof MD.subtitle>): this;
|
|
@@ -26,6 +27,8 @@ declare class FormatMarkDown {
|
|
|
26
27
|
addNewline(...args: Parameters<typeof MD.newline>): this;
|
|
27
28
|
addCode(...args: Parameters<typeof MD.code>): this;
|
|
28
29
|
addBreak(): this;
|
|
30
|
+
addMention(...args: Parameters<typeof MD.mention>): this;
|
|
31
|
+
addButton(...args: Parameters<typeof MD.button>): this;
|
|
29
32
|
clear(): this;
|
|
30
33
|
}
|
|
31
34
|
export declare class Format {
|
|
@@ -35,11 +38,7 @@ export declare class Format {
|
|
|
35
38
|
static createButtonGroup(): FormatButtonGroup;
|
|
36
39
|
get value(): DataEnums[];
|
|
37
40
|
addText(...args: Parameters<typeof Text>): this;
|
|
38
|
-
addTextBreak(): this;
|
|
39
|
-
addLink(...args: Parameters<typeof Link>): this;
|
|
40
41
|
addImage(...args: Parameters<typeof Image>): this;
|
|
41
|
-
addImageFile(...args: Parameters<typeof ImageFile>): this;
|
|
42
|
-
addImageURL(...args: Parameters<typeof ImageURL>): this;
|
|
43
42
|
addMention(...args: Parameters<typeof Mention>): this;
|
|
44
43
|
addButtonGroup(bt: FormatButtonGroup): this;
|
|
45
44
|
addButtonGroup(...args: Parameters<typeof BT.group>): this;
|
|
@@ -50,6 +49,9 @@ export declare class Format {
|
|
|
50
49
|
addAudio(...args: Parameters<typeof Audio>): this;
|
|
51
50
|
addVideo(...args: Parameters<typeof Video>): this;
|
|
52
51
|
addCustom(...args: Parameters<typeof Custom>): this;
|
|
52
|
+
addLink(...args: Parameters<typeof Link>): this;
|
|
53
|
+
addImageFile(...args: Parameters<typeof ImageFile>): this;
|
|
54
|
+
addImageURL(...args: Parameters<typeof ImageURL>): this;
|
|
53
55
|
clear(): this;
|
|
54
56
|
}
|
|
55
57
|
export declare function createEvent<T extends EventKeys>(options: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Text,
|
|
1
|
+
import { Text, Image, Mention, BT, MD, Markdown, Attachment, Audio, Video, Custom, Link, ImageFile, ImageURL } from './message-format-old.js';
|
|
2
2
|
export { Ark } from './message-format-old.js';
|
|
3
3
|
|
|
4
4
|
class FormatButtonGroup {
|
|
@@ -37,6 +37,10 @@ class FormatMarkDown {
|
|
|
37
37
|
get value() {
|
|
38
38
|
return MD(...this.#data);
|
|
39
39
|
}
|
|
40
|
+
addContent(...args) {
|
|
41
|
+
this.#data.push(MD.content(...args));
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
40
44
|
addText(...args) {
|
|
41
45
|
this.#data.push(MD.text(...args));
|
|
42
46
|
return this;
|
|
@@ -97,6 +101,14 @@ class FormatMarkDown {
|
|
|
97
101
|
this.#data.push(MD.newline());
|
|
98
102
|
return this;
|
|
99
103
|
}
|
|
104
|
+
addMention(...args) {
|
|
105
|
+
this.#data.push(MD.mention(...args));
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
addButton(...args) {
|
|
109
|
+
this.#data.push(MD.button(...args));
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
100
112
|
clear() {
|
|
101
113
|
this.#data = [];
|
|
102
114
|
return this;
|
|
@@ -120,26 +132,10 @@ class Format {
|
|
|
120
132
|
this.#data.push(Text(...args));
|
|
121
133
|
return this;
|
|
122
134
|
}
|
|
123
|
-
addTextBreak() {
|
|
124
|
-
this.#data.push(Text('\n'));
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
addLink(...args) {
|
|
128
|
-
this.#data.push(Link(...args));
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
135
|
addImage(...args) {
|
|
132
136
|
this.#data.push(Image(...args));
|
|
133
137
|
return this;
|
|
134
138
|
}
|
|
135
|
-
addImageFile(...args) {
|
|
136
|
-
this.#data.push(ImageFile(...args));
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
addImageURL(...args) {
|
|
140
|
-
this.#data.push(ImageURL(...args));
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
139
|
addMention(...args) {
|
|
144
140
|
this.#data.push(Mention(...args));
|
|
145
141
|
return this;
|
|
@@ -182,6 +178,18 @@ class Format {
|
|
|
182
178
|
this.#data.push(Custom(...args));
|
|
183
179
|
return this;
|
|
184
180
|
}
|
|
181
|
+
addLink(...args) {
|
|
182
|
+
this.#data.push(Link(...args));
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
addImageFile(...args) {
|
|
186
|
+
this.#data.push(ImageFile(...args));
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
addImageURL(...args) {
|
|
190
|
+
this.#data.push(ImageURL(...args));
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
185
193
|
clear() {
|
|
186
194
|
this.#data = [];
|
|
187
195
|
return this;
|
package/lib/core/variable.d.ts
CHANGED
|
@@ -28,3 +28,21 @@ export declare const ResultCode: {
|
|
|
28
28
|
readonly FailInternal: 5000;
|
|
29
29
|
};
|
|
30
30
|
export type ResultCode = (typeof ResultCode)[keyof typeof ResultCode];
|
|
31
|
+
export declare class Result {
|
|
32
|
+
#private;
|
|
33
|
+
get value(): {
|
|
34
|
+
code: ResultCode;
|
|
35
|
+
message: string;
|
|
36
|
+
data: null;
|
|
37
|
+
}[];
|
|
38
|
+
static create(): Result;
|
|
39
|
+
push(param: {
|
|
40
|
+
code: ResultCode;
|
|
41
|
+
message: string;
|
|
42
|
+
data: null;
|
|
43
|
+
}): this;
|
|
44
|
+
newIndex(): this;
|
|
45
|
+
updateMessage(msg: string): this;
|
|
46
|
+
updateData(data: any): this;
|
|
47
|
+
updateCode(callback: (code: typeof ResultCode) => ResultCode): this;
|
|
48
|
+
}
|
package/lib/core/variable.js
CHANGED
|
@@ -26,5 +26,63 @@ const ResultCode = {
|
|
|
26
26
|
FailAuth,
|
|
27
27
|
FailInternal
|
|
28
28
|
};
|
|
29
|
+
class Result {
|
|
30
|
+
#data = [];
|
|
31
|
+
#currentIndex = 0;
|
|
32
|
+
get value() {
|
|
33
|
+
return this.#data;
|
|
34
|
+
}
|
|
35
|
+
static create() {
|
|
36
|
+
return new Result();
|
|
37
|
+
}
|
|
38
|
+
push(param) {
|
|
39
|
+
this.#data.push(param);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
newIndex() {
|
|
43
|
+
if (this.#data[this.#currentIndex]) {
|
|
44
|
+
this.#currentIndex++;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.#currentIndex = 0;
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
updateMessage(msg) {
|
|
52
|
+
if (!this.#data[this.#currentIndex]) {
|
|
53
|
+
this.#data[this.#currentIndex] = {
|
|
54
|
+
code: ResultCode.Ok,
|
|
55
|
+
message: msg,
|
|
56
|
+
data: null
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
this.#data[this.#currentIndex].message = msg;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
updateData(data) {
|
|
63
|
+
if (!this.#data[this.#currentIndex]) {
|
|
64
|
+
this.#data[this.#currentIndex] = {
|
|
65
|
+
code: ResultCode.Ok,
|
|
66
|
+
message: '',
|
|
67
|
+
data: data
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
updateCode(callback) {
|
|
73
|
+
const newCode = callback(ResultCode);
|
|
74
|
+
if (!this.#data[this.#currentIndex]) {
|
|
75
|
+
this.#data[this.#currentIndex] = {
|
|
76
|
+
code: newCode,
|
|
77
|
+
message: '',
|
|
78
|
+
data: null
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.#data[this.#currentIndex].code = newCode;
|
|
83
|
+
}
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
29
87
|
|
|
30
|
-
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, ResultCode, Warn, defaultLogin, defaultPlatformCommonPrefix, defaultPlatformPrefix, defaultPort, filePrefixCommon, fileSuffixMiddleware, fileSuffixResponse, processorMaxMapSize, processorRepeatedClearSize, processorRepeatedClearTimeMax, processorRepeatedClearTimeMin, processorRepeatedEventTime, processorRepeatedUserTime };
|
|
88
|
+
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, Result, ResultCode, Warn, defaultLogin, defaultPlatformCommonPrefix, defaultPlatformPrefix, defaultPort, filePrefixCommon, fileSuffixMiddleware, fileSuffixResponse, processorMaxMapSize, processorRepeatedClearSize, processorRepeatedClearTimeMax, processorRepeatedClearTimeMin, processorRepeatedEventTime, processorRepeatedUserTime };
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
export type DataButton = {
|
|
2
2
|
type: 'Button';
|
|
3
|
-
value: string
|
|
4
|
-
title: string;
|
|
5
|
-
label: string;
|
|
6
|
-
};
|
|
3
|
+
value: string;
|
|
7
4
|
options?: {
|
|
8
5
|
toolTip?: string;
|
|
9
6
|
autoEnter?: boolean;
|
|
10
|
-
|
|
11
|
-
data?: string | {
|
|
12
|
-
click: string;
|
|
13
|
-
confirm: string;
|
|
14
|
-
cancel: string;
|
|
15
|
-
};
|
|
7
|
+
data?: string;
|
|
16
8
|
type?: 'command' | 'link' | 'call';
|
|
17
9
|
};
|
|
18
10
|
};
|
|
@@ -11,6 +11,27 @@ export type DataMarkdownText = {
|
|
|
11
11
|
type: 'MD.text';
|
|
12
12
|
value: string;
|
|
13
13
|
};
|
|
14
|
+
export type DataMarkdownMention = {
|
|
15
|
+
type: 'MD.mention';
|
|
16
|
+
value?: string;
|
|
17
|
+
options?: {
|
|
18
|
+
belong?: 'user' | 'channel' | 'all';
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type DataMarkdownContent = {
|
|
22
|
+
type: 'MD.content';
|
|
23
|
+
value: string;
|
|
24
|
+
};
|
|
25
|
+
export type DataMarkdownButton = {
|
|
26
|
+
type: 'MD.button';
|
|
27
|
+
value: string;
|
|
28
|
+
options?: {
|
|
29
|
+
toolTip?: string;
|
|
30
|
+
autoEnter?: boolean;
|
|
31
|
+
data?: string;
|
|
32
|
+
type?: 'command' | 'link' | 'call';
|
|
33
|
+
};
|
|
34
|
+
};
|
|
14
35
|
export type DataMarkdownTitle = {
|
|
15
36
|
type: 'MD.title';
|
|
16
37
|
value: string;
|
|
@@ -86,7 +107,7 @@ export type DataCustom = {
|
|
|
86
107
|
[key: string]: any;
|
|
87
108
|
};
|
|
88
109
|
};
|
|
89
|
-
type DataMarkDownBalue = DataMarkdownText | DataMarkdownTitle | DataMarkdownSubtitle | DataMarkdownBold | DataMarkdownItalic | DataMarkdownItalicStar | DataMarkdownStrikethrough | DataMarkdownLink | DataMarkdownImage | DataMarkdownList | DataMarkdownBlockquote | DataMarkdownDivider | DataMarkdownNewline | DataMarkdownCode | DataCustom;
|
|
110
|
+
type DataMarkDownBalue = DataMarkdownMention | DataMarkdownContent | DataMarkdownButton | DataMarkdownText | DataMarkdownTitle | DataMarkdownSubtitle | DataMarkdownBold | DataMarkdownItalic | DataMarkdownItalicStar | DataMarkdownStrikethrough | DataMarkdownLink | DataMarkdownImage | DataMarkdownList | DataMarkdownBlockquote | DataMarkdownDivider | DataMarkdownNewline | DataMarkdownCode | DataCustom;
|
|
90
111
|
export type DataMarkDown = {
|
|
91
112
|
type: 'Markdown';
|
|
92
113
|
value: DataMarkDownBalue[];
|