alemonjs 1.3.1 → 1.3.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.
- package/LICENSE +21 -21
- package/README.md +110 -110
- package/config/tsconfig.json +36 -39
- package/dist/config/types.d.ts +0 -2
- package/dist/core/main.d.ts +0 -3
- package/dist/core/utils/index.d.ts +0 -1
- package/dist/define/types.d.ts +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +18 -365
- package/package.json +87 -99
- package/.puppeteerrc.cjs +0 -67
- package/dist/core/utils/component.d.ts +0 -25
- package/dist/core/utils/link.d.ts +0 -1
- package/dist/core/utils/module.d.ts +0 -1
- package/dist/core/utils/picture.d.ts +0 -7
- package/dist/core/utils/puppeteer.d.ts +0 -32
- package/dist/main.css +0 -8
- package/dist/require.d.ts +0 -1
- package/dist/url.d.ts +0 -2
- package/env.d.ts +0 -129
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013-present, Yuxi (Evan) You
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-present, Yuxi (Evan) You
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
# AlemonJS [https://alemonjs.com](https://alemonjs.com)
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
<a
|
|
5
|
-
href="https://alemonjs.com/"
|
|
6
|
-
target="_blank"
|
|
7
|
-
rel="noopener noreferrer">
|
|
8
|
-
<img
|
|
9
|
-
width="256"
|
|
10
|
-
height="128"
|
|
11
|
-
src="https://alemonjs.com/img/alemon.jpg"
|
|
12
|
-
alt="AlemonJS LOGO"
|
|
13
|
-
>
|
|
14
|
-
</a>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<div align="center">
|
|
18
|
-
|
|
19
|
-
跨平台开发的事件驱动机器人 | 支持 QQ (群&频道)、KOOK、Discord
|
|
20
|
-
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
### Ecosystem
|
|
24
|
-
|
|
25
|
-
| Project | Status | Description |
|
|
26
|
-
| ----------------- | ---------------------------------------------------- | --------------- |
|
|
27
|
-
| [alemonjs] | [![alemonjs-status]][alemonjs-package] | 标准应用解析器 |
|
|
28
|
-
| [create-alemonjs] | [![create-alemonjs-status]][create-alemonjs-package] | 模板创建脚手架 |
|
|
29
|
-
| [alemon-ffmpeg] | [![alemon-ffmpeg-status]][alemon-ffmpeg-package] | ffmpeg 自动下载 |
|
|
30
|
-
|
|
31
|
-
[alemonjs]: https://github.com/ningmengchongshui/alemonjs
|
|
32
|
-
[alemonjs-status]: https://img.shields.io/npm/v/alemonjs.svg
|
|
33
|
-
[alemonjs-package]: https://www.npmjs.com/package/alemonjs
|
|
34
|
-
[create-alemonjs]: https://github.com/ningmengchongshui/alemonjs/tree/create-alemonjs
|
|
35
|
-
[create-alemonjs-status]: https://img.shields.io/npm/v/create-alemonjs.svg
|
|
36
|
-
[create-alemonjs-package]: https://www.npmjs.com/package/create-alemonjs
|
|
37
|
-
[alemon-ffmpeg]: https://github.com/kongxiangyiren/alemon-ffmpeg
|
|
38
|
-
[alemon-ffmpeg-status]: https://img.shields.io/npm/v/alemon-ffmpeg.svg
|
|
39
|
-
[alemon-ffmpeg-package]: https://www.npmjs.com/package/alemon-ffmpeg
|
|
40
|
-
|
|
41
|
-
### Quick Start
|
|
42
|
-
|
|
43
|
-
可直接执行脚手架 并快速启动程序
|
|
44
|
-
|
|
45
|
-
```sh
|
|
46
|
-
npm install pnpm -g
|
|
47
|
-
pnpm create alemonjs@latest -y
|
|
48
|
-
cd alemonb
|
|
49
|
-
npm install
|
|
50
|
-
npm run dev
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
连接平台需要正确配置登录
|
|
54
|
-
|
|
55
|
-
`alemon.login.ts`
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
import { defineConfig } from 'alemonjs'
|
|
59
|
-
export default defineConfig({
|
|
60
|
-
// 配置名 test
|
|
61
|
-
test: {
|
|
62
|
-
// qq平台配置
|
|
63
|
-
qq: {
|
|
64
|
-
appID: 'your app id',
|
|
65
|
-
token: 'your token'
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
// 配置名 pro
|
|
69
|
-
pro: {
|
|
70
|
-
// kook平台配置
|
|
71
|
-
kook: {}
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
> npm run [脚本名] [配置名] [平台名]
|
|
77
|
-
|
|
78
|
-
启动时带上匹配规则机器人正确启动
|
|
79
|
-
|
|
80
|
-
```sh
|
|
81
|
-
npm run dev test qq
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Development Examples
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
import { createApp, Events, Messages } from 'alemonjs'
|
|
88
|
-
// 监听事件
|
|
89
|
-
const event = new Events()
|
|
90
|
-
event.response('MEMBERS', async e => {
|
|
91
|
-
if (/^你好$/.test(e.msg)) e.reply('你好呀')
|
|
92
|
-
})
|
|
93
|
-
event.response('MEMBERS', async e => {
|
|
94
|
-
console.log('成员', e.user_name, '加入')
|
|
95
|
-
})
|
|
96
|
-
// 响应消息
|
|
97
|
-
const message = new Messages()
|
|
98
|
-
message.response(/^最近怎么样/, async e => {
|
|
99
|
-
e.reply('很好')
|
|
100
|
-
})
|
|
101
|
-
// 构建应用
|
|
102
|
-
const app = createApp(import.meta.url)
|
|
103
|
-
app.on(event.ok)
|
|
104
|
-
app.use(message.ok)
|
|
105
|
-
app.mount()
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Community
|
|
109
|
-
|
|
110
|
-
QQ Group 806943302
|
|
1
|
+
# AlemonJS [https://alemonjs.com](https://alemonjs.com)
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a
|
|
5
|
+
href="https://alemonjs.com/"
|
|
6
|
+
target="_blank"
|
|
7
|
+
rel="noopener noreferrer">
|
|
8
|
+
<img
|
|
9
|
+
width="256"
|
|
10
|
+
height="128"
|
|
11
|
+
src="https://alemonjs.com/img/alemon.jpg"
|
|
12
|
+
alt="AlemonJS LOGO"
|
|
13
|
+
>
|
|
14
|
+
</a>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div align="center">
|
|
18
|
+
|
|
19
|
+
跨平台开发的事件驱动机器人 | 支持 QQ (群&频道)、KOOK、Discord
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
### Ecosystem
|
|
24
|
+
|
|
25
|
+
| Project | Status | Description |
|
|
26
|
+
| ----------------- | ---------------------------------------------------- | --------------- |
|
|
27
|
+
| [alemonjs] | [![alemonjs-status]][alemonjs-package] | 标准应用解析器 |
|
|
28
|
+
| [create-alemonjs] | [![create-alemonjs-status]][create-alemonjs-package] | 模板创建脚手架 |
|
|
29
|
+
| [alemon-ffmpeg] | [![alemon-ffmpeg-status]][alemon-ffmpeg-package] | ffmpeg 自动下载 |
|
|
30
|
+
|
|
31
|
+
[alemonjs]: https://github.com/ningmengchongshui/alemonjs
|
|
32
|
+
[alemonjs-status]: https://img.shields.io/npm/v/alemonjs.svg
|
|
33
|
+
[alemonjs-package]: https://www.npmjs.com/package/alemonjs
|
|
34
|
+
[create-alemonjs]: https://github.com/ningmengchongshui/alemonjs/tree/create-alemonjs
|
|
35
|
+
[create-alemonjs-status]: https://img.shields.io/npm/v/create-alemonjs.svg
|
|
36
|
+
[create-alemonjs-package]: https://www.npmjs.com/package/create-alemonjs
|
|
37
|
+
[alemon-ffmpeg]: https://github.com/kongxiangyiren/alemon-ffmpeg
|
|
38
|
+
[alemon-ffmpeg-status]: https://img.shields.io/npm/v/alemon-ffmpeg.svg
|
|
39
|
+
[alemon-ffmpeg-package]: https://www.npmjs.com/package/alemon-ffmpeg
|
|
40
|
+
|
|
41
|
+
### Quick Start
|
|
42
|
+
|
|
43
|
+
可直接执行脚手架 并快速启动程序
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install pnpm -g
|
|
47
|
+
pnpm create alemonjs@latest -y
|
|
48
|
+
cd alemonb
|
|
49
|
+
npm install
|
|
50
|
+
npm run dev
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
连接平台需要正确配置登录
|
|
54
|
+
|
|
55
|
+
`alemon.login.ts`
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { defineConfig } from 'alemonjs'
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
// 配置名 test
|
|
61
|
+
test: {
|
|
62
|
+
// qq平台配置
|
|
63
|
+
qq: {
|
|
64
|
+
appID: 'your app id',
|
|
65
|
+
token: 'your token'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
// 配置名 pro
|
|
69
|
+
pro: {
|
|
70
|
+
// kook平台配置
|
|
71
|
+
kook: {}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> npm run [脚本名] [配置名] [平台名]
|
|
77
|
+
|
|
78
|
+
启动时带上匹配规则机器人正确启动
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npm run dev test qq
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Development Examples
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { createApp, Events, Messages } from 'alemonjs'
|
|
88
|
+
// 监听事件
|
|
89
|
+
const event = new Events()
|
|
90
|
+
event.response('MEMBERS', async e => {
|
|
91
|
+
if (/^你好$/.test(e.msg)) e.reply('你好呀')
|
|
92
|
+
})
|
|
93
|
+
event.response('MEMBERS', async e => {
|
|
94
|
+
console.log('成员', e.user_name, '加入')
|
|
95
|
+
})
|
|
96
|
+
// 响应消息
|
|
97
|
+
const message = new Messages()
|
|
98
|
+
message.response(/^最近怎么样/, async e => {
|
|
99
|
+
e.reply('很好')
|
|
100
|
+
})
|
|
101
|
+
// 构建应用
|
|
102
|
+
const app = createApp(import.meta.url)
|
|
103
|
+
app.on(event.ok)
|
|
104
|
+
app.use(message.ok)
|
|
105
|
+
app.mount()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Community
|
|
109
|
+
|
|
110
|
+
QQ Group 806943302
|
package/config/tsconfig.json
CHANGED
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"noImplicitAny": false,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"preserveConstEnums": true,
|
|
9
|
-
"ignoreDeprecations": "5.0",
|
|
10
|
-
"removeComments": true,
|
|
11
|
-
"jsx": "react",
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"allowJs": false,
|
|
15
|
-
"suppressImplicitAnyIndexErrors": true,
|
|
16
|
-
"typeRoots": ["node_modules/@types"],
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"experimentalSpecifierResolution": "node"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"noImplicitAny": false,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"preserveConstEnums": true,
|
|
9
|
+
"ignoreDeprecations": "5.0",
|
|
10
|
+
"removeComments": true,
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"allowJs": false,
|
|
15
|
+
"suppressImplicitAnyIndexErrors": true,
|
|
16
|
+
"typeRoots": ["node_modules/@types"],
|
|
17
|
+
/* */
|
|
18
|
+
"useDefineForClassFields": true,
|
|
19
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
/* Bundler mode */
|
|
22
|
+
"resolveJsonModule": true,
|
|
23
|
+
"isolatedModules": true,
|
|
24
|
+
/* Linting */
|
|
25
|
+
// "strict": true, 严格模式
|
|
26
|
+
"noUnusedLocals": true,
|
|
27
|
+
"noUnusedParameters": true,
|
|
28
|
+
"noFallthroughCasesInSwitch": true,
|
|
29
|
+
"forceConsistentCasingInFileNames": true
|
|
30
|
+
},
|
|
31
|
+
"ts-node": {
|
|
32
|
+
"esm": true,
|
|
33
|
+
"transpileOnly": true,
|
|
34
|
+
"experimentalSpecifierResolution": "node"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type PuppeteerLaunchOptions } from 'puppeteer';
|
|
2
1
|
import { type EmailOptions } from '../email/types.js';
|
|
3
2
|
import { type FileOptions } from '../file/index.js';
|
|
4
3
|
import { type KOOKOptions } from '../platform/kook/sdk/wss.types.js';
|
|
@@ -10,7 +9,6 @@ export interface BotConfigType {
|
|
|
10
9
|
kook: KOOKOptions;
|
|
11
10
|
qq: QQOptions;
|
|
12
11
|
file: FileOptions;
|
|
13
|
-
puppeteer: PuppeteerLaunchOptions;
|
|
14
12
|
ntqq: NTQQOptions;
|
|
15
13
|
discord: DISOCRDOptions;
|
|
16
14
|
email: EmailOptions;
|
package/dist/core/main.d.ts
CHANGED
|
@@ -10,7 +10,4 @@ export * from './config.js';
|
|
|
10
10
|
export * from './utils/index.js';
|
|
11
11
|
export * from './koa/main.js';
|
|
12
12
|
export * from './processor/read.js';
|
|
13
|
-
export * from './utils/component.js';
|
|
14
|
-
export * from './utils/module.js';
|
|
15
|
-
export * from './utils/picture.js';
|
|
16
13
|
export * from './func.js';
|
package/dist/define/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PuppeteerLaunchOptions } from 'puppeteer';
|
|
2
1
|
import { LoginOptions, PlatformsItemType } from '../default/types.js';
|
|
3
2
|
import { FileOptions } from '../file/types.js';
|
|
4
3
|
import { ApplicationProcessingOpsion, type ServerOptions } from '../core/index.js';
|
|
@@ -22,7 +21,6 @@ export interface AlemonOptions {
|
|
|
22
21
|
server?: ServerOptions;
|
|
23
22
|
file?: FileOptions;
|
|
24
23
|
pupStart?: false;
|
|
25
|
-
puppeteer?: PuppeteerLaunchOptions;
|
|
26
24
|
env?: DotenvConfigOptions;
|
|
27
25
|
email?: EmailOptions;
|
|
28
26
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve, dirname, basename, join } from 'path';
|
|
1
|
+
import { dirname, basename, join } from 'path';
|
|
3
2
|
import { fileURLToPath } from 'url';
|
|
4
3
|
import memory from 'memory-cache';
|
|
5
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, readFile, writeFile as writeFile$1, createReadStream,
|
|
4
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, readFile, writeFile as writeFile$1, createReadStream, unlinkSync, writeFileSync } from 'fs';
|
|
6
5
|
import { writeFile } from 'fs/promises';
|
|
7
6
|
import koabodyparser from 'koa-bodyparser';
|
|
8
7
|
import koacors from 'koa2-cors';
|
|
@@ -12,58 +11,15 @@ import { LRUCache } from 'lru-cache';
|
|
|
12
11
|
import axios from 'axios';
|
|
13
12
|
import { toDataURL } from 'qrcode';
|
|
14
13
|
import { publicIp } from 'public-ip';
|
|
15
|
-
import puppeteer from 'puppeteer';
|
|
16
|
-
import queryString from 'querystring';
|
|
17
14
|
import { Readable, isReadable } from 'stream';
|
|
18
15
|
import { fileTypeFromBuffer, fileTypeFromStream } from 'file-type';
|
|
19
|
-
import { renderToString } from 'react-dom/server';
|
|
20
|
-
import React from 'react';
|
|
21
|
-
import { createHash } from 'crypto';
|
|
22
16
|
import FormData from 'form-data';
|
|
23
17
|
import WebSocket from 'ws';
|
|
24
18
|
import { createTransport } from 'nodemailer';
|
|
25
19
|
import mime from 'mime-types';
|
|
20
|
+
import { createHash } from 'crypto';
|
|
26
21
|
import { configDotenv } from 'dotenv';
|
|
27
22
|
|
|
28
|
-
const require$1 = createRequire(import.meta.url);
|
|
29
|
-
const CustomExtensions = [
|
|
30
|
-
'.css',
|
|
31
|
-
'.apng',
|
|
32
|
-
'.png',
|
|
33
|
-
'.jpg',
|
|
34
|
-
'.jpeg',
|
|
35
|
-
'.jfif',
|
|
36
|
-
'.pjpeg',
|
|
37
|
-
'.pjp',
|
|
38
|
-
'.gif',
|
|
39
|
-
'.svg',
|
|
40
|
-
'.ico',
|
|
41
|
-
'.webp',
|
|
42
|
-
'.avif',
|
|
43
|
-
'.mp4',
|
|
44
|
-
'.webm',
|
|
45
|
-
'.ogg',
|
|
46
|
-
'.mp3',
|
|
47
|
-
'.wav',
|
|
48
|
-
'.flac',
|
|
49
|
-
'.aac',
|
|
50
|
-
'.opus',
|
|
51
|
-
'.mov',
|
|
52
|
-
'.m4a',
|
|
53
|
-
'.vtt',
|
|
54
|
-
'.woff',
|
|
55
|
-
'.woff2',
|
|
56
|
-
'.eot',
|
|
57
|
-
'.ttf',
|
|
58
|
-
'.otf',
|
|
59
|
-
'.md'
|
|
60
|
-
];
|
|
61
|
-
for (const ext of CustomExtensions) {
|
|
62
|
-
require$1.extensions[ext] = (module, filename) => {
|
|
63
|
-
module.exports = resolve(filename);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
23
|
const EventEnum = [
|
|
68
24
|
'MESSAGES',
|
|
69
25
|
'message',
|
|
@@ -682,155 +638,6 @@ class Ip {
|
|
|
682
638
|
}
|
|
683
639
|
const IP = new Ip();
|
|
684
640
|
|
|
685
|
-
const ALunchConfig = new BaseConfig$1({
|
|
686
|
-
timeout: 0,
|
|
687
|
-
protocolTimeout: 0,
|
|
688
|
-
headless: 'new',
|
|
689
|
-
args: [
|
|
690
|
-
'--disable-gpu',
|
|
691
|
-
'--disable-dev-shm-usage',
|
|
692
|
-
'--disable-setuid-sandbox',
|
|
693
|
-
'--no-first-run',
|
|
694
|
-
'--no-sandbox',
|
|
695
|
-
'--no-zygote',
|
|
696
|
-
'--single-process'
|
|
697
|
-
]
|
|
698
|
-
});
|
|
699
|
-
class Puppeteer {
|
|
700
|
-
#pic = 0;
|
|
701
|
-
#restart = 200;
|
|
702
|
-
#browser;
|
|
703
|
-
#isBrowser = false;
|
|
704
|
-
#launch = ALunchConfig.all();
|
|
705
|
-
setLaunch(val) {
|
|
706
|
-
this.#launch = val;
|
|
707
|
-
return this;
|
|
708
|
-
}
|
|
709
|
-
getLaunch() {
|
|
710
|
-
return this.#launch;
|
|
711
|
-
}
|
|
712
|
-
async start() {
|
|
713
|
-
try {
|
|
714
|
-
this.#browser = await puppeteer.launch(this.#launch);
|
|
715
|
-
this.#isBrowser = true;
|
|
716
|
-
loger.info('[puppeteer] open success');
|
|
717
|
-
return true;
|
|
718
|
-
}
|
|
719
|
-
catch (err) {
|
|
720
|
-
this.#isBrowser = false;
|
|
721
|
-
loger.error('[puppeteer] err', err);
|
|
722
|
-
return false;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
async isStart() {
|
|
726
|
-
if (!this.#isBrowser) {
|
|
727
|
-
const T = await this.start();
|
|
728
|
-
if (!T)
|
|
729
|
-
return false;
|
|
730
|
-
}
|
|
731
|
-
if (this.#pic <= this.#restart) {
|
|
732
|
-
this.#pic++;
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
735
|
-
this.#pic = 0;
|
|
736
|
-
loger.info('[puppeteer] close');
|
|
737
|
-
this.#isBrowser = false;
|
|
738
|
-
this.#browser.close().catch(err => {
|
|
739
|
-
loger.error('[puppeteer] close', err);
|
|
740
|
-
});
|
|
741
|
-
loger.info('[puppeteer] reopen');
|
|
742
|
-
if (!(await this.start()))
|
|
743
|
-
return false;
|
|
744
|
-
this.#pic++;
|
|
745
|
-
}
|
|
746
|
-
return true;
|
|
747
|
-
}
|
|
748
|
-
async render(htmlPath, Options) {
|
|
749
|
-
if (!(await this.isStart()))
|
|
750
|
-
return false;
|
|
751
|
-
try {
|
|
752
|
-
const page = await this.#browser.newPage().catch(err => {
|
|
753
|
-
loger.error(err);
|
|
754
|
-
});
|
|
755
|
-
if (!page)
|
|
756
|
-
return false;
|
|
757
|
-
await page.goto(`file://${htmlPath}`, {
|
|
758
|
-
timeout: Options?.timeout ?? 120000
|
|
759
|
-
});
|
|
760
|
-
const body = await page.$(Options?.tab ?? 'body');
|
|
761
|
-
loger.info('[puppeteer] success');
|
|
762
|
-
const buff = await body
|
|
763
|
-
.screenshot(Options?.SOptions ?? {
|
|
764
|
-
type: 'jpeg',
|
|
765
|
-
quality: 90
|
|
766
|
-
})
|
|
767
|
-
.catch(err => {
|
|
768
|
-
loger.error('[puppeteer]', 'screenshot', err);
|
|
769
|
-
return false;
|
|
770
|
-
});
|
|
771
|
-
await page.close().catch((err) => {
|
|
772
|
-
loger.error('[puppeteer]', 'page close', err);
|
|
773
|
-
});
|
|
774
|
-
if (!buff) {
|
|
775
|
-
loger.error('[puppeteer]', htmlPath);
|
|
776
|
-
return false;
|
|
777
|
-
}
|
|
778
|
-
return buff;
|
|
779
|
-
}
|
|
780
|
-
catch (err) {
|
|
781
|
-
loger.error('[puppeteer] newPage', err);
|
|
782
|
-
return false;
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
toFile = this.render;
|
|
786
|
-
async toUrl(Options) {
|
|
787
|
-
if (!(await this.isStart()))
|
|
788
|
-
return false;
|
|
789
|
-
try {
|
|
790
|
-
const page = await this.#browser.newPage().catch(err => {
|
|
791
|
-
loger.error(err);
|
|
792
|
-
});
|
|
793
|
-
if (!page)
|
|
794
|
-
return false;
|
|
795
|
-
const query = Options.params == undefined ? '' : queryString.stringify(Options.params);
|
|
796
|
-
const isurl = Options.params == undefined ? Options.url : `${Options.url}?${query}`;
|
|
797
|
-
await page.setCacheEnabled(Options.cache == undefined ? true : Options.cache);
|
|
798
|
-
await page.goto(isurl, {
|
|
799
|
-
timeout: Options.timeout ?? 120000,
|
|
800
|
-
waitUntil: Options.waitUntil ?? 'networkidle2'
|
|
801
|
-
});
|
|
802
|
-
loger.info('[screenshot] open', isurl);
|
|
803
|
-
const body = await page.$(Options.tab ?? 'body');
|
|
804
|
-
if (!body) {
|
|
805
|
-
await page.close();
|
|
806
|
-
loger.error('[screenshot] tab err');
|
|
807
|
-
return false;
|
|
808
|
-
}
|
|
809
|
-
await new Promise(resolve => setTimeout(resolve, Options.time ?? 1000));
|
|
810
|
-
const buff = await body
|
|
811
|
-
.screenshot(Options.rand ?? {
|
|
812
|
-
type: 'jpeg',
|
|
813
|
-
quality: 90,
|
|
814
|
-
path: ''
|
|
815
|
-
})
|
|
816
|
-
.catch(err => {
|
|
817
|
-
loger.error('[screenshot] page body', err);
|
|
818
|
-
return false;
|
|
819
|
-
});
|
|
820
|
-
await page.close();
|
|
821
|
-
if (!buff) {
|
|
822
|
-
loger.error('[screenshot] buffer err', Options.url);
|
|
823
|
-
return false;
|
|
824
|
-
}
|
|
825
|
-
return buff;
|
|
826
|
-
}
|
|
827
|
-
catch (err) {
|
|
828
|
-
loger.error('[screenshot] newPage', err);
|
|
829
|
-
return false;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
|
|
834
641
|
async function createPicFrom(image, name = 'image.jpg') {
|
|
835
642
|
let picData;
|
|
836
643
|
if (typeof image === 'string') {
|
|
@@ -1316,147 +1123,6 @@ if (!global.alemonjs.plugin)
|
|
|
1316
1123
|
global.alemonjs.plugin = APlugin;
|
|
1317
1124
|
const plugin = global.alemonjs.plugin;
|
|
1318
1125
|
|
|
1319
|
-
const require = createRequire(import.meta.url);
|
|
1320
|
-
const MainCSS = require('./main.css');
|
|
1321
|
-
const OutputCss = join(process.cwd(), 'public', 'output.css');
|
|
1322
|
-
|
|
1323
|
-
const getLink = () => {
|
|
1324
|
-
return renderToString(React.createElement(React.Fragment, null,
|
|
1325
|
-
React.createElement("link", { rel: "stylesheet", href: OutputCss }),
|
|
1326
|
-
React.createElement("link", { rel: "stylesheet", href: MainCSS })));
|
|
1327
|
-
};
|
|
1328
|
-
|
|
1329
|
-
function PathsCss(htmlContent) {
|
|
1330
|
-
const regex = /(src|href|url)\s*=\s*["']([^"']*\\[^"']*)["']/g;
|
|
1331
|
-
htmlContent = htmlContent.replace(regex, (_, p1, p2) => {
|
|
1332
|
-
const correctedPath = p2.replace(/\\/g, '/');
|
|
1333
|
-
return `${p1}="${correctedPath}"`;
|
|
1334
|
-
});
|
|
1335
|
-
const cssUrlRegex = /url\(["']?([^"'\)\\]*\\[^"'\)]*)["']?\)/g;
|
|
1336
|
-
return htmlContent.replace(cssUrlRegex, (_, p1) => {
|
|
1337
|
-
const correctedPath = p1.replace(/\\/g, '/');
|
|
1338
|
-
return `url(${correctedPath})`;
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
class Component {
|
|
1342
|
-
#Link = getLink();
|
|
1343
|
-
#dir = '';
|
|
1344
|
-
constructor() {
|
|
1345
|
-
this.#dir = join(process.cwd(), '.html');
|
|
1346
|
-
mkdirSync(join(this.#dir, 'css'), {
|
|
1347
|
-
recursive: true
|
|
1348
|
-
});
|
|
1349
|
-
mkdirSync(join(this.#dir, 'img'), {
|
|
1350
|
-
recursive: true
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
#rewriteFiles(options) {
|
|
1354
|
-
const callback = (_, p1, p2) => {
|
|
1355
|
-
let p0 = p1 || p2;
|
|
1356
|
-
const resourcePath = `@${p0}`;
|
|
1357
|
-
for (const key in options.file_paths) {
|
|
1358
|
-
const E = new RegExp(key, 'g');
|
|
1359
|
-
p0 = resourcePath.replace(E, options.file_paths[key]);
|
|
1360
|
-
if (options?.server === true) {
|
|
1361
|
-
p0 = this.replaceServerPaths(p0);
|
|
1362
|
-
}
|
|
1363
|
-
else {
|
|
1364
|
-
p0 = this.replacePaths(p0);
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
return `url(${p0})`;
|
|
1368
|
-
};
|
|
1369
|
-
for (const url of options.html_files) {
|
|
1370
|
-
if (/(.css|.less|.sass)$/) {
|
|
1371
|
-
try {
|
|
1372
|
-
const data = readFileSync(url, 'utf-8').replace(/url\("@([^"]*)"\)|url\('@([^']*)'\)/g, callback);
|
|
1373
|
-
const str = createHash('md5')
|
|
1374
|
-
.update(`${url}:${data.substring(0, 12)}`)
|
|
1375
|
-
.digest('hex');
|
|
1376
|
-
const dir = join(this.#dir, 'css', `${str}.${basename(url)}`);
|
|
1377
|
-
writeFileSync(dir, this.replacePaths(data), 'utf-8');
|
|
1378
|
-
options.html_head = `<link rel="stylesheet" href="${dir}" />${options?.html_head ?? ''}`;
|
|
1379
|
-
}
|
|
1380
|
-
catch (err) {
|
|
1381
|
-
console.warn(err);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
return options;
|
|
1386
|
-
}
|
|
1387
|
-
#compile(options) {
|
|
1388
|
-
if (options?.file_paths &&
|
|
1389
|
-
options?.html_files &&
|
|
1390
|
-
Array.isArray(options.html_files)) {
|
|
1391
|
-
options = this.#rewriteFiles(options);
|
|
1392
|
-
}
|
|
1393
|
-
if (options.body_component) {
|
|
1394
|
-
const str = renderToString(options.body_component);
|
|
1395
|
-
options.html_body = `${str}${options.html_body}`;
|
|
1396
|
-
}
|
|
1397
|
-
if (options.head_component) {
|
|
1398
|
-
const str = renderToString(options.head_component);
|
|
1399
|
-
options.html_head = `${str}${options.html_head}`;
|
|
1400
|
-
}
|
|
1401
|
-
const DOCTYPE = '<!DOCTYPE html>';
|
|
1402
|
-
const head = `<head>${this.#Link}${options?.html_head ?? ''}</head>`;
|
|
1403
|
-
const body = `<body>${options?.html_body ?? ''}</body>`;
|
|
1404
|
-
const html = `${DOCTYPE}<html>${head}${body}</html>`;
|
|
1405
|
-
if (typeof options?.file_create == 'boolean' &&
|
|
1406
|
-
options?.file_create == false) {
|
|
1407
|
-
if (options.server === true)
|
|
1408
|
-
return this.replaceServerPaths(html);
|
|
1409
|
-
return this.replacePaths(html);
|
|
1410
|
-
}
|
|
1411
|
-
const dir = join(this.#dir, options?.join_dir ?? '');
|
|
1412
|
-
mkdirSync(dir, { recursive: true });
|
|
1413
|
-
const address = join(dir, options?.html_name ?? 'hello.html');
|
|
1414
|
-
writeFileSync(address, options.server === true
|
|
1415
|
-
? this.replaceServerPaths(html)
|
|
1416
|
-
: this.replacePaths(html));
|
|
1417
|
-
return address;
|
|
1418
|
-
}
|
|
1419
|
-
create(element, options) {
|
|
1420
|
-
const str = renderToString(element);
|
|
1421
|
-
return this.#compile({
|
|
1422
|
-
...options,
|
|
1423
|
-
html_body: `${str ?? ''}${options?.html_body ?? ''}`
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
replacePaths(htmlContent) {
|
|
1427
|
-
const regex = /(src|href|url)\s*=\s*["']([^"']*\\[^"']*)["']/g;
|
|
1428
|
-
htmlContent = htmlContent.replace(regex, (_, p1, p2) => {
|
|
1429
|
-
const correctedPath = p2.replace(/\\/g, '/');
|
|
1430
|
-
return `${p1}="${correctedPath}"`;
|
|
1431
|
-
});
|
|
1432
|
-
const cssUrlRegex = /url\(["']?([^"'\)\\]*\\[^"'\)]*)["']?\)/g;
|
|
1433
|
-
return htmlContent.replace(cssUrlRegex, (_, p1) => {
|
|
1434
|
-
const correctedPath = p1.replace(/\\/g, '/');
|
|
1435
|
-
return `url(${correctedPath})`;
|
|
1436
|
-
});
|
|
1437
|
-
}
|
|
1438
|
-
replaceServerPaths = (htmlContent) => {
|
|
1439
|
-
return this.replacePaths(htmlContent.replace(new RegExp(process.cwd().replace(/\\/g, '\\\\'), 'g'), '/file'));
|
|
1440
|
-
};
|
|
1441
|
-
get render() {
|
|
1442
|
-
return renderToString;
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
const now = () => `?t=${Date.now()}`;
|
|
1447
|
-
const createDynamicComponent = (basePath) => {
|
|
1448
|
-
return (path) => import(new URL(`${path}${process.env.NODE_ENV == 'production' ? '' : now()}`, basePath).href);
|
|
1449
|
-
};
|
|
1450
|
-
|
|
1451
|
-
class Picture {
|
|
1452
|
-
Pup = null;
|
|
1453
|
-
Com = null;
|
|
1454
|
-
constructor() {
|
|
1455
|
-
this.Com = new Component();
|
|
1456
|
-
this.Pup = new Puppeteer();
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
1126
|
class Messages {
|
|
1461
1127
|
#count = 0;
|
|
1462
1128
|
#priority = 999;
|
|
@@ -1622,31 +1288,24 @@ class BaseConfig {
|
|
|
1622
1288
|
this.#data = val;
|
|
1623
1289
|
}
|
|
1624
1290
|
set(key, val) {
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
this.#data[key]
|
|
1628
|
-
|
|
1629
|
-
}
|
|
1630
|
-
else {
|
|
1631
|
-
for (const item in val) {
|
|
1632
|
-
if (this.#data[key]) {
|
|
1633
|
-
if (Object.prototype.hasOwnProperty.call(this.#data[key], item)) {
|
|
1634
|
-
this.#data[key][item] = val[item];
|
|
1635
|
-
}
|
|
1636
|
-
else {
|
|
1637
|
-
try {
|
|
1638
|
-
this.#data[key] = val[item];
|
|
1639
|
-
loger.info('KEY secess');
|
|
1640
|
-
}
|
|
1641
|
-
catch {
|
|
1642
|
-
loger.info('KEY err');
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1291
|
+
for (const item in val) {
|
|
1292
|
+
if (this.#data[key]) {
|
|
1293
|
+
if (Object.prototype.hasOwnProperty.call(this.#data[key], item)) {
|
|
1294
|
+
this.#data[key][item] = val[item];
|
|
1645
1295
|
}
|
|
1646
1296
|
else {
|
|
1647
|
-
|
|
1297
|
+
try {
|
|
1298
|
+
this.#data[key] = val[item];
|
|
1299
|
+
loger.info('KEY secess');
|
|
1300
|
+
}
|
|
1301
|
+
catch {
|
|
1302
|
+
loger.info('KEY err');
|
|
1303
|
+
}
|
|
1648
1304
|
}
|
|
1649
1305
|
}
|
|
1306
|
+
else {
|
|
1307
|
+
this.#data[key] = val[item];
|
|
1308
|
+
}
|
|
1650
1309
|
}
|
|
1651
1310
|
return this;
|
|
1652
1311
|
}
|
|
@@ -1660,7 +1319,6 @@ const ABotConfig = new BaseConfig({
|
|
|
1660
1319
|
kook: defineKOOK,
|
|
1661
1320
|
qq: defineQQ,
|
|
1662
1321
|
ntqq: defineNtqq,
|
|
1663
|
-
puppeteer: ALunchConfig.all(),
|
|
1664
1322
|
discord: defineDISCORD
|
|
1665
1323
|
});
|
|
1666
1324
|
|
|
@@ -8971,11 +8629,6 @@ var RebotMap = /*#__PURE__*/Object.freeze({
|
|
|
8971
8629
|
function createBot(Options, login) {
|
|
8972
8630
|
if (login)
|
|
8973
8631
|
Options.login = login;
|
|
8974
|
-
if (Options?.puppeteer) {
|
|
8975
|
-
for (const item in Options.puppeteer) {
|
|
8976
|
-
ALunchConfig.set(item, Options.puppeteer[item]);
|
|
8977
|
-
}
|
|
8978
|
-
}
|
|
8979
8632
|
if (Options?.imageStorage) {
|
|
8980
8633
|
DrawingBed.set('func', Options.imageStorage);
|
|
8981
8634
|
DrawingBed.set('state', true);
|
|
@@ -9120,4 +8773,4 @@ function createBot(Options, login) {
|
|
|
9120
8773
|
Promise.all(promises).catch(loger.error);
|
|
9121
8774
|
}
|
|
9122
8775
|
|
|
9123
|
-
export { ABodyParser, ABotConfig, ABuffer, AControllers, ACors, AKoa, ALoginOptions,
|
|
8776
|
+
export { ABodyParser, ABotConfig, ABuffer, AControllers, ACors, AKoa, ALoginOptions, AObserver, APPS, APlugin, ARouter, Alemon, App, AppLoadConfig, AppServerConfig, BaseBotMessage, BaseConfig$1 as BaseConfig, ClientDISOCRD, ClientFile, ClientKOOK, ClientNTQQ, ClientQQ, Controllers, Counter, DrawingBed, Email, EventEnum, Events, FileConfig, IP, Messages, Observer, TypingEnum, analysis, analysisRegex, createApp, createBot, createPicFrom, createSubApp, defineConfig, getAppPath, hash, importPath, loger, plugin, readScript };
|
package/package.json
CHANGED
|
@@ -1,99 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "alemonjs",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "啊柠檬脚本",
|
|
5
|
-
"author": "ningmengchongshui",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "rollup --config rollup.config.js",
|
|
11
|
-
"format": "prettier --write .",
|
|
12
|
-
"check-format": "git diff --exit-code",
|
|
13
|
-
"prepare": "husky"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"axios": "^1.4.0",
|
|
17
|
-
"dotenv": "^16.4.1",
|
|
18
|
-
"file-type": "^18.5.0",
|
|
19
|
-
"form-data": "^4.0.0",
|
|
20
|
-
"image-size": "^1.0.2",
|
|
21
|
-
"koa": "^2.14.2",
|
|
22
|
-
"koa-bodyparser": "^4.4.1",
|
|
23
|
-
"koa-router": "^12.0.0",
|
|
24
|
-
"koa2-cors": "^2.0.6",
|
|
25
|
-
"lodash-es": "^4.17.21",
|
|
26
|
-
"lru-cache": "^10.2.0",
|
|
27
|
-
"memory-cache": "^0.2.0",
|
|
28
|
-
"mime-types": "^2.1.35",
|
|
29
|
-
"nodemailer": "^6.9.12",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"@types/
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
".
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"registry": "https://registry.npmjs.org"
|
|
89
|
-
},
|
|
90
|
-
"engines": {
|
|
91
|
-
"node": ">=16.14.0"
|
|
92
|
-
},
|
|
93
|
-
"bugs": "https://github.com/ningmengchongshui/alemonjs/issues",
|
|
94
|
-
"repository": {
|
|
95
|
-
"type": "git",
|
|
96
|
-
"url": "https://github.com/ningmengchongshui/alemonjs.git"
|
|
97
|
-
},
|
|
98
|
-
"homepage": "https://alemonjs.com/"
|
|
99
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "alemonjs",
|
|
3
|
+
"version": "1.3.2",
|
|
4
|
+
"description": "啊柠檬脚本",
|
|
5
|
+
"author": "ningmengchongshui",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "rollup --config rollup.config.js",
|
|
11
|
+
"format": "prettier --write .",
|
|
12
|
+
"check-format": "git diff --exit-code",
|
|
13
|
+
"prepare": "husky"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"axios": "^1.4.0",
|
|
17
|
+
"dotenv": "^16.4.1",
|
|
18
|
+
"file-type": "^18.5.0",
|
|
19
|
+
"form-data": "^4.0.0",
|
|
20
|
+
"image-size": "^1.0.2",
|
|
21
|
+
"koa": "^2.14.2",
|
|
22
|
+
"koa-bodyparser": "^4.4.1",
|
|
23
|
+
"koa-router": "^12.0.0",
|
|
24
|
+
"koa2-cors": "^2.0.6",
|
|
25
|
+
"lodash-es": "^4.17.21",
|
|
26
|
+
"lru-cache": "^10.2.0",
|
|
27
|
+
"memory-cache": "^0.2.0",
|
|
28
|
+
"mime-types": "^2.1.35",
|
|
29
|
+
"nodemailer": "^6.9.12",
|
|
30
|
+
"public-ip": "^6.0.1",
|
|
31
|
+
"qrcode": "^1.5.3",
|
|
32
|
+
"react": "^18.3.1",
|
|
33
|
+
"react-dom": "^18.3.1",
|
|
34
|
+
"ws": "^8.13.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
38
|
+
"@types/koa": "^2.13.11",
|
|
39
|
+
"@types/koa-bodyparser": "^4.3.12",
|
|
40
|
+
"@types/koa-router": "^7.4.7",
|
|
41
|
+
"@types/koa2-cors": "^2.0.5",
|
|
42
|
+
"@types/lodash-es": "^4.17.12",
|
|
43
|
+
"@types/memory-cache": "^0.2.5",
|
|
44
|
+
"@types/mime-types": "^2.1.4",
|
|
45
|
+
"@types/node": "^20.2.4",
|
|
46
|
+
"@types/node-schedule": "^2.1.2",
|
|
47
|
+
"@types/nodemailer": "^6.4.14",
|
|
48
|
+
"@types/progress": "^2.0.5",
|
|
49
|
+
"@types/qrcode": "^1.5.0",
|
|
50
|
+
"@types/react": "^18.3.3",
|
|
51
|
+
"@types/react-dom": "^18.3.0",
|
|
52
|
+
"@types/ws": "^8.5.5",
|
|
53
|
+
"husky": "^9.0.11",
|
|
54
|
+
"prettier": "^2.8.8",
|
|
55
|
+
"rollup": "^4.18.1",
|
|
56
|
+
"ts-node": "^10.9.2",
|
|
57
|
+
"tslib": "^2.6.3",
|
|
58
|
+
"typescript": "^5.5.3"
|
|
59
|
+
},
|
|
60
|
+
"types": "dist",
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"config"
|
|
64
|
+
],
|
|
65
|
+
"exports": {
|
|
66
|
+
".": {
|
|
67
|
+
"import": "./dist/index.js",
|
|
68
|
+
"types": "./dist/index.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./config/tsconfig.json": {
|
|
71
|
+
"import": "./config/tsconfig.json",
|
|
72
|
+
"require": "./config/tsconfig.json"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"registry": "https://registry.npmjs.org"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=16.14.0"
|
|
80
|
+
},
|
|
81
|
+
"bugs": "https://github.com/ningmengchongshui/alemonjs/issues",
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "https://github.com/ningmengchongshui/alemonjs.git"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://alemonjs.com/"
|
|
87
|
+
}
|
package/.puppeteerrc.cjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const { arch } = require('os')
|
|
2
|
-
const { existsSync, realpathSync } = require('fs')
|
|
3
|
-
const { execSync } = require('child_process')
|
|
4
|
-
const isArch = arch()
|
|
5
|
-
const platform = process.platform
|
|
6
|
-
const win32Edge = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
|
7
|
-
// Downloa
|
|
8
|
-
let skipDownload = false
|
|
9
|
-
// Path
|
|
10
|
-
let executablePath
|
|
11
|
-
if (process.platform == 'win32' && existsSync(win32Edge)) {
|
|
12
|
-
// win32 Edge
|
|
13
|
-
skipDownload = true
|
|
14
|
-
executablePath = win32Edge
|
|
15
|
-
} else if (platform == 'linux' || platform == 'android') {
|
|
16
|
-
// linux | android
|
|
17
|
-
const chromium = [
|
|
18
|
-
'whereis chrome-browser',
|
|
19
|
-
'whereis chrome',
|
|
20
|
-
'whereis chromium-browser',
|
|
21
|
-
'whereis chromium',
|
|
22
|
-
'whereis firefox'
|
|
23
|
-
]
|
|
24
|
-
// get path
|
|
25
|
-
for (const item of chromium) {
|
|
26
|
-
try {
|
|
27
|
-
const chromiumPath = execSync(item).toString().split(' ')[1]?.trim()
|
|
28
|
-
if (chromiumPath) {
|
|
29
|
-
skipDownload = true
|
|
30
|
-
executablePath = realpathSync(chromiumPath)
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
} catch (error) {
|
|
34
|
-
continue
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// not path
|
|
38
|
-
if (!skipDownload) {
|
|
39
|
-
/**
|
|
40
|
-
* search
|
|
41
|
-
*/
|
|
42
|
-
const arr = [
|
|
43
|
-
'/usr/bin/chromium',
|
|
44
|
-
'/snap/bin/chromium',
|
|
45
|
-
'/usr/bin/chromium-browser',
|
|
46
|
-
'/data/data/com.termux/files/usr/lib/chromium-browser'
|
|
47
|
-
]
|
|
48
|
-
for (const item of arr) {
|
|
49
|
-
if (existsSync(item)) {
|
|
50
|
-
skipDownload = true
|
|
51
|
-
executablePath = item
|
|
52
|
-
break
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// arm64/arrch64
|
|
57
|
-
if (isArch == 'arm64' || isArch == 'aarch64') {
|
|
58
|
-
skipDownload = true
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @type {import("puppeteer").Configuration}
|
|
63
|
-
*/
|
|
64
|
-
module.exports = {
|
|
65
|
-
skipDownload,
|
|
66
|
-
executablePath
|
|
67
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { renderToString } from 'react-dom/server';
|
|
3
|
-
export type ComponentCreateOpsionType = {
|
|
4
|
-
join_dir?: string;
|
|
5
|
-
html_name?: string;
|
|
6
|
-
file_create?: boolean;
|
|
7
|
-
head_component?: React.ReactNode;
|
|
8
|
-
body_component?: React.ReactNode;
|
|
9
|
-
html_head?: string;
|
|
10
|
-
html_body?: string;
|
|
11
|
-
html_files?: string[];
|
|
12
|
-
file_paths?: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
};
|
|
15
|
-
server?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare function PathsCss(htmlContent: any): any;
|
|
18
|
-
export declare class Component {
|
|
19
|
-
#private;
|
|
20
|
-
constructor();
|
|
21
|
-
create(element: React.ReactNode, options: ComponentCreateOpsionType): string;
|
|
22
|
-
replacePaths(htmlContent: string): string;
|
|
23
|
-
replaceServerPaths: (htmlContent: string) => string;
|
|
24
|
-
get render(): typeof renderToString;
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getLink: () => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createDynamicComponent: (basePath: string) => <T = any>(path: string) => Promise<T>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type PuppeteerLaunchOptions, type ScreenshotOptions, type PuppeteerLifeCycleEvent } from 'puppeteer';
|
|
2
|
-
import queryString from 'querystring';
|
|
3
|
-
import { BaseConfig } from '../config.js';
|
|
4
|
-
export interface ScreenshotFileOptions {
|
|
5
|
-
SOptions?: {
|
|
6
|
-
type: 'jpeg' | 'png' | 'webp';
|
|
7
|
-
quality: number;
|
|
8
|
-
};
|
|
9
|
-
tab?: string;
|
|
10
|
-
timeout?: number;
|
|
11
|
-
}
|
|
12
|
-
export interface ScreenshotUrlOptions {
|
|
13
|
-
url: string;
|
|
14
|
-
time?: number;
|
|
15
|
-
rand?: ScreenshotOptions;
|
|
16
|
-
params?: queryString.ParsedUrlQueryInput;
|
|
17
|
-
tab?: string;
|
|
18
|
-
timeout?: number;
|
|
19
|
-
cache?: boolean;
|
|
20
|
-
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
|
|
21
|
-
}
|
|
22
|
-
export declare const ALunchConfig: BaseConfig<PuppeteerLaunchOptions>;
|
|
23
|
-
export declare class Puppeteer {
|
|
24
|
-
#private;
|
|
25
|
-
setLaunch(val: PuppeteerLaunchOptions): this;
|
|
26
|
-
getLaunch(): PuppeteerLaunchOptions;
|
|
27
|
-
start(): Promise<boolean>;
|
|
28
|
-
isStart(): Promise<boolean>;
|
|
29
|
-
render(htmlPath: string | Buffer | URL, Options?: ScreenshotFileOptions): Promise<string | false | Buffer>;
|
|
30
|
-
toFile: (htmlPath: string | Buffer | URL, Options?: ScreenshotFileOptions) => Promise<string | false | Buffer>;
|
|
31
|
-
toUrl(Options: ScreenshotUrlOptions): Promise<string | false | Buffer>;
|
|
32
|
-
}
|
package/dist/main.css
DELETED
package/dist/require.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/url.d.ts
DELETED
package/env.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// CSS modules
|
|
2
|
-
type CSSModuleClasses = { readonly [key: string]: string }
|
|
3
|
-
|
|
4
|
-
// CSS
|
|
5
|
-
declare module '*.css' {}
|
|
6
|
-
|
|
7
|
-
// images
|
|
8
|
-
declare module '*.apng' {
|
|
9
|
-
const src: string
|
|
10
|
-
export default src
|
|
11
|
-
}
|
|
12
|
-
declare module '*.png' {
|
|
13
|
-
const src: string
|
|
14
|
-
export default src
|
|
15
|
-
}
|
|
16
|
-
declare module '*.jpg' {
|
|
17
|
-
const src: string
|
|
18
|
-
export default src
|
|
19
|
-
}
|
|
20
|
-
declare module '*.jpeg' {
|
|
21
|
-
const src: string
|
|
22
|
-
export default src
|
|
23
|
-
}
|
|
24
|
-
declare module '*.jfif' {
|
|
25
|
-
const src: string
|
|
26
|
-
export default src
|
|
27
|
-
}
|
|
28
|
-
declare module '*.pjpeg' {
|
|
29
|
-
const src: string
|
|
30
|
-
export default src
|
|
31
|
-
}
|
|
32
|
-
declare module '*.pjp' {
|
|
33
|
-
const src: string
|
|
34
|
-
export default src
|
|
35
|
-
}
|
|
36
|
-
declare module '*.gif' {
|
|
37
|
-
const src: string
|
|
38
|
-
export default src
|
|
39
|
-
}
|
|
40
|
-
declare module '*.svg' {
|
|
41
|
-
const src: string
|
|
42
|
-
export default src
|
|
43
|
-
}
|
|
44
|
-
declare module '*.ico' {
|
|
45
|
-
const src: string
|
|
46
|
-
export default src
|
|
47
|
-
}
|
|
48
|
-
declare module '*.webp' {
|
|
49
|
-
const src: string
|
|
50
|
-
export default src
|
|
51
|
-
}
|
|
52
|
-
declare module '*.avif' {
|
|
53
|
-
const src: string
|
|
54
|
-
export default src
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// media
|
|
58
|
-
declare module '*.mp4' {
|
|
59
|
-
const src: string
|
|
60
|
-
export default src
|
|
61
|
-
}
|
|
62
|
-
declare module '*.webm' {
|
|
63
|
-
const src: string
|
|
64
|
-
export default src
|
|
65
|
-
}
|
|
66
|
-
declare module '*.ogg' {
|
|
67
|
-
const src: string
|
|
68
|
-
export default src
|
|
69
|
-
}
|
|
70
|
-
declare module '*.mp3' {
|
|
71
|
-
const src: string
|
|
72
|
-
export default src
|
|
73
|
-
}
|
|
74
|
-
declare module '*.wav' {
|
|
75
|
-
const src: string
|
|
76
|
-
export default src
|
|
77
|
-
}
|
|
78
|
-
declare module '*.flac' {
|
|
79
|
-
const src: string
|
|
80
|
-
export default src
|
|
81
|
-
}
|
|
82
|
-
declare module '*.aac' {
|
|
83
|
-
const src: string
|
|
84
|
-
export default src
|
|
85
|
-
}
|
|
86
|
-
declare module '*.opus' {
|
|
87
|
-
const src: string
|
|
88
|
-
export default src
|
|
89
|
-
}
|
|
90
|
-
declare module '*.mov' {
|
|
91
|
-
const src: string
|
|
92
|
-
export default src
|
|
93
|
-
}
|
|
94
|
-
declare module '*.m4a' {
|
|
95
|
-
const src: string
|
|
96
|
-
export default src
|
|
97
|
-
}
|
|
98
|
-
declare module '*.vtt' {
|
|
99
|
-
const src: string
|
|
100
|
-
export default src
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// fonts
|
|
104
|
-
declare module '*.woff' {
|
|
105
|
-
const src: string
|
|
106
|
-
export default src
|
|
107
|
-
}
|
|
108
|
-
declare module '*.woff2' {
|
|
109
|
-
const src: string
|
|
110
|
-
export default src
|
|
111
|
-
}
|
|
112
|
-
declare module '*.eot' {
|
|
113
|
-
const src: string
|
|
114
|
-
export default src
|
|
115
|
-
}
|
|
116
|
-
declare module '*.ttf' {
|
|
117
|
-
const src: string
|
|
118
|
-
export default src
|
|
119
|
-
}
|
|
120
|
-
declare module '*.otf' {
|
|
121
|
-
const src: string
|
|
122
|
-
export default src
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// file
|
|
126
|
-
declare module '*.md' {
|
|
127
|
-
const src: string
|
|
128
|
-
export default src
|
|
129
|
-
}
|