node-karin 0.3.4 → 0.3.7

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,3 +1,4 @@
1
+ /// <reference types="@types/ws" />
1
2
  /// <reference types="node" />
2
3
  import WebSocket from 'ws';
3
4
  import { IncomingMessage } from 'http';
@@ -94,8 +94,8 @@ export declare const listener: {
94
94
  * @param options.retry_count - 重试次数
95
95
  */
96
96
  sendMsg(uid: string, contact: contact, elements: KarinElement, options?: {
97
- recallMsg: number;
98
- retry_count: number;
97
+ recallMsg?: number;
98
+ retry_count?: number;
99
99
  }): Promise<{
100
100
  message_id: string;
101
101
  }>;
@@ -178,7 +178,7 @@ export const listener = new (class Listeners extends EventEmitter {
178
178
  logger.bot('error', self_id, error)
179
179
  }
180
180
  /** 快速撤回 */
181
- if (bot.RecallMessage && recallMsg > 0 && result?.message_id) {
181
+ if (recallMsg && bot.RecallMessage && recallMsg > 0 && result?.message_id) {
182
182
  setTimeout(() => bot.RecallMessage(contact, result.message_id), recallMsg * 1000)
183
183
  }
184
184
  return result
package/lib/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export declare const Renderer: {
25
25
  }): number;
26
26
  unapp(index: number): boolean;
27
27
  App(id?: string): import("./types/index.js").KarinRenderApp;
28
- render(options: import("./types/index.js").KarinRenderType, id: string): Promise<string | string[]>;
28
+ render(options: import("./types/index.js").KarinRenderType, id?: string | undefined): Promise<string | string[]>;
29
29
  renderHtml(data: string): Promise<string | string[]>;
30
30
  };
31
31
  export declare const Cfg: {
@@ -35,7 +35,7 @@ export declare const Cfg: {
35
35
  change: Map<string, any>;
36
36
  watcher: Map<string, any>;
37
37
  review: boolean;
38
- loggger: import("log4js").Logger;
38
+ logger: import("log4js").Logger;
39
39
  initCfg(): Promise<void>;
40
40
  getPlugins(): string[];
41
41
  dirPath(name: string, plugins: string[]): Promise<void>;
@@ -92,8 +92,8 @@ export declare const Bot: {
92
92
  path: string;
93
93
  }[] | (new () => import("./types/index.js").KarinAdapter)[];
94
94
  sendMsg(uid: string, contact: import("./types/index.js").contact, elements: import("./types/index.js").KarinElement, options?: {
95
- recallMsg: number;
96
- retry_count: number;
95
+ recallMsg?: number | undefined;
96
+ retry_count?: number | undefined;
97
97
  }): Promise<{
98
98
  message_id: string;
99
99
  }>;
package/lib/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ /// <reference types="@types/express" />
2
+ /// <reference types="@types/lodash" />
3
+ /// <reference types="@types/node" />
4
+ /// <reference types="@types/node-schedule" />
5
+ /// <reference types="@types/ws" />
1
6
  // 基本模块
2
7
  export * from 'kritor-proto';
3
8
  export * from './core/index.js';
@@ -31,7 +31,7 @@ declare class Renderer {
31
31
  /**
32
32
  * 调用标准渲染器
33
33
  */
34
- render(options: KarinRenderType, id: string): Promise<string | string[]>;
34
+ render(options: KarinRenderType, id?: string): Promise<string | string[]>;
35
35
  /**
36
36
  * 快速渲染
37
37
  * @param data html路径、http地址
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/ws" />
1
2
  import WebSocket from 'ws';
2
3
  import { RenderBase } from './base.js';
3
4
  import { KarinRenderType } from '../types/render.js';
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/ws" />
1
2
  /// <reference types="node" />
2
3
  import WebSocket from 'ws';
3
4
  import { RenderBase } from './base.js';
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/ws" />
1
2
  /// <reference types="node" />
2
3
  import { WebSocket } from 'ws';
3
4
  import { IncomingMessage } from 'http';
@@ -50,7 +50,7 @@ export interface KarinRenderType {
50
50
  /**
51
51
  * - 设备像素比
52
52
  */
53
- deviceScaleFactor?: string;
53
+ deviceScaleFactor?: number;
54
54
  };
55
55
  /**
56
56
  * - 分页截图 传递数字则视为视窗高度 返回数组
@@ -10,7 +10,7 @@ export declare const config: {
10
10
  change: Map<string, any>;
11
11
  watcher: Map<string, any>;
12
12
  review: boolean;
13
- loggger: Logger;
13
+ logger: Logger;
14
14
  /** 初始化配置 */
15
15
  initCfg(): Promise<void>;
16
16
  getPlugins(): string[];
@@ -10,7 +10,7 @@ export const config = new (class Cfg {
10
10
  change
11
11
  watcher
12
12
  review
13
- loggger
13
+ logger
14
14
  constructor () {
15
15
  this.dir = karinDir
16
16
  this._path = process.cwd() + '/config'
@@ -43,7 +43,7 @@ export const config = new (class Cfg {
43
43
  this.dirPath('temp', plugins)
44
44
  this.dirPath('resources', plugins)
45
45
  this.dirPath('temp/html', plugins)
46
- this.loggger = (await import('./logger.js')).default
46
+ this.logger = (await import('./logger.js')).default
47
47
  }
48
48
 
49
49
  getPlugins () {
@@ -212,7 +212,7 @@ export const config = new (class Cfg {
212
212
  /** 监听文件变化 */
213
213
  watcher.on('change', () => {
214
214
  this.change.delete(key)
215
- this.loggger.mark(`[修改配置文件][${type}][${name}]`)
215
+ this.logger.mark(`[修改配置文件][${type}][${name}]`)
216
216
  /** 文件修改后调用对应的方法 */
217
217
  switch (`change_${name}`) {
218
218
  case 'change_App':
@@ -236,7 +236,7 @@ export const config = new (class Cfg {
236
236
 
237
237
  async change_config () {
238
238
  /** 修改日志等级 */
239
- this.loggger.level = this.Config.log4jsCfg.level
239
+ this.logger.level = this.Config.log4jsCfg.level
240
240
  await this.#review()
241
241
  if (this.Server.HotUpdate) {
242
242
  const { Bot } = await import('../index.js')
@@ -0,0 +1 @@
1
+ declare module 'kritor-proto'
package/modules.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import ws from 'ws';
4
+ import moment from 'moment';
5
+ import lodash from 'lodash';
6
+ import express from 'express';
7
+ import axios from 'axios';
8
+ import chalk from 'chalk';
9
+ import chokidar from 'chokidar';
10
+ import { Level as level } from 'level';
11
+ import schedule from 'node-schedule';
12
+ import yaml from 'yaml';
13
+ import log4js from 'log4js';
14
+ export { fs, ws, path, axios, lodash, moment, express, chalk, chokidar, level, schedule, yaml, log4js, };
package/modules.js ADDED
@@ -0,0 +1,14 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import ws from 'ws';
4
+ import moment from 'moment';
5
+ import lodash from 'lodash';
6
+ import express from 'express';
7
+ import axios from 'axios';
8
+ import chalk from 'chalk';
9
+ import chokidar from 'chokidar';
10
+ import { Level as level } from 'level';
11
+ import schedule from 'node-schedule';
12
+ import yaml from 'yaml';
13
+ import log4js from 'log4js';
14
+ export { fs, ws, path, axios, lodash, moment, express, chalk, chokidar, level, schedule, yaml, log4js, };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.3.4",
3
+ "version": "0.3.7",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",
7
+ "types": "./lib/index.d.ts",
7
8
  "bugs": {
8
9
  "url": "https://github.com/KarinJS/Karin/issues"
9
10
  },
@@ -26,6 +27,8 @@
26
27
  "/lib/**/*.d.ts",
27
28
  "/config/defSet/*.yaml",
28
29
  "/config/view/*.yaml",
30
+ "modules.js",
31
+ "modules.d.ts",
29
32
  "LICENSE",
30
33
  "package.json",
31
34
  "README.md"
@@ -35,7 +38,8 @@
35
38
  ],
36
39
  "scripts": {
37
40
  "app": "node .",
38
- "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix",
41
+ "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix && npm run cp",
42
+ "cp": "cp ./lib/modules.d.ts ./modules.d.ts && cp ./lib/modules.js ./modules.js && cp ./src/utils/kritor-proto.d.ts ./lib/utils/kritor-proto.d.ts",
39
43
  "delete": "pm2 delete ./config/config/pm2.yaml",
40
44
  "fix": "eslint lib/**/*.js --fix",
41
45
  "fix:all": "eslint lib/**/*.js --fix && eslint src/**/*.ts --fix",