alemonjs 1.1.36 → 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.
@@ -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.36",
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
  */