@nextclaw/channel-extension-feishu 0.1.1 → 0.1.2
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.
|
@@ -5,15 +5,15 @@ import { ExtensionChannel } from "@nextclaw/extension-sdk";
|
|
|
5
5
|
declare class FeishuExtensionRuntime {
|
|
6
6
|
private readonly channel;
|
|
7
7
|
private readonly adapter;
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private unsubscribeNcpEvents;
|
|
8
|
+
private readonly cleanups;
|
|
9
|
+
private started;
|
|
11
10
|
constructor(channel: ExtensionChannel, adapter: FeishuChannelAdapterContract);
|
|
12
11
|
readonly start: () => Promise<void>;
|
|
13
12
|
readonly stop: () => Promise<void>;
|
|
14
13
|
private readonly applyConfig;
|
|
15
14
|
private readonly submitMessage;
|
|
16
15
|
private readonly sendNcpEvent;
|
|
16
|
+
private readonly drainCleanups;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
export { FeishuExtensionRuntime };
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
//#region src/services/feishu-extension-runtime.service.ts
|
|
2
2
|
var FeishuExtensionRuntime = class {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
unsubscribeNcpEvents = null;
|
|
3
|
+
cleanups = [];
|
|
4
|
+
started = false;
|
|
6
5
|
constructor(channel, adapter) {
|
|
7
6
|
this.channel = channel;
|
|
8
7
|
this.adapter = adapter;
|
|
9
8
|
}
|
|
10
9
|
start = async () => {
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
10
|
+
if (this.started) return;
|
|
11
|
+
this.started = true;
|
|
12
|
+
this.cleanups.push(this.adapter.onMessage(this.submitMessage));
|
|
13
|
+
this.cleanups.push(this.channel.onNcpEvent(this.sendNcpEvent));
|
|
14
|
+
this.cleanups.push(this.channel.config.onChange(async () => {
|
|
14
15
|
await this.applyConfig();
|
|
15
|
-
});
|
|
16
|
+
}));
|
|
16
17
|
await this.applyConfig();
|
|
17
18
|
};
|
|
18
19
|
stop = async () => {
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.unsubscribeConfig = null;
|
|
23
|
-
this.unsubscribeMessages = null;
|
|
24
|
-
this.unsubscribeNcpEvents = null;
|
|
20
|
+
if (!this.started) return;
|
|
21
|
+
this.started = false;
|
|
22
|
+
this.drainCleanups();
|
|
25
23
|
await this.adapter.stop();
|
|
26
24
|
};
|
|
27
25
|
applyConfig = async () => {
|
|
@@ -61,6 +59,9 @@ var FeishuExtensionRuntime = class {
|
|
|
61
59
|
console.warn(`[feishu] failed to send NCP event: ${message}`);
|
|
62
60
|
}
|
|
63
61
|
};
|
|
62
|
+
drainCleanups = () => {
|
|
63
|
+
for (const cleanup of this.cleanups.splice(0).reverse()) cleanup();
|
|
64
|
+
};
|
|
64
65
|
};
|
|
65
66
|
//#endregion
|
|
66
67
|
export { FeishuExtensionRuntime };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/channel-extension-feishu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NextClaw Feishu/Lark lightweight channel extension process.",
|
|
6
6
|
"type": "module",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
22
|
-
"@nextclaw/extension-sdk": "0.1.
|
|
23
|
-
"@nextclaw/ncp
|
|
24
|
-
"@nextclaw/ncp": "0.5.
|
|
22
|
+
"@nextclaw/extension-sdk": "0.1.5",
|
|
23
|
+
"@nextclaw/ncp": "0.5.11",
|
|
24
|
+
"@nextclaw/ncp-toolkit": "0.5.16"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^20.17.6",
|