alemonjs 2.1.25 → 2.1.27
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 +3 -3
- package/lib/app/hook-use-api.d.ts +1 -1
- package/lib/app/index.js +1 -1
- package/lib/app/message-format.d.ts +7 -3
- package/lib/app/message-format.js +23 -4
- package/lib/core/variable.d.ts +18 -0
- package/lib/core/variable.js +59 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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";
|
package/lib/app/index.js
CHANGED
|
@@ -18,5 +18,5 @@ export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, use
|
|
|
18
18
|
export { onState, unState, useState } from './hook-use-state.js';
|
|
19
19
|
export { useObserver, useSubscribe } from './hook-use-subscribe.js';
|
|
20
20
|
export { createDataFormat, createEventValue, format, getMessageIntent, sendToChannel, sendToUser } from './message-api.js';
|
|
21
|
-
export { Format, createEvent } from './message-format.js';
|
|
21
|
+
export { Format, FormatButtonGroup, FormatMarkDown, createEvent } from './message-format.js';
|
|
22
22
|
export { Ark, Attachment, Audio, BT, Custom, Image, ImageFile, ImageURL, Link, MD, Markdown, Mention, Text, Video } from './message-format-old.js';
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { DataButtonGroup, DataMarkDown, DataEnums, EventKeys, Events } from '../types';
|
|
2
2
|
import { Text, Link, Image, ImageFile, ImageURL, Mention, BT, MD, Markdown, Attachment, Audio, Video, Custom } from './message-format-old.js';
|
|
3
3
|
export * from './message-format-old.js';
|
|
4
|
-
declare class FormatButtonGroup {
|
|
4
|
+
export declare class FormatButtonGroup {
|
|
5
5
|
#private;
|
|
6
6
|
get value(): DataButtonGroup;
|
|
7
|
+
absorb(group: FormatButtonGroup): this;
|
|
7
8
|
addRow(): this;
|
|
8
9
|
addButton(...args: Parameters<typeof BT>): this;
|
|
9
10
|
clear(): this;
|
|
10
11
|
}
|
|
11
|
-
declare class FormatMarkDown {
|
|
12
|
+
export declare class FormatMarkDown {
|
|
12
13
|
#private;
|
|
13
14
|
get value(): DataMarkDown;
|
|
14
|
-
|
|
15
|
+
absorb(md: FormatMarkDown): this;
|
|
15
16
|
addContent(...args: Parameters<typeof MD.content>): this;
|
|
16
17
|
addText(...args: Parameters<typeof MD.text>): this;
|
|
17
18
|
addTitle(...args: Parameters<typeof MD.title>): this;
|
|
@@ -28,6 +29,8 @@ declare class FormatMarkDown {
|
|
|
28
29
|
addNewline(...args: Parameters<typeof MD.newline>): this;
|
|
29
30
|
addCode(...args: Parameters<typeof MD.code>): this;
|
|
30
31
|
addBreak(): this;
|
|
32
|
+
addMention(...args: Parameters<typeof MD.mention>): this;
|
|
33
|
+
addButton(...args: Parameters<typeof MD.button>): this;
|
|
31
34
|
clear(): this;
|
|
32
35
|
}
|
|
33
36
|
export declare class Format {
|
|
@@ -36,6 +39,7 @@ export declare class Format {
|
|
|
36
39
|
static createMarkdown(): FormatMarkDown;
|
|
37
40
|
static createButtonGroup(): FormatButtonGroup;
|
|
38
41
|
get value(): DataEnums[];
|
|
42
|
+
absorb(format: Format): this;
|
|
39
43
|
addText(...args: Parameters<typeof Text>): this;
|
|
40
44
|
addImage(...args: Parameters<typeof Image>): this;
|
|
41
45
|
addMention(...args: Parameters<typeof Mention>): this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BT, MD, Text, Image, Mention, 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 {
|
|
@@ -14,6 +14,13 @@ class FormatButtonGroup {
|
|
|
14
14
|
this.#currentRow = null;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
absorb(group) {
|
|
18
|
+
if (this.#currentRow && this.#currentRow.length > 0) {
|
|
19
|
+
this.#flush();
|
|
20
|
+
}
|
|
21
|
+
this.#rows.push(...group.value.value);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
17
24
|
addRow() {
|
|
18
25
|
this.#flush();
|
|
19
26
|
this.#currentRow = [];
|
|
@@ -37,8 +44,8 @@ class FormatMarkDown {
|
|
|
37
44
|
get value() {
|
|
38
45
|
return MD(...this.#data);
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
this.#data.push(
|
|
47
|
+
absorb(md) {
|
|
48
|
+
this.#data.push(...md.value.value);
|
|
42
49
|
return this;
|
|
43
50
|
}
|
|
44
51
|
addContent(...args) {
|
|
@@ -105,6 +112,14 @@ class FormatMarkDown {
|
|
|
105
112
|
this.#data.push(MD.newline());
|
|
106
113
|
return this;
|
|
107
114
|
}
|
|
115
|
+
addMention(...args) {
|
|
116
|
+
this.#data.push(MD.mention(...args));
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
addButton(...args) {
|
|
120
|
+
this.#data.push(MD.button(...args));
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
108
123
|
clear() {
|
|
109
124
|
this.#data = [];
|
|
110
125
|
return this;
|
|
@@ -124,6 +139,10 @@ class Format {
|
|
|
124
139
|
get value() {
|
|
125
140
|
return this.#data;
|
|
126
141
|
}
|
|
142
|
+
absorb(format) {
|
|
143
|
+
this.#data.push(...format.value);
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
127
146
|
addText(...args) {
|
|
128
147
|
this.#data.push(Text(...args));
|
|
129
148
|
return this;
|
|
@@ -216,4 +235,4 @@ function createEvent(options) {
|
|
|
216
235
|
return { ...event, ...o };
|
|
217
236
|
}
|
|
218
237
|
|
|
219
|
-
export { Attachment, Audio, BT, Custom, Format, Image, ImageFile, ImageURL, Link, MD, Markdown, Mention, Text, Video, createEvent };
|
|
238
|
+
export { Attachment, Audio, BT, Custom, Format, FormatButtonGroup, FormatMarkDown, Image, ImageFile, ImageURL, Link, MD, Markdown, Mention, Text, Video, createEvent };
|
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 };
|
package/lib/index.js
CHANGED
|
@@ -25,6 +25,6 @@ export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, use
|
|
|
25
25
|
export { onState, unState, useState } from './app/hook-use-state.js';
|
|
26
26
|
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
27
27
|
export { createDataFormat, createEventValue, format, getMessageIntent, sendToChannel, sendToUser } from './app/message-api.js';
|
|
28
|
-
export { Format, createEvent } from './app/message-format.js';
|
|
28
|
+
export { Format, FormatButtonGroup, FormatMarkDown, createEvent } from './app/message-format.js';
|
|
29
29
|
export { start } from './main.js';
|
|
30
30
|
export { Ark, Attachment, Audio, BT, Custom, Image, ImageFile, ImageURL, Link, MD, Markdown, Mention, Text, Video } from './app/message-format-old.js';
|