@karinjs/plugin-puppeteer 1.0.18 → 1.0.20
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/dist/chunk-WMPJFMK4.js +144 -0
- package/dist/index.js +71 -1
- package/dist/web.config.js +180 -2
- package/package.json +1 -1
- package/dist/chunk-YXMPHCN4.js +0 -2
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { karin } from 'node-karin';
|
|
4
|
+
import { basePath } from 'node-karin/root';
|
|
5
|
+
|
|
6
|
+
// package.json
|
|
7
|
+
var package_default = {
|
|
8
|
+
name: "@karinjs/plugin-puppeteer",
|
|
9
|
+
version: "1.0.20",
|
|
10
|
+
description: "karin\u7684 puppeteer\u622A\u56FE\u3001\u6E32\u67D3\u63D2\u4EF6",
|
|
11
|
+
keywords: [
|
|
12
|
+
"karin",
|
|
13
|
+
"node-karin",
|
|
14
|
+
"karin-plugin",
|
|
15
|
+
"puppeteer",
|
|
16
|
+
"browser",
|
|
17
|
+
"headless"
|
|
18
|
+
],
|
|
19
|
+
license: "MIT",
|
|
20
|
+
author: "sj817",
|
|
21
|
+
type: "module",
|
|
22
|
+
main: "dist/index.js",
|
|
23
|
+
types: "dist/index.d.ts",
|
|
24
|
+
files: [
|
|
25
|
+
"dist",
|
|
26
|
+
"!LICENSE",
|
|
27
|
+
"!README.md"
|
|
28
|
+
],
|
|
29
|
+
scripts: {
|
|
30
|
+
build: "tsc && tsup",
|
|
31
|
+
dev: "tsx src/index.ts",
|
|
32
|
+
"dev:test": "node dist/index.js",
|
|
33
|
+
pub: "pnpm publish --access public",
|
|
34
|
+
rm: `node -e "require('fs').rmSync('dist', { recursive: true, force: true })"`,
|
|
35
|
+
sync: 'curl -X PUT "https://registry-direct.npmmirror.com/-/package/@karinjs/plugin-puppeteer/syncs"'
|
|
36
|
+
},
|
|
37
|
+
dependencies: {
|
|
38
|
+
"@karinjs/puppeteer": "workspace:*"
|
|
39
|
+
},
|
|
40
|
+
devDependencies: {
|
|
41
|
+
"@karinjs/puppeteer-types": "workspace:*",
|
|
42
|
+
"node-karin": "^1.7.12"
|
|
43
|
+
},
|
|
44
|
+
karin: {
|
|
45
|
+
main: "src/index.ts",
|
|
46
|
+
apps: [],
|
|
47
|
+
web: "dist/web.config.js",
|
|
48
|
+
"ts-web": "src/web.config.ts",
|
|
49
|
+
files: [
|
|
50
|
+
"config"
|
|
51
|
+
],
|
|
52
|
+
env: [
|
|
53
|
+
{
|
|
54
|
+
key: "PUPPETEER_CACHE_DIR",
|
|
55
|
+
value: "",
|
|
56
|
+
comment: "Puppeteer\u7F13\u5B58\u7684\u9ED8\u8BA4\u6839\u76EE\u5F55"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "PUPPETEER_CACHE_VERSION",
|
|
60
|
+
value: "",
|
|
61
|
+
comment: "\u8BB0\u5F55puppeteer\u4E0B\u8F7D\u8FC7\u7684\u6D4F\u89C8\u5668\u4FE1\u606F"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "PUPPETEER_CHROME_HEADLESS_SHELL_VERSION",
|
|
65
|
+
value: "",
|
|
66
|
+
comment: "Puppeteer\u4E0B\u8F7D\u6D4F\u89C8\u5668\u7684\u7248\u672C"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "PUPPETEER_EXECUTABLE_PATH",
|
|
70
|
+
value: "",
|
|
71
|
+
comment: "Puppeteer\u53EF\u6267\u884C\u6587\u4EF6\u8DEF\u5F84 \u914D\u7F6E\u540E\u5C06\u4F7F\u7528\u6B64\u8DEF\u5F84\u7684\u6D4F\u89C8\u5668"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: "PUPPETEER_CHROME_HEADLESS_SHELL_DOWNLOAD_BASE_URL",
|
|
75
|
+
value: "",
|
|
76
|
+
comment: "Puppeteer\u6D4F\u89C8\u5668host\u5730\u5740"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
timestamp: "2025-10-01T00:47:22.222Z"
|
|
81
|
+
};
|
|
82
|
+
var HMR_KEY = "karin-plugin-puppeteer-hmr";
|
|
83
|
+
var defaultConfig = {
|
|
84
|
+
downloadBrowser: "chrome",
|
|
85
|
+
protocol: "cdp",
|
|
86
|
+
headless: true,
|
|
87
|
+
debug: false,
|
|
88
|
+
maxPages: 10,
|
|
89
|
+
idleTime: 500,
|
|
90
|
+
hmr: false,
|
|
91
|
+
executablePath: "",
|
|
92
|
+
pipe: false,
|
|
93
|
+
userDataDir: "",
|
|
94
|
+
args: [
|
|
95
|
+
"--window-size=800,600",
|
|
96
|
+
// 设置窗口大小
|
|
97
|
+
"--disable-gpu",
|
|
98
|
+
// 禁用 GPU 硬件加速
|
|
99
|
+
"--no-sandbox",
|
|
100
|
+
// 关闭 Chrome 的沙盒模式
|
|
101
|
+
"--disable-setuid-sandbox",
|
|
102
|
+
// 进一步禁用 setuid 沙盒机制,通常和 --no-sandbox 配合使用,避免权限问题
|
|
103
|
+
"--no-zygote",
|
|
104
|
+
// 关闭 Chrome 的 zygote 进程,减少进程开销,优化资源使用
|
|
105
|
+
"--disable-extensions",
|
|
106
|
+
// 禁用扩展
|
|
107
|
+
"--disable-dev-shm-usage",
|
|
108
|
+
// 禁用 /dev/shm(共享内存)用作临时存储,改用磁盘存储
|
|
109
|
+
"--disable-background-networking",
|
|
110
|
+
// 禁用后台网络请求
|
|
111
|
+
"--disable-sync",
|
|
112
|
+
// 禁用 Chrome 的同步功能
|
|
113
|
+
"--disable-crash-reporter",
|
|
114
|
+
// 禁用崩溃报告
|
|
115
|
+
"--disable-translate",
|
|
116
|
+
// 禁用翻译
|
|
117
|
+
"--disable-notifications",
|
|
118
|
+
// 禁用通知
|
|
119
|
+
"--disable-device-discovery-notifications",
|
|
120
|
+
// 禁用设备发现通知
|
|
121
|
+
"--disable-accelerated-2d-canvas"
|
|
122
|
+
// 禁用 2D 画布的硬件加速
|
|
123
|
+
]
|
|
124
|
+
};
|
|
125
|
+
var pluginName = package_default.name.replace(/\//g, "-");
|
|
126
|
+
var pluginVersion = package_default.version;
|
|
127
|
+
var configPath = path.resolve(basePath, pluginName, "config", "config.json");
|
|
128
|
+
var init = () => {
|
|
129
|
+
if (!fs.existsSync(configPath)) {
|
|
130
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
131
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var getConfig = () => {
|
|
135
|
+
const data = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
136
|
+
return { ...defaultConfig, ...data };
|
|
137
|
+
};
|
|
138
|
+
var saveConfig = (config) => {
|
|
139
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
140
|
+
karin.emit(HMR_KEY, config);
|
|
141
|
+
};
|
|
142
|
+
init();
|
|
143
|
+
|
|
144
|
+
export { HMR_KEY, getConfig, package_default, pluginName, pluginVersion, saveConfig };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfig, HMR_KEY, pluginVersion, pluginName } from './chunk-WMPJFMK4.js';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { launch } from '@karinjs/puppeteer';
|
|
4
|
+
import { karin, registerRender, renderTpl, logger } from 'node-karin';
|
|
5
|
+
|
|
6
|
+
var formatBytes = (bytes) => {
|
|
7
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
8
|
+
if (!bytes || bytes < 0) return "0 B";
|
|
9
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
10
|
+
const value = bytes / Math.pow(1024, i);
|
|
11
|
+
return `${i === 0 ? Math.round(value) : value.toFixed(2)} ${units[i]}`;
|
|
12
|
+
};
|
|
13
|
+
var getScreenshotByteSize = (payload, encoding) => {
|
|
14
|
+
try {
|
|
15
|
+
if (payload == null) return void 0;
|
|
16
|
+
const enc = (encoding || "").toLowerCase();
|
|
17
|
+
if (Array.isArray(payload)) {
|
|
18
|
+
let total = 0;
|
|
19
|
+
for (const item of payload) {
|
|
20
|
+
const size = getScreenshotByteSize(item, enc);
|
|
21
|
+
if (typeof size === "number") total += size;
|
|
22
|
+
}
|
|
23
|
+
return total;
|
|
24
|
+
}
|
|
25
|
+
if (typeof payload === "string") {
|
|
26
|
+
return enc === "base64" ? Buffer.from(payload, "base64").length : Buffer.byteLength(payload);
|
|
27
|
+
}
|
|
28
|
+
if (Buffer.isBuffer(payload)) return payload.length;
|
|
29
|
+
if (payload instanceof Uint8Array) return payload.byteLength;
|
|
30
|
+
if (payload instanceof ArrayBuffer) return payload.byteLength;
|
|
31
|
+
const anyPayload = payload;
|
|
32
|
+
if (typeof anyPayload.data === "string") {
|
|
33
|
+
return enc === "base64" ? Buffer.from(anyPayload.data, "base64").length : Buffer.byteLength(anyPayload.data);
|
|
34
|
+
}
|
|
35
|
+
if (Buffer.isBuffer(anyPayload.buffer)) return anyPayload.buffer.length;
|
|
36
|
+
if (anyPayload.buffer instanceof ArrayBuffer) return anyPayload.buffer.byteLength;
|
|
37
|
+
if (typeof anyPayload.byteLength === "number") return anyPayload.byteLength;
|
|
38
|
+
if (typeof anyPayload.length === "number") return anyPayload.length;
|
|
39
|
+
return void 0;
|
|
40
|
+
} catch {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var main = async () => {
|
|
45
|
+
const config = getConfig();
|
|
46
|
+
const browser = await launch(config);
|
|
47
|
+
karin.on(HMR_KEY, (cfg) => browser.hmrConfig(cfg));
|
|
48
|
+
const name = "@karinjs/plugin-puppeteer";
|
|
49
|
+
registerRender(name, async (options) => {
|
|
50
|
+
options.encoding = "base64";
|
|
51
|
+
const data = renderTpl(options);
|
|
52
|
+
data.encoding = options.encoding;
|
|
53
|
+
const time = Date.now();
|
|
54
|
+
const result = await browser.screenshot(data);
|
|
55
|
+
const fileName = typeof data?.file === "string" ? path.basename(data.file) : "unknown";
|
|
56
|
+
if (!result.status) {
|
|
57
|
+
logger.info(
|
|
58
|
+
`[${name}][${fileName}] \u622A\u56FE\u5931\u8D25 \u8017\u65F6: ${logger.green(Date.now() - time + "")} ms`
|
|
59
|
+
);
|
|
60
|
+
throw new Error(result.data.message || "\u622A\u56FE\u5931\u8D25", { cause: result.data });
|
|
61
|
+
}
|
|
62
|
+
const sizeBytes = getScreenshotByteSize(result.data, options.encoding);
|
|
63
|
+
const sizeStr = sizeBytes != null ? `\u5927\u5C0F: ${logger.green(formatBytes(sizeBytes))} ` : "";
|
|
64
|
+
logger.info(
|
|
65
|
+
`[${name}][${fileName}] \u622A\u56FE\u5B8C\u6210 ${sizeStr}\u8017\u65F6: ${logger.green(Date.now() - time + "")} ms`
|
|
66
|
+
);
|
|
67
|
+
return result.data;
|
|
68
|
+
});
|
|
69
|
+
logger.info(`${logger.violet(`[\u63D2\u4EF6:${pluginVersion}]`)} ${logger.green(pluginName)} \u521D\u59CB\u5316\u5B8C\u6210~`);
|
|
70
|
+
};
|
|
71
|
+
main();
|
package/dist/web.config.js
CHANGED
|
@@ -1,2 +1,180 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { package_default, saveConfig, getConfig } from './chunk-WMPJFMK4.js';
|
|
2
|
+
import { components } from 'node-karin';
|
|
3
|
+
|
|
4
|
+
var webConfig = {
|
|
5
|
+
info: {
|
|
6
|
+
id: package_default.name,
|
|
7
|
+
name: "\u6E32\u67D3\u5668\u63D2\u4EF6",
|
|
8
|
+
version: package_default.version,
|
|
9
|
+
description: package_default.description,
|
|
10
|
+
author: [
|
|
11
|
+
{
|
|
12
|
+
name: "sj817",
|
|
13
|
+
home: "https://sj817.com",
|
|
14
|
+
avatar: "https://github.com/sj817.png"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
icon: {
|
|
18
|
+
name: "search",
|
|
19
|
+
size: 24,
|
|
20
|
+
color: "#0078d4"
|
|
21
|
+
// 浅蓝色
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
/** 动态渲染的组件 */
|
|
25
|
+
components: () => {
|
|
26
|
+
const config = getConfig();
|
|
27
|
+
return [
|
|
28
|
+
components.radio.group("downloadBrowser", {
|
|
29
|
+
label: "\u4E0B\u8F7D\u7684\u6D4F\u89C8\u5668",
|
|
30
|
+
orientation: "horizontal",
|
|
31
|
+
description: "\u6CA1\u6709\u6D4F\u89C8\u5668\u65F6\uFF0C\u4E0B\u8F7D\u7684\u6D4F\u89C8\u5668\u7248\u672C\uFF0Clinux\u63A8\u8350 chrome-headless-shell",
|
|
32
|
+
defaultValue: config.downloadBrowser,
|
|
33
|
+
radio: [
|
|
34
|
+
components.radio.create("chrome", {
|
|
35
|
+
label: "chrome",
|
|
36
|
+
value: "chrome"
|
|
37
|
+
}),
|
|
38
|
+
components.radio.create("chrome-headless-shell", {
|
|
39
|
+
label: "chrome-headless-shell",
|
|
40
|
+
value: "chrome-headless-shell"
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
}),
|
|
44
|
+
components.radio.group("protocol", {
|
|
45
|
+
label: "protocol",
|
|
46
|
+
orientation: "horizontal",
|
|
47
|
+
description: "\u8FDE\u63A5\u5230\u6D4F\u89C8\u5668\u7684\u534F\u8BAE",
|
|
48
|
+
defaultValue: config.protocol || "cdp",
|
|
49
|
+
radio: [
|
|
50
|
+
components.radio.create("cdp", {
|
|
51
|
+
label: "cdp",
|
|
52
|
+
value: "cdp",
|
|
53
|
+
description: "chrome devtools protocol\uFF0C\u6027\u80FD\u4E00\u822C\uFF0C\u4F46\u662F\u7A33\u5B9A"
|
|
54
|
+
}),
|
|
55
|
+
components.radio.create("webDriverBiDi", {
|
|
56
|
+
label: "webDriverBiDi",
|
|
57
|
+
value: "webDriverBiDi",
|
|
58
|
+
description: "webDriverBiDi\uFF0C\u6027\u80FD\u66F4\u597D\uFF0C\u901F\u5EA6\u66F4\u5FEB\uFF0C\u76EE\u524D\u5904\u4E8E\u5F00\u53D1\u4E2D\uFF0C\u8C28\u614E\u4F7F\u7528"
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
}),
|
|
62
|
+
components.divider.create("divider1"),
|
|
63
|
+
components.radio.group("headless", {
|
|
64
|
+
label: "\u65E0\u5934\u6A21\u5F0F",
|
|
65
|
+
description: "\u662F\u5426\u65E0\u5934\u6A21\u5F0F\uFF0C\u65E0\u5934\u6A21\u5F0F\u4E0B\uFF0C\u6D4F\u89C8\u5668\u5C06\u540E\u53F0\u8FD0\u884C\uFF0C\u4E0D\u4F1A\u6253\u5F00\u6D4F\u89C8\u5668\u7A97\u53E3",
|
|
66
|
+
defaultValue: String(config.headless),
|
|
67
|
+
radio: [
|
|
68
|
+
components.radio.create("headless:true", {
|
|
69
|
+
label: "true",
|
|
70
|
+
value: "true",
|
|
71
|
+
description: "\u6253\u5F00\u65E0\u5934\u6A21\u5F0F"
|
|
72
|
+
}),
|
|
73
|
+
components.radio.create("headless:false", {
|
|
74
|
+
label: "false",
|
|
75
|
+
value: "false",
|
|
76
|
+
description: "\u5173\u95ED\u65E0\u5934\u6A21\u5F0F"
|
|
77
|
+
}),
|
|
78
|
+
components.radio.create("shell", {
|
|
79
|
+
label: "shell",
|
|
80
|
+
value: "shell",
|
|
81
|
+
description: "\u4F7F\u7528chrome-headless-shell"
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
}),
|
|
85
|
+
components.divider.create("divider3"),
|
|
86
|
+
components.switch.create("debug", {
|
|
87
|
+
label: "debug\u6A21\u5F0F",
|
|
88
|
+
description: "\u662F\u5426\u5F00\u542Fdebug\u6A21\u5F0F\uFF0Cdebug\u6A21\u5F0F\u4E0B\uFF0C\u6D4F\u89C8\u5668\u5C06\u524D\u53F0\u8FD0\u884C\uFF0C\u5E76\u4E14\u6253\u5F00\u9875\u9762\u540E\u4E0D\u4F1A\u5173\u95ED\uFF0C\u4EC5\u5728windows\u4E0B\u6709\u6548",
|
|
89
|
+
defaultSelected: config.debug,
|
|
90
|
+
color: "success"
|
|
91
|
+
}),
|
|
92
|
+
// hmr
|
|
93
|
+
components.switch.create("hmr", {
|
|
94
|
+
label: "\u70ED\u66F4\u65B0",
|
|
95
|
+
description: "\u662F\u5426\u5F00\u542F\u70ED\u66F4\u65B0\uFF0C\u5F00\u542F\u540E\uFF0C\u524D\u7AEF\u70B9\u51FB\u4FDD\u5B58\u540E\u4F1A\u5F3A\u5236\u5173\u95ED\u6240\u6709\u6B63\u5728\u8FDB\u884C\u7684\u622A\u56FE\u4EFB\u52A1\u5E76\u91CD\u8F7D\u914D\u7F6E",
|
|
96
|
+
defaultSelected: config.hmr,
|
|
97
|
+
color: "success"
|
|
98
|
+
}),
|
|
99
|
+
// pipe
|
|
100
|
+
components.switch.create("pipe", {
|
|
101
|
+
label: "\u7BA1\u9053\u6A21\u5F0F",
|
|
102
|
+
description: "\u662F\u5426\u5F00\u542F\u7BA1\u9053\u6A21\u5F0F\uFF0C\u5F00\u542F\u540E\uFF0C\u6D4F\u89C8\u5668\u5C06\u4F7F\u7528\u7BA1\u9053\u6A21\u5F0F\u8FD0\u884C",
|
|
103
|
+
defaultSelected: config.pipe,
|
|
104
|
+
color: "success"
|
|
105
|
+
}),
|
|
106
|
+
components.divider.create("divider2"),
|
|
107
|
+
// maxPages
|
|
108
|
+
components.input.number("maxPages", {
|
|
109
|
+
label: "\u6700\u5927\u6807\u7B7E\u9875",
|
|
110
|
+
description: "\u6700\u591A\u540C\u65F6\u6253\u5F00\u7684\u6807\u7B7E\u9875\u6570\u91CF\uFF0C\u8D85\u51FA\u540E\u5C06\u4F1A\u81EA\u52A8\u6392\u961F",
|
|
111
|
+
defaultValue: config.maxPages + "",
|
|
112
|
+
className: "inline-block p-2",
|
|
113
|
+
rules: [
|
|
114
|
+
{
|
|
115
|
+
min: 1,
|
|
116
|
+
max: 100,
|
|
117
|
+
error: "\u6700\u5927\u6807\u7B7E\u9875\u6570\u91CF\u5FC5\u987B\u57281-100\u4E4B\u95F4"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}),
|
|
121
|
+
// idleTime
|
|
122
|
+
components.input.number("idleTime", {
|
|
123
|
+
label: "\u7F51\u7EDC\u8BF7\u6C42\u7A7A\u95F2\u65F6\u95F4",
|
|
124
|
+
description: "\u7F51\u7EDC\u8BF7\u6C42\u7A7A\u95F2\u65F6\u95F4\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2",
|
|
125
|
+
defaultValue: config.idleTime + "",
|
|
126
|
+
className: "inline-block p-2",
|
|
127
|
+
rules: [
|
|
128
|
+
{
|
|
129
|
+
min: 1,
|
|
130
|
+
max: 999999,
|
|
131
|
+
error: "\u7F51\u7EDC\u8BF7\u6C42\u7A7A\u95F2\u65F6\u95F4\u5FC5\u987B\u57281-999999\u4E4B\u95F4"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}),
|
|
135
|
+
// executablePath
|
|
136
|
+
components.input.string("executablePath", {
|
|
137
|
+
label: "\u6D4F\u89C8\u5668\u53EF\u6267\u884C\u8DEF\u5F84",
|
|
138
|
+
description: "\u6D4F\u89C8\u5668\u53EF\u6267\u884C\u8DEF\u5F84\uFF0C\u5982\u679C\u4E3A\u7A7A\uFF0C\u5C06\u4F1A\u81EA\u52A8\u4E0B\u8F7D\u6D4F\u89C8\u5668",
|
|
139
|
+
defaultValue: config.executablePath,
|
|
140
|
+
isRequired: false,
|
|
141
|
+
className: "inline-block p-2"
|
|
142
|
+
}),
|
|
143
|
+
// userDataDir
|
|
144
|
+
components.input.string("userDataDir", {
|
|
145
|
+
label: "\u7528\u6237\u6570\u636E\u76EE\u5F55",
|
|
146
|
+
description: "\u7528\u6237\u6570\u636E\u76EE\u5F55\uFF0C\u5982\u679C\u4E3A\u7A7A\uFF0C\u5C06\u4F1A\u4F7F\u7528\u9ED8\u8BA4\u8DEF\u5F84",
|
|
147
|
+
defaultValue: config.userDataDir,
|
|
148
|
+
isRequired: false,
|
|
149
|
+
className: "inline-block p-2"
|
|
150
|
+
}),
|
|
151
|
+
// 分隔线
|
|
152
|
+
components.divider.create("divider4"),
|
|
153
|
+
// args
|
|
154
|
+
components.input.group("args", {
|
|
155
|
+
label: "\u542F\u52A8\u53C2\u6570",
|
|
156
|
+
description: "\u542F\u52A8\u53C2\u6570\uFF0C\u4E0D\u5141\u8BB8\u51FA\u73B0\u7A7A\u503C\uFF0C\u65E0\u7279\u6B8A\u9700\u6C42\u4E0D\u5EFA\u8BAE\u6539\u52A8",
|
|
157
|
+
template: components.input.string("args", {
|
|
158
|
+
label: "\u542F\u52A8\u53C2\u6570"
|
|
159
|
+
}),
|
|
160
|
+
data: config.args || []
|
|
161
|
+
})
|
|
162
|
+
];
|
|
163
|
+
},
|
|
164
|
+
/** 前端点击保存之后调用的方法 */
|
|
165
|
+
save: (config) => {
|
|
166
|
+
config = {
|
|
167
|
+
...config,
|
|
168
|
+
maxPages: Number(config.maxPages),
|
|
169
|
+
idleTime: Number(config.idleTime)
|
|
170
|
+
};
|
|
171
|
+
saveConfig(config);
|
|
172
|
+
return {
|
|
173
|
+
success: true,
|
|
174
|
+
message: "\u597D\u4E86\u54E6 \u03C6(>\u03C9<*)"
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var web_config_default = webConfig;
|
|
179
|
+
|
|
180
|
+
export { web_config_default as default };
|
package/package.json
CHANGED
package/dist/chunk-YXMPHCN4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import e from'node:fs';import t from'node:path';import {karin}from'node-karin';import {basePath}from'node-karin/root';var r={name:"@karinjs/plugin-puppeteer",version:"1.0.18",description:"karin\u7684 puppeteer\u622A\u56FE\u3001\u6E32\u67D3\u63D2\u4EF6",keywords:["karin","node-karin","karin-plugin","puppeteer","browser","headless"],license:"MIT",author:"sj817",type:"module",main:"dist/index.js",types:"dist/index.d.ts",files:["dist","!LICENSE","!README.md"],scripts:{build:"tsc && tsup",dev:"tsx src/index.ts","dev:test":"node dist/index.js",pub:"pnpm publish --access public",rm:`node -e "require('fs').rmSync('dist', { recursive: true, force: true })"`,sync:'curl -X PUT "https://registry-direct.npmmirror.com/-/package/@karinjs/plugin-puppeteer/syncs"'},dependencies:{"@karinjs/puppeteer":"workspace:*"},devDependencies:{"@karinjs/puppeteer-types":"workspace:*","node-karin":"^1.7.12"},karin:{main:"src/index.ts",apps:[],web:"dist/web.config.js","ts-web":"src/web.config.ts",files:["config"],env:[{key:"PUPPETEER_CACHE_DIR",value:"",comment:"Puppeteer\u7F13\u5B58\u7684\u9ED8\u8BA4\u6839\u76EE\u5F55"},{key:"PUPPETEER_CACHE_VERSION",value:"",comment:"\u8BB0\u5F55puppeteer\u4E0B\u8F7D\u8FC7\u7684\u6D4F\u89C8\u5668\u4FE1\u606F"},{key:"PUPPETEER_CHROME_HEADLESS_SHELL_VERSION",value:"",comment:"Puppeteer\u4E0B\u8F7D\u6D4F\u89C8\u5668\u7684\u7248\u672C"},{key:"PUPPETEER_EXECUTABLE_PATH",value:"",comment:"Puppeteer\u53EF\u6267\u884C\u6587\u4EF6\u8DEF\u5F84 \u914D\u7F6E\u540E\u5C06\u4F7F\u7528\u6B64\u8DEF\u5F84\u7684\u6D4F\u89C8\u5668"},{key:"PUPPETEER_CHROME_HEADLESS_SHELL_DOWNLOAD_BASE_URL",value:"",comment:"Puppeteer\u6D4F\u89C8\u5668host\u5730\u5740"}]},timestamp:"2025-10-01T00:47:22.222Z"};var c="karin-plugin-puppeteer-hmr",n={downloadBrowser:"chrome",protocol:"cdp",headless:true,debug:false,maxPages:10,idleTime:500,hmr:false,executablePath:"",pipe:false,userDataDir:"",args:["--window-size=800,600","--disable-gpu","--no-sandbox","--disable-setuid-sandbox","--no-zygote","--disable-extensions","--disable-dev-shm-usage","--disable-background-networking","--disable-sync","--disable-crash-reporter","--disable-translate","--disable-notifications","--disable-device-discovery-notifications","--disable-accelerated-2d-canvas"]},d=r.name.replace(/\//g,"-"),y=r.version,s=t.resolve(basePath,d,"config","config.json"),u=()=>{e.existsSync(s)||(e.mkdirSync(t.dirname(s),{recursive:true}),e.writeFileSync(s,JSON.stringify(n,null,2)));},h=()=>{let i=JSON.parse(e.readFileSync(s,"utf-8"));return {...n,...i}},v=i=>{e.writeFileSync(s,JSON.stringify(i,null,2)),karin.emit(c,i);};u();
|
|
2
|
-
export{r as a,c as b,d as c,y as d,h as e,v as f};
|