alemonjs 1.1.35 → 1.1.37

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.
@@ -69,8 +69,8 @@ export async function InstructionMatching(e) {
69
69
  /**
70
70
  * 上下文
71
71
  */
72
- for (const item in this.CommandApp) {
73
- const { name, APP } = this.CommandApp[item];
72
+ for (const item in APPLICATION.CommandApp) {
73
+ const { name, APP } = APPLICATION.CommandApp[item];
74
74
  const AppFnc = MSG.get(name);
75
75
  const AppArg = ARG.get(name);
76
76
  const arr = SLICING.get(name);
@@ -85,7 +85,7 @@ export async function InstructionMatching(e) {
85
85
  if (typeof AppArg == 'function')
86
86
  ARGCACHE[item] = await AppArg(e);
87
87
  const app = new APP(e);
88
- // 设置this.e
88
+ // 设置this
89
89
  app.e = e;
90
90
  // 如果存在用户上下文
91
91
  if (app.getContext) {
@@ -125,12 +125,12 @@ export async function InstructionMatching(e) {
125
125
  /**
126
126
  * 撤回事件 || 匹配不到事件 || 大正则不匹配
127
127
  */
128
- if (!this.Command[e.event] || !APPLICATION.mergedRegex.test(e.msg))
128
+ if (!APPLICATION.Command[e.event] || !APPLICATION.mergedRegex.test(e.msg))
129
129
  return true;
130
130
  /**
131
131
  * 循环所有指令
132
132
  */
133
- for (const data of this.Command[e.event]) {
133
+ for (const data of APPLICATION.Command[e.event]) {
134
134
  if (e.typing != data.typing ||
135
135
  data.reg === undefined ||
136
136
  !data.reg.test(e.msg)) {
@@ -164,7 +164,7 @@ export async function InstructionMatching(e) {
164
164
  export async function InstructionMatchingByNotMessage(e) {
165
165
  if (process.env?.ALEMONJS_MESSAGE == 'dev')
166
166
  console.info('e', e);
167
- if (!this.CommandNotMessage[e.event])
167
+ if (!APPLICATION.CommandNotMessage[e.event])
168
168
  return true;
169
169
  /**
170
170
  * 回调系统
@@ -184,8 +184,8 @@ export async function InstructionMatchingByNotMessage(e) {
184
184
  }
185
185
  const APPCACHE = {};
186
186
  const ARGCACHE = {};
187
- for (const item in this.CommandApp) {
188
- const { name, APP } = this.CommandApp[item];
187
+ for (const item in APPLICATION.CommandApp) {
188
+ const { name, APP } = APPLICATION.CommandApp[item];
189
189
  const AppFnc = MSG.get(name);
190
190
  const AppArg = ARG.get(name);
191
191
  try {
@@ -203,7 +203,7 @@ export async function InstructionMatchingByNotMessage(e) {
203
203
  }
204
204
  }
205
205
  // 循环查找
206
- for (const data of this.CommandNotMessage[e.event]) {
206
+ for (const data of APPLICATION.CommandNotMessage[e.event]) {
207
207
  if (e.typing != data.typing)
208
208
  continue;
209
209
  try {
@@ -1,16 +1,10 @@
1
- import { arch } from 'os';
2
1
  import { existsSync, realpathSync } from 'fs';
3
2
  import { execSync } from 'child_process';
4
- const isArch = arch();
5
3
  const platform = process.platform;
6
4
  const win32Edge = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe';
7
- // Downloa
8
- let skipDownload = false;
9
5
  // Path
10
6
  let executablePath;
11
7
  if (process.platform == 'win32' && existsSync(win32Edge)) {
12
- // win32 Edge
13
- skipDownload = true;
14
8
  executablePath = win32Edge;
15
9
  }
16
10
  else if (platform == 'linux' || platform == 'android') {
@@ -22,6 +16,8 @@ else if (platform == 'linux' || platform == 'android') {
22
16
  'whereis chromium',
23
17
  'whereis firefox'
24
18
  ];
19
+ // Downloa
20
+ let skipDownload = false;
25
21
  // get path
26
22
  for (const item of chromium) {
27
23
  try {
@@ -44,28 +40,19 @@ else if (platform == 'linux' || platform == 'android') {
44
40
  const arr = [
45
41
  '/usr/bin/chromium',
46
42
  '/snap/bin/chromium',
47
- '/usr/bin/chromium-browser'
43
+ '/usr/bin/chromium-browser',
44
+ '/data/data/com.termux/files/usr/lib/chromium-browser'
48
45
  ];
49
46
  for (const item of arr) {
50
47
  if (existsSync(item)) {
51
- skipDownload = true;
52
48
  executablePath = item;
53
49
  break;
54
50
  }
55
51
  }
56
52
  }
57
- // arm64/arrch64
58
- if (isArch == 'arm64' || isArch == 'aarch64') {
59
- skipDownload = true;
60
- }
61
53
  }
62
54
  /**
63
55
  * 得到可寻地址
64
56
  * @returns 配置对象
65
57
  */
66
- export function getPupPath() {
67
- return {
68
- skipDownload,
69
- executablePath
70
- };
71
- }
58
+ export { executablePath };
@@ -1,7 +1,7 @@
1
1
  import puppeteer from 'puppeteer';
2
2
  import queryString from 'querystring';
3
3
  import { watch } from 'fs';
4
- import { getPupPath as PupPath } from './pup.js';
4
+ import { executablePath } from './pup.js';
5
5
  class Pup {
6
6
  // 截图次数记录
7
7
  pic = 0;
@@ -13,8 +13,9 @@ class Pup {
13
13
  isBrowser = false;
14
14
  // 配置
15
15
  launch = {
16
- headless: process.env?.ALEMONJS_PUPPERTEER_HEADLESS ?? 'new',
17
- timeout: Number(process.env?.ALEMONJS_PUPPERTEER_TIMEOUT ?? 30000),
16
+ headless: 'new',
17
+ timeout: 30000,
18
+ executablePath,
18
19
  args: [
19
20
  '--disable-gpu',
20
21
  '--disable-dev-shm-usage',
@@ -23,8 +24,7 @@ class Pup {
23
24
  '--no-sandbox',
24
25
  '--no-zygote',
25
26
  '--single-process'
26
- ],
27
- skipDownload: true
27
+ ]
28
28
  };
29
29
  /**
30
30
  * 设置
@@ -207,13 +207,8 @@ class Pup {
207
207
  delete this.watchCache[tplFile];
208
208
  });
209
209
  }
210
- init = PupPath;
211
210
  }
212
211
  export const Screenshot = new Pup();
213
- /**
214
- * @deprecated 已废弃
215
- */
216
- export const getPupPath = Screenshot.init;
217
212
  /**
218
213
  * @deprecated 已废弃
219
214
  */
@@ -36,8 +36,7 @@ export async function defineAlemonConfig(Options) {
36
36
  * pup配置
37
37
  * *******
38
38
  */
39
- const pCig = { ...Screenshot.launch, ...Screenshot.init() };
40
- BOTCONFIG.set('puppeteer', pCig);
39
+ BOTCONFIG.set('puppeteer', Screenshot.launch);
41
40
  if (Options?.puppeteer) {
42
41
  BOTCONFIG.set('puppeteer', Options?.puppeteer);
43
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "description": "DOCS https://alemonjs.com/",
5
5
  "scripts": {
6
6
  "dev": "ts-node alemon.config.ts",
@@ -1,6 +1,6 @@
1
- import { Configuration } from 'puppeteer';
1
+ declare let executablePath: string;
2
2
  /**
3
3
  * 得到可寻地址
4
4
  * @returns 配置对象
5
5
  */
6
- export declare function getPupPath(): Configuration;
6
+ export { executablePath };
@@ -1,14 +1,13 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import puppeteer, { Browser, PuppeteerLaunchOptions, ScreenshotOptions, PuppeteerLifeCycleEvent } from 'puppeteer';
3
+ import { Browser, PuppeteerLaunchOptions, ScreenshotOptions, PuppeteerLifeCycleEvent } from 'puppeteer';
4
4
  import queryString from 'querystring';
5
- import { getPupPath as PupPath } from './pup.js';
6
5
  declare class Pup {
7
6
  pic: number;
8
7
  restart: number;
9
8
  browser: Browser;
10
9
  isBrowser: boolean;
11
- launch: puppeteer.PuppeteerLaunchOptions;
10
+ launch: PuppeteerLaunchOptions;
12
11
  /**
13
12
  * 设置
14
13
  * @param val
@@ -18,7 +17,7 @@ declare class Pup {
18
17
  * 获取
19
18
  * @returns
20
19
  */
21
- getLaunch(): puppeteer.PuppeteerLaunchOptions;
20
+ getLaunch(): PuppeteerLaunchOptions;
22
21
  /**
23
22
  * 启动pup
24
23
  * @returns
@@ -58,21 +57,22 @@ declare class Pup {
58
57
  cache?: boolean;
59
58
  waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
60
59
  }): Promise<string | false | Buffer>;
61
- cache: {};
62
- html: {};
63
- watchCache: {};
60
+ cache: {
61
+ [key: string]: any;
62
+ };
63
+ html: {
64
+ [key: string]: any;
65
+ };
66
+ watchCache: {
67
+ [key: string]: any;
68
+ };
64
69
  /**
65
70
  * 缓存监听
66
71
  * @param tplFile 模板地址
67
72
  */
68
73
  watch(tplFile: string): void;
69
- init: typeof PupPath;
70
74
  }
71
75
  export declare const Screenshot: Pup;
72
- /**
73
- * @deprecated 已废弃
74
- */
75
- export declare const getPupPath: typeof PupPath;
76
76
  /**
77
77
  * @deprecated 已废弃
78
78
  */