alemonjs 2.1.23 → 2.1.25

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.
@@ -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,8 @@ declare class FormatButtonGroup {
11
11
  declare class FormatMarkDown {
12
12
  #private;
13
13
  get value(): DataMarkDown;
14
+ addMention(...args: Parameters<typeof MD.button>): this;
15
+ addContent(...args: Parameters<typeof MD.content>): this;
14
16
  addText(...args: Parameters<typeof MD.text>): this;
15
17
  addTitle(...args: Parameters<typeof MD.title>): this;
16
18
  addSubtitle(...args: Parameters<typeof MD.subtitle>): this;
@@ -35,11 +37,7 @@ export declare class Format {
35
37
  static createButtonGroup(): FormatButtonGroup;
36
38
  get value(): DataEnums[];
37
39
  addText(...args: Parameters<typeof Text>): this;
38
- addTextBreak(): this;
39
- addLink(...args: Parameters<typeof Link>): this;
40
40
  addImage(...args: Parameters<typeof Image>): this;
41
- addImageFile(...args: Parameters<typeof ImageFile>): this;
42
- addImageURL(...args: Parameters<typeof ImageURL>): this;
43
41
  addMention(...args: Parameters<typeof Mention>): this;
44
42
  addButtonGroup(bt: FormatButtonGroup): this;
45
43
  addButtonGroup(...args: Parameters<typeof BT.group>): this;
@@ -50,6 +48,9 @@ export declare class Format {
50
48
  addAudio(...args: Parameters<typeof Audio>): this;
51
49
  addVideo(...args: Parameters<typeof Video>): this;
52
50
  addCustom(...args: Parameters<typeof Custom>): this;
51
+ addLink(...args: Parameters<typeof Link>): this;
52
+ addImageFile(...args: Parameters<typeof ImageFile>): this;
53
+ addImageURL(...args: Parameters<typeof ImageURL>): this;
53
54
  clear(): this;
54
55
  }
55
56
  export declare function createEvent<T extends EventKeys>(options: {
@@ -1,4 +1,4 @@
1
- import { Text, Link, Image, ImageFile, ImageURL, Mention, BT, MD, Markdown, Attachment, Audio, Video, Custom } from './message-format-old.js';
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,14 @@ class FormatMarkDown {
37
37
  get value() {
38
38
  return MD(...this.#data);
39
39
  }
40
+ addMention(...args) {
41
+ this.#data.push(MD.button(...args));
42
+ return this;
43
+ }
44
+ addContent(...args) {
45
+ this.#data.push(MD.content(...args));
46
+ return this;
47
+ }
40
48
  addText(...args) {
41
49
  this.#data.push(MD.text(...args));
42
50
  return this;
@@ -120,26 +128,10 @@ class Format {
120
128
  this.#data.push(Text(...args));
121
129
  return this;
122
130
  }
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
131
  addImage(...args) {
132
132
  this.#data.push(Image(...args));
133
133
  return this;
134
134
  }
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
135
  addMention(...args) {
144
136
  this.#data.push(Mention(...args));
145
137
  return this;
@@ -182,6 +174,18 @@ class Format {
182
174
  this.#data.push(Custom(...args));
183
175
  return this;
184
176
  }
177
+ addLink(...args) {
178
+ this.#data.push(Link(...args));
179
+ return this;
180
+ }
181
+ addImageFile(...args) {
182
+ this.#data.push(ImageFile(...args));
183
+ return this;
184
+ }
185
+ addImageURL(...args) {
186
+ this.#data.push(ImageURL(...args));
187
+ return this;
188
+ }
185
189
  clear() {
186
190
  this.#data = [];
187
191
  return this;
@@ -2,20 +2,20 @@ import type { Package } from '../types';
2
2
  type ConfigValue = {
3
3
  [key: string]: any;
4
4
  };
5
- type ConfigListener = (value: ConfigValue) => void;
6
- declare class ConfigCore {
5
+ type ConfigListener<T extends ConfigValue = ConfigValue> = (value: T) => void;
6
+ declare class ConfigCore<T extends ConfigValue = ConfigValue> {
7
7
  #private;
8
8
  constructor(dir: string);
9
- get value(): ConfigValue | null;
10
- saveValue(value: ConfigValue): void;
11
- onWatch(listener: ConfigListener): () => void;
9
+ get value(): T | null;
10
+ saveValue(value: T): void;
11
+ onWatch(listener: ConfigListener<T>): () => void;
12
12
  dispose(): void;
13
13
  get package(): Package | null;
14
14
  get argv(): {
15
15
  [key: string]: string;
16
16
  };
17
17
  }
18
- export declare const getConfig: () => typeof ConfigCore.prototype;
19
- export declare const getConfigValue: () => ConfigValue;
20
- export declare const onWatchConfigValue: (callback: ConfigListener) => (() => void);
18
+ export declare const getConfig: <T extends ConfigValue = ConfigValue>() => ConfigCore<T>;
19
+ export declare const getConfigValue: <T extends ConfigValue = ConfigValue>() => T;
20
+ export declare const onWatchConfigValue: <T extends ConfigValue = ConfigValue>(callback: ConfigListener<T>) => (() => void);
21
21
  export {};
@@ -12,11 +12,7 @@ class ConfigCore {
12
12
  #debounceDelay = 100;
13
13
  #argvProxy = null;
14
14
  #resolvedDir = null;
15
- #initValue = {
16
- gui: {
17
- port: 17127
18
- }
19
- };
15
+ #initValue = {};
20
16
  constructor(dir) {
21
17
  this.#resolvedDir = join(process.cwd(), dir);
22
18
  }
@@ -205,7 +201,9 @@ const getConfig = () => {
205
201
  global.__config = new ConfigCore(configDir);
206
202
  return global.__config;
207
203
  };
208
- const getConfigValue = () => getConfig()?.value || {};
204
+ const getConfigValue = () => {
205
+ return (getConfig()?.value || {});
206
+ };
209
207
  const onWatchConfigValue = (callback) => {
210
208
  return getConfig().onWatch(callback);
211
209
  };
@@ -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
- showList?: boolean;
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[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.1.23",
3
+ "version": "2.1.25",
4
4
  "description": "bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",