node-karin 1.3.17 → 1.3.19

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.3.19](https://github.com/KarinJS/Karin/compare/core-v1.3.18...core-v1.3.19) (2025-02-25)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * hook ([3647bb2](https://github.com/KarinJS/Karin/commit/3647bb2db51d09a7ad94c33a78abb42455300abe))
9
+
10
+ ## [1.3.18](https://github.com/KarinJS/Karin/compare/core-v1.3.17...core-v1.3.18) (2025-02-24)
11
+
12
+
13
+ ### 🐛 Bug Fixes
14
+
15
+ * 兼容性提升 ([d22b68a](https://github.com/KarinJS/Karin/commit/d22b68a7600d419c4c2571e21893d2d36011df25))
16
+
3
17
  ## [1.3.17](https://github.com/KarinJS/Karin/compare/core-v1.3.16...core-v1.3.17) (2025-02-24)
4
18
 
5
19
 
package/dist/index.d.ts CHANGED
@@ -11212,8 +11212,9 @@ interface MessageHookItem<T extends UnionMessage> {
11212
11212
  * @param contact 联系人
11213
11213
  * @param elements 消息元素
11214
11214
  * @param retryCount 重试次数
11215
+ * @param next 继续执行下一个钩子的函数
11215
11216
  */
11216
- type BaseMessageCallback<T> = (contact: Contact, elements: Array<Elements>, retryCount?: number) => T | Promise<T>;
11217
+ type BaseMessageCallback<T> = (contact: Contact, elements: Array<Elements>, retryCount: number, next: HookNext) => T | Promise<T>;
11217
11218
  /**
11218
11219
  * 接收普通消息发送回调类型 这个由开发者调用
11219
11220
  */
@@ -11227,8 +11228,9 @@ type HookEmitMessage = BaseMessageCallback<boolean>;
11227
11228
  * @param contact 联系人
11228
11229
  * @param elements 消息元素
11229
11230
  * @param options 转发选项
11231
+ * @param next 继续执行下一个钩子的函数
11230
11232
  */
11231
- type BaseForwardCallback<T> = (contact: Contact, elements: Array<NodeElement>, options?: ForwardOptions) => T | Promise<T>;
11233
+ type BaseForwardCallback<T> = (contact: Contact, elements: Array<NodeElement>, options: ForwardOptions | undefined, next: HookNext) => T | Promise<T>;
11232
11234
  /**
11233
11235
  * 接收转发消息回调类型 这个由开发者调用
11234
11236
  */
package/dist/index.js CHANGED
@@ -3400,8 +3400,6 @@ var init_list = __esm({
3400
3400
  if (fs15.existsSync(`${pluginDir}/${v.name}/package.json`)) return;
3401
3401
  list2.push(`app:${v.name}`);
3402
3402
  }));
3403
- const root2 = await requireFile("./package.json");
3404
- if (root2.name && root2.karin) list2.push(`root:${root2.name}`);
3405
3403
  };
3406
3404
  filterGit = async (files, list2) => {
3407
3405
  await Promise.all(files.map(async (v) => {
@@ -3410,6 +3408,8 @@ var init_list = __esm({
3410
3408
  if (!fs15.existsSync(path9.join(pluginDir, v.name, "package.json"))) return;
3411
3409
  list2.push(`git:${v.name}`);
3412
3410
  }));
3411
+ const root2 = await requireFile("./package.json");
3412
+ if (root2.name && root2.karin) list2.push(`root:${root2.name}`);
3413
3413
  };
3414
3414
  filterPkg = async (list2) => {
3415
3415
  const exclude = [
@@ -5686,13 +5686,17 @@ var init_sendMsg = __esm({
5686
5686
  }
5687
5687
  };
5688
5688
  emitHooks = async (hooks2, callback) => {
5689
- const isNext = false;
5689
+ let shouldContinue = false;
5690
5690
  for (const hook of hooks2) {
5691
- const result = callback(hook);
5691
+ const next = () => {
5692
+ shouldContinue = true;
5693
+ };
5694
+ const result = callback(hook, next);
5692
5695
  if (isPromise(result)) await result;
5693
- if (!isNext) return false;
5696
+ if (!shouldContinue) return false;
5697
+ shouldContinue = false;
5694
5698
  }
5695
- return isNext;
5699
+ return true;
5696
5700
  };
5697
5701
  hooksSendMsgEmit = {
5698
5702
  /**
@@ -5702,10 +5706,10 @@ var init_sendMsg = __esm({
5702
5706
  * @param retryCount 重试次数
5703
5707
  * @returns 是否继续正常流程
5704
5708
  */
5705
- message: async (contact3, elements, retryCount) => {
5709
+ message: async (contact3, elements, retryCount = 0) => {
5706
5710
  return emitHooks(
5707
5711
  cache10.sendMsg.message,
5708
- (hook) => hook.callback(contact3, elements, retryCount)
5712
+ (hook, next) => hook.callback(contact3, elements, retryCount, next)
5709
5713
  );
5710
5714
  },
5711
5715
  /**
@@ -5718,7 +5722,7 @@ var init_sendMsg = __esm({
5718
5722
  forward: async (contact3, elements, options) => {
5719
5723
  return emitHooks(
5720
5724
  cache10.sendMsg.forward,
5721
- (hook) => hook.callback(contact3, elements, options)
5725
+ (hook, next) => hook.callback(contact3, elements, options, next)
5722
5726
  );
5723
5727
  }
5724
5728
  };
@@ -7798,8 +7802,9 @@ var init_messaeg = __esm({
7798
7802
  });
7799
7803
  if (isPromise2(result)) await result;
7800
7804
  if (!isNext) return false;
7805
+ isNext = false;
7801
7806
  }
7802
- return isNext;
7807
+ return true;
7803
7808
  };
7804
7809
  hooksMessageEmit = {
7805
7810
  /**
@@ -7931,8 +7936,16 @@ var init_groups4 = __esm({
7931
7936
  initAlias(ctx3, group.alias);
7932
7937
  initEmit(ctx3);
7933
7938
  initPrint2(ctx3, "group", "\u7FA4\u6D88\u606F", isPrint ? "info" : "debug");
7934
- hooksMessageEmit.group(ctx3);
7935
- hooksMessageEmit.message(ctx3);
7939
+ const hook = await hooksMessageEmit.group(ctx3);
7940
+ if (!hook) {
7941
+ logger.debug(`[${ctx3.logFnc}] \u7FA4\u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
7942
+ return;
7943
+ }
7944
+ const hook2 = await hooksMessageEmit.message(ctx3);
7945
+ if (!hook2) {
7946
+ logger.debug(`[${ctx3.logFnc}] \u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
7947
+ return;
7948
+ }
7936
7949
  const context2 = context(ctx3);
7937
7950
  if (context2) return ctx3;
7938
7951
  const cd = groupsCD(group, ctx3.groupId, ctx3.userId);
@@ -7960,8 +7973,16 @@ var init_groups4 = __esm({
7960
7973
  initAlias(ctx3, group.alias);
7961
7974
  initEmit(ctx3);
7962
7975
  initPrint2(ctx3, "groupTemp", "\u7FA4\u4E34\u65F6\u6D88\u606F");
7963
- hooksMessageEmit.groupTemp(ctx3);
7964
- hooksMessageEmit.message(ctx3);
7976
+ const hook = await hooksMessageEmit.groupTemp(ctx3);
7977
+ if (!hook) {
7978
+ logger.debug(`[${ctx3.logFnc}] \u7FA4\u4E34\u65F6\u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
7979
+ return;
7980
+ }
7981
+ const hook2 = await hooksMessageEmit.message(ctx3);
7982
+ if (!hook2) {
7983
+ logger.debug(`[${ctx3.logFnc}] \u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
7984
+ return;
7985
+ }
7965
7986
  const context2 = context(ctx3);
7966
7987
  if (context2) return ctx3;
7967
7988
  const cd = groupsCD(group, ctx3.groupId, ctx3.userId);
@@ -8091,8 +8112,16 @@ var init_private3 = __esm({
8091
8112
  initAlias(ctx3, friend.alias);
8092
8113
  initEmit(ctx3);
8093
8114
  initPrint3(ctx3, "friend", "\u597D\u53CB\u6D88\u606F");
8094
- hooksMessageEmit.friend(ctx3);
8095
- hooksMessageEmit.message(ctx3);
8115
+ const hook = await hooksMessageEmit.friend(ctx3);
8116
+ if (!hook) {
8117
+ logger.debug(`[${ctx3.logFnc}] \u597D\u53CB\u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
8118
+ return;
8119
+ }
8120
+ const hook2 = await hooksMessageEmit.message(ctx3);
8121
+ if (!hook2) {
8122
+ logger.debug(`[${ctx3.logFnc}] \u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
8123
+ return;
8124
+ }
8096
8125
  const context2 = context(ctx3);
8097
8126
  if (context2) return ctx3;
8098
8127
  const filter = privateFilterEvent(ctx3, config2, friend, privateCD(friend, ctx3.userId));
@@ -8112,8 +8141,16 @@ var init_private3 = __esm({
8112
8141
  initAlias(ctx3, friend.alias);
8113
8142
  initEmit(ctx3);
8114
8143
  initPrint3(ctx3, "direct", "\u9891\u9053\u79C1\u4FE1");
8115
- hooksMessageEmit.direct(ctx3);
8116
- hooksMessageEmit.message(ctx3);
8144
+ const hook = await hooksMessageEmit.direct(ctx3);
8145
+ if (!hook) {
8146
+ logger.debug(`[${ctx3.logFnc}] \u9891\u9053\u79C1\u4FE1\u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
8147
+ return;
8148
+ }
8149
+ const hook2 = await hooksMessageEmit.message(ctx3);
8150
+ if (!hook2) {
8151
+ logger.debug(`[${ctx3.logFnc}] \u6D88\u606F\u94A9\u5B50\u8FD4\u56DEfalse \u8DF3\u8FC7\u5F53\u524D\u4E8B\u4EF6: ${ctx3.eventId}`);
8152
+ return;
8153
+ }
8117
8154
  const context2 = context(ctx3);
8118
8155
  if (context2) return ctx3;
8119
8156
  const cd = privateCD(friend, ctx3.userId);
@@ -10880,31 +10917,35 @@ var init_local = __esm({
10880
10917
  var _a, _b;
10881
10918
  const pkg2 = val.pkgData;
10882
10919
  if (isTs() && ((_a = pkg2.karin) == null ? void 0 : _a["ts-web"])) {
10883
- const config2 = await getWebConfig(val.type, val.name);
10884
- if (config2 && config2.info) {
10885
- result.push({
10886
- ...config2.info,
10887
- id: val.name,
10888
- version: config2.info.version ?? pkg2.version,
10889
- description: config2.info.description ?? pkg2.description,
10890
- hasConfig: true,
10891
- type: val.type
10892
- });
10920
+ let config2 = await getWebConfig(val.type, val.name);
10921
+ if (!config2 && isDev()) {
10922
+ config2 = await getWebConfig("git", val.name);
10893
10923
  }
10924
+ if (!config2 || !config2.info) return;
10925
+ result.push({
10926
+ ...config2.info,
10927
+ id: val.name,
10928
+ version: config2.info.version ?? pkg2.version,
10929
+ description: config2.info.description ?? pkg2.description,
10930
+ hasConfig: true,
10931
+ type: val.type
10932
+ });
10894
10933
  return;
10895
10934
  }
10896
10935
  if ((_b = pkg2.karin) == null ? void 0 : _b.web) {
10897
- const config2 = await getWebConfig(val.type, val.name);
10898
- if (config2 && config2.info) {
10899
- result.push({
10900
- ...config2.info,
10901
- id: val.name,
10902
- version: config2.info.version ?? pkg2.version,
10903
- description: config2.info.description ?? pkg2.description,
10904
- hasConfig: true,
10905
- type: val.type
10906
- });
10936
+ let config2 = await getWebConfig(val.type, val.name);
10937
+ if (!config2 && isDev()) {
10938
+ config2 = await getWebConfig("git", val.name);
10907
10939
  }
10940
+ if (!config2 || !config2.info) return;
10941
+ result.push({
10942
+ ...config2.info,
10943
+ id: val.name,
10944
+ version: config2.info.version ?? pkg2.version,
10945
+ description: config2.info.description ?? pkg2.description,
10946
+ hasConfig: true,
10947
+ type: val.type
10948
+ });
10908
10949
  }
10909
10950
  }));
10910
10951
  createSuccessResponse(res, result);
@@ -0,0 +1 @@
1
+ import{d as a}from"./index-Wy6xtsbt.js";var r=a;export{r as default};