@tocha688/browser 1.0.3 → 1.0.4

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,240 +0,0 @@
1
- import type { Locator, Page } from "patchright-core";
2
- import HumanMouse from "../../human/mouse";
3
- import { isLocator } from "./utils";
4
- import { rWait } from "./wait";
5
- import { click } from "./click";
6
-
7
- export async function select(
8
- page: Page,
9
- mouse: HumanMouse,
10
- locator: Locator | string,
11
- value: Parameters<Locator["selectOption"]>[0],
12
- options?: Parameters<Locator["waitFor"]>[0] &
13
- Parameters<Locator["selectOption"]>[1] & {
14
- retries?: number;
15
- verify?: boolean;
16
- }
17
- ): Promise<void> {
18
- // 标准化locator
19
- if (typeof locator === "string") {
20
- locator = page.locator(locator);
21
- }
22
- if (!isLocator(locator)) {
23
- throw new Error("locator 类型错误");
24
- }
25
-
26
- const { retries = 3, verify = true, ...selectOptions } = options || {};
27
-
28
- // 等待元素可见和可用
29
- await locator.waitFor({ state: "visible", ...selectOptions });
30
- await locator.waitFor({ state: "attached", ...selectOptions });
31
-
32
- // 检查当前值是否已经是目标值
33
- try {
34
- const currentValue = await locator.inputValue();
35
- const targetValue =
36
- typeof value === "string"
37
- ? value
38
- : Array.isArray(value)
39
- ? value[0]?.toString()
40
- : value?.toString();
41
-
42
- if (currentValue === targetValue) {
43
- return; // 已经是目标值,无需操作
44
- }
45
- } catch (error) {
46
- // 如果获取当前值失败,继续执行选择操作
47
- console.warn(`获取当前选择值失败: ${error}`);
48
- }
49
-
50
- let attempt = 0;
51
- while (attempt < retries) {
52
- try {
53
- // 点击元素确保聚焦
54
- await click(page, mouse, locator, selectOptions);
55
- await rWait(50, 100);
56
-
57
- // 执行选择操作
58
- await locator.selectOption(value, selectOptions);
59
- await rWait(100, 200);
60
-
61
- // 验证选择结果
62
- if (verify) {
63
- const newValue = await locator.inputValue();
64
- const targetValue =
65
- typeof value === "string"
66
- ? value
67
- : Array.isArray(value)
68
- ? value[0]?.toString()
69
- : value?.toString();
70
-
71
- if (newValue !== targetValue) {
72
- throw new Error(
73
- `选择验证失败: 期望"${targetValue}", 实际"${newValue}"`
74
- );
75
- }
76
- }
77
-
78
- // 失焦
79
- await locator.blur();
80
- return; // 成功完成
81
- } catch (error) {
82
- attempt++;
83
- if (attempt >= retries) {
84
- throw new Error(`选择操作失败,已重试${retries}次: ${error}`);
85
- }
86
- // 重试前等待
87
- await rWait(200, 400);
88
- }
89
- }
90
- }
91
-
92
- export async function check(
93
- page: Page,
94
- mouse: HumanMouse,
95
- locator: Locator | string,
96
- options?: Parameters<Locator["waitFor"]>[0] & {
97
- force?: boolean;
98
- retries?: number;
99
- verify?: boolean;
100
- }
101
- ): Promise<void> {
102
- // 标准化locator
103
- if (typeof locator === "string") {
104
- locator = page.locator(locator);
105
- }
106
- if (!isLocator(locator)) {
107
- throw new Error("locator 类型错误");
108
- }
109
-
110
- const {
111
- force = false,
112
- retries = 3,
113
- verify = true,
114
- ...waitOptions
115
- } = options || {};
116
-
117
- // 等待元素可见和可用
118
- await locator.waitFor({ state: "visible", ...waitOptions });
119
- await locator.waitFor({ state: "attached", ...waitOptions });
120
-
121
- // 检查当前状态
122
- if (!force) {
123
- try {
124
- const isChecked = await locator.isChecked();
125
- if (isChecked) {
126
- return; // 已经勾选,无需操作
127
- }
128
- } catch (error) {
129
- // 如果检查状态失败,继续执行勾选操作
130
- console.warn(`检查勾选状态失败: ${error}`);
131
- }
132
- }
133
-
134
- let attempt = 0;
135
- while (attempt < retries) {
136
- try {
137
- // 点击元素确保聚焦
138
- await click(page, mouse, locator, waitOptions);
139
- await rWait(50, 100);
140
-
141
- // 执行勾选操作
142
- await locator.check({ force, ...waitOptions });
143
- await rWait(100, 200);
144
-
145
- // 验证勾选结果
146
- if (verify) {
147
- const isChecked = await locator.isChecked();
148
- if (!isChecked) {
149
- throw new Error("勾选验证失败: 元素未被成功勾选");
150
- }
151
- }
152
-
153
- // 失焦
154
- await locator.blur();
155
- return; // 成功完成
156
- } catch (error) {
157
- attempt++;
158
- if (attempt >= retries) {
159
- throw new Error(`勾选操作失败,已重试${retries}次: ${error}`);
160
- }
161
- // 重试前等待
162
- await rWait(200, 400);
163
- }
164
- }
165
- }
166
-
167
- export async function uncheck(
168
- page: Page,
169
- mouse: HumanMouse,
170
- locator: Locator | string,
171
- options?: Parameters<Locator["waitFor"]>[0] & {
172
- force?: boolean;
173
- retries?: number;
174
- verify?: boolean;
175
- }
176
- ): Promise<void> {
177
- // 标准化locator
178
- if (typeof locator === "string") {
179
- locator = page.locator(locator);
180
- }
181
- if (!isLocator(locator)) {
182
- throw new Error("locator 类型错误");
183
- }
184
-
185
- const {
186
- force = false,
187
- retries = 3,
188
- verify = true,
189
- ...waitOptions
190
- } = options || {};
191
-
192
- // 等待元素可见和可用
193
- await locator.waitFor({ state: "visible", ...waitOptions });
194
- await locator.waitFor({ state: "attached", ...waitOptions });
195
-
196
- // 检查当前状态
197
- if (!force) {
198
- try {
199
- const isChecked = await locator.isChecked();
200
- if (!isChecked) {
201
- return; // 已经未勾选,无需操作
202
- }
203
- } catch (error) {
204
- // 如果检查状态失败,继续执行取消勾选操作
205
- console.warn(`检查勾选状态失败: ${error}`);
206
- }
207
- }
208
-
209
- let attempt = 0;
210
- while (attempt < retries) {
211
- try {
212
- // 点击元素确保聚焦
213
- await click(page, mouse, locator, waitOptions);
214
- await rWait(50, 100);
215
-
216
- // 执行取消勾选操作
217
- await locator.uncheck({ force, ...waitOptions });
218
- await rWait(100, 200);
219
-
220
- // 验证取消勾选结果
221
- if (verify) {
222
- const isChecked = await locator.isChecked();
223
- if (isChecked) {
224
- throw new Error("取消勾选验证失败: 元素仍然被勾选");
225
- }
226
- }
227
-
228
- // 失焦
229
- await locator.blur();
230
- return; // 成功完成
231
- } catch (error) {
232
- attempt++;
233
- if (attempt >= retries) {
234
- throw new Error(`取消勾选操作失败,已重试${retries}次: ${error}`);
235
- }
236
- // 重试前等待
237
- await rWait(200, 400);
238
- }
239
- }
240
- }
@@ -1,63 +0,0 @@
1
- import type { Locator, Page } from "patchright-core";
2
-
3
- export type AutoPage = Page & {
4
- // We can't easily circular reference AutoHelper here if it's not exported yet,
5
- // but we can use `any` or interface merging if needed.
6
- // For now, let's keep it simple or import AutoHelper if possible.
7
- [key: string]: any;
8
- };
9
-
10
- export type AutoLocator = Locator & {
11
- _loc: Locator;
12
- input(
13
- text: string,
14
- options?: Parameters<Locator["waitFor"]>[0] & {
15
- clear?: boolean;
16
- delay?: { min: number; max: number };
17
- retries?: number;
18
- }
19
- ): Promise<void>;
20
- select(
21
- value: Parameters<Locator["selectOption"]>[0],
22
- options?: Parameters<Locator["waitFor"]>[0] &
23
- Parameters<Locator["selectOption"]>[1] & {
24
- retries?: number;
25
- verify?: boolean;
26
- }
27
- ): Promise<void>;
28
- check(
29
- options?: Parameters<Locator["waitFor"]>[0] & {
30
- force?: boolean;
31
- retries?: number;
32
- verify?: boolean;
33
- }
34
- ): Promise<void>;
35
- uncheck(
36
- options?: Parameters<Locator["waitFor"]>[0] & {
37
- force?: boolean;
38
- retries?: number;
39
- verify?: boolean;
40
- }
41
- ): Promise<void>;
42
- };
43
-
44
- export interface FrameInLocatorOptions {
45
- has?: Locator;
46
- hasNot?: Locator;
47
- hasNotText?: string | RegExp;
48
- hasText?: string | RegExp;
49
- }
50
-
51
- export interface WaitForIframeCompleteOptions {
52
- frameAttachedTimeout?: number;
53
- frameVisibleTimeout?: number;
54
- frameBodyTimeout?: number;
55
- frameInLocatorOptions?: FrameInLocatorOptions;
56
- waitForElementTimeout?: number;
57
- timeout?: number;
58
- }
59
-
60
- export interface MonitorOptions {
61
- interval?: number; // 轮询间隔 (ms),默认 1000ms
62
- debug?: boolean; // 是否开启调试日志
63
- }
@@ -1,36 +0,0 @@
1
-
2
- export function splitTextIntoChunks(text: string, chunkSize: number): string[] {
3
- const chunks: string[] = [];
4
- for (let i = 0; i < text.length; i += chunkSize) {
5
- chunks.push(text.slice(i, i + chunkSize));
6
- }
7
- return chunks;
8
- }
9
-
10
- export async function isElementFocused(locator: any): Promise<boolean> {
11
- try {
12
- // 使用字符串形式避免 DOM 类型依赖问题
13
- return await locator.evaluate(`(element) => {
14
- let active = document.activeElement;
15
- // 穿透 Shadow DOM
16
- while (active && active.shadowRoot && active.shadowRoot.activeElement) {
17
- active = active.shadowRoot.activeElement;
18
- }
19
- // 1. 精确匹配
20
- if (active === element) return true;
21
- // 2. 容器包含匹配 (如果 locator 是父容器)
22
- if (element.contains(active)) return true;
23
-
24
- return false;
25
- }`);
26
- } catch {
27
- return false;
28
- }
29
- }
30
-
31
- export function isLocator(obj: any): boolean {
32
- return (
33
- obj && typeof obj === "object" && "_frame" in obj && "_selector" in obj
34
- );
35
- }
36
-
@@ -1,105 +0,0 @@
1
- import type { Page, FrameLocator, Locator } from "patchright-core";
2
- import type { WaitForIframeCompleteOptions } from "./types";
3
- import { cancelableFunction } from "@tocha688/utils/sync";
4
- import { rInt } from "@tocha688/utils";
5
-
6
- export async function rWait(minMs = 200, maxMs = 800) {
7
- const waitTime = rInt(minMs, maxMs);
8
- return new Promise((resolve) => setTimeout(resolve, waitTime));
9
- }
10
-
11
- export async function safeWaitForLoadState(
12
- page: Page,
13
- state: "load" | "domcontentloaded" | "networkidle" | undefined = "load",
14
- timeoutMs: number = 30000
15
- ): Promise<boolean> {
16
- const stateName = state.toUpperCase();
17
-
18
- try {
19
- console.log(
20
- `[等待页面加载] 目标状态: ${stateName}, 超时: ${timeoutMs / 1000}s`
21
- );
22
-
23
- await page.waitForLoadState(state, { timeout: timeoutMs });
24
-
25
- console.log(`[等待页面加载] ${stateName} 状态已完成。`);
26
- return true;
27
- } catch (error) {
28
- console.error(`[等待页面加载] ${stateName} 状态失败或超时。`);
29
- return false;
30
- }
31
- }
32
-
33
- export function waitForIframeComplete(
34
- page: Page,
35
- frameLocator: string | number | symbol,
36
- frameInLocator: string | Locator,
37
- options: WaitForIframeCompleteOptions = {}
38
- ) {
39
- return new Promise<FrameLocator>(async (resolve, reject) => {
40
- const {
41
- frameAttachedTimeout = 45_000,
42
- frameVisibleTimeout = 10_000,
43
- frameBodyTimeout = 15_000,
44
- frameInLocatorOptions = {},
45
- waitForElementTimeout = 15_000,
46
- timeout = 2_000,
47
- } = options;
48
- console.log(`[等待 ${String(frameLocator)} iframe 完全加载]`);
49
- try {
50
- console.log("等待 iframe 元素...");
51
- await page.waitForSelector(String(frameLocator), {
52
- state: "attached",
53
- timeout: frameAttachedTimeout,
54
- });
55
-
56
- console.log("等待 iframe 可见...");
57
- await page.waitForSelector(String(frameLocator), {
58
- state: "visible",
59
- timeout: frameVisibleTimeout,
60
- });
61
- console.log("✅ iframe 可见");
62
- const frame = page.frameLocator(String(frameLocator));
63
-
64
- // 等待 iframe 内的关键元素出现
65
- await frame.locator("body").waitFor({
66
- state: "attached",
67
- timeout: frameBodyTimeout,
68
- });
69
- console.log("✅ iframe 内容已加载");
70
-
71
- console.log(`[等待指定元素可见] ${String(frameInLocator)}`);
72
- const waitForElement = frame.locator(
73
- frameInLocator as any, // Fix types
74
- frameInLocatorOptions
75
- );
76
- await waitForElement.waitFor({ timeout: waitForElementTimeout });
77
- console.log("[等待完全加载]");
78
- // 额外等待确保完全加载
79
- await page.waitForTimeout(timeout);
80
-
81
- resolve(frame);
82
- } catch (error) {
83
- reject(error);
84
- }
85
- });
86
- }
87
-
88
- export function waitForAbort(el: Locator, options: Parameters<Locator["waitFor"]>[0] = {}) {
89
- return cancelableFunction(async (abr) => {
90
- let start = Date.now();
91
- while (
92
- abr.signal.aborted === false &&
93
- Date.now() - start < (options.timeout || 30000)
94
- ) {
95
- // 开始检查
96
- const isVisible = await el.isVisible().catch(() => false);
97
- if (isVisible) {
98
- return el;
99
- }
100
- await rWait(100);
101
- }
102
- //超时
103
- throw new Error("waitForAbort 超时");
104
- });
105
- }
@@ -1 +0,0 @@
1
- export * from "./auto";
@@ -1,215 +0,0 @@
1
- import fontList from 'font-list';
2
- import { rInt } from '@tocha688/utils';
3
-
4
- export const PcScreen = [
5
- "750 × 1334",
6
- "800 x 600",
7
- "1024 x 600",
8
- "1024 x 640",
9
- "1024 x 768",
10
- "1152 x 864",
11
- "1280 x 720",
12
- "1280 x 768",
13
- "1280 x 800",
14
- "1280 x 960",
15
- "1280 x 1024",
16
- "1360 x 768",
17
- "808 × 1792",
18
- "828 × 1792",
19
- "1080 x 2340",
20
- "1125 x 2436",
21
- "1242 x 2208",
22
- "1170 × 2532",
23
- "1284 x 2778",
24
- "1366 x 768",
25
- "1400 x 1050",
26
- "1400 x 900",
27
- "1440 x 900",
28
- "1536 x 864",
29
- "1600 x 900",
30
- "1600 x 1200",
31
- "1680 x 1050",
32
- "1920 x 1080",
33
- "1920 x 1200",
34
- "2048 x 1152",
35
- "2304 x 1440",
36
- "2560 x 1440",
37
- "2560 x 1600",
38
- "2880 x 1800",
39
- "4096 x 2304",
40
- "5120 x 2880"
41
- ];
42
-
43
- // cpu
44
- export const Cpus = [
45
- "2",
46
- "3",
47
- "4",
48
- "6",
49
- "8",
50
- "10",
51
- "12",
52
- "16",
53
- "20",
54
- "24",
55
- "32",
56
- "64"
57
- ]
58
-
59
- export const Memorys = [
60
- "2",
61
- "4",
62
- "6",
63
- "8",
64
- "16",
65
- "32",
66
- "64",
67
- "128"
68
- ]
69
-
70
-
71
- export const LinuxWebGL = [
72
- {
73
- name: "Google Inc. (AMD)",
74
- values: [
75
- "ANGLE (AMD, RENOIR(renoir LLVM 15.0.7), OpenGL 4.6)",
76
- ]
77
- },
78
- {
79
- name: "Google Inc. (Intel)",
80
- values: [
81
- "ANGLE (Intel, Mesa Intel(R) Graphics (RPL-S), OpenGL 4.6)",
82
- "ANGLE (Intel, Mesa Intel(R) Graphics (RPL-P), OpenGL 4.6)",
83
- "ANGLE (Intel, Mesa Intel(R) Xe Graphics (TGL GT2), OpenGL 4.6)",
84
- ]
85
- }
86
- ]
87
-
88
- export const WindowsWebGL = [
89
- {
90
- name: "Google Inc. (NVIDIA)",
91
- vendor: "nvidia",
92
- values: [
93
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1660 SUPER (0x000021C4) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6647)",
94
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 750 Ti (0x00001380) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6647)",
95
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 650 (0x00002504) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6140)",
96
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 Ti (0x00001C8C) Direct3D9Ex vs_3_0 ps_3_0, D3D9Ex)",
97
- "ANGLE (NVIDIA, NVIDIA GeForce GT 635M (0x00002504) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.13.6472)",
98
- "ANGLE (NVIDIA, NVIDIA GeForce GT 710 (0x0000128B) Direct3D11 vs_5_0 ps_5_0, D3D11-26.21.14.3160)",
99
- "ANGLE (NVIDIA, NVIDIA GeForce 410M (0x00001055) Direct3D11 vs_5_0 ps_5_0, D3D11)",
100
- "ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 (0x00001F51) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6093)",
101
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1060 (0x00001C20) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5148)",
102
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1660 (0x00002184) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5751)",
103
- "ANGLE (NVIDIA, NVIDIA GeForce RTX 2070 SUPER (0x00001E84) Direct3D11 vs_5_0 ps_5_0, D3D11)",
104
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 750 Ti (0x00001380) Direct3D9Ex vs_3_0 ps_3_0, nvd3dumx.dll-26.21.14.4219)",
105
- "ANGLE (NVIDIA, NVIDIA GeForce GT 730 (0x00001287) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5671)",
106
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1650 (0x00001F9D) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5751)",
107
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 (0x00001C91) Direct3D11 vs_5_0 ps_5_0, D3D11-22.21.13.8476)",
108
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 950 (0x00001402) Direct3D11 vs_5_0 ps_5_0, D3D11-26.21.14.4187)",
109
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 960 (0x00001401) Direct3D11 vs_5_0 ps_5_0, D3D11)",
110
- "ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 (0x00002484) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6611)",
111
- "ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 (0x00001F51) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5256)",
112
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 660 (0x000011C0) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5671)",
113
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 970 (0x000013C2) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5671)",
114
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1650 (0x00001F9D) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5256)",
115
- "ANGLE (NVIDIA, NVIDIA GeForce 205 (0x00002504) Direct3D11 vs_4_1 ps_4_1, D3D11)",
116
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1070 (0x00001BA1) Direct3D11 vs_5_0 ps_5_0, D3D11)",
117
- "ANGLE (NVIDIA, NVIDIA Quadro K620 (0x00002504) Direct3D11 vs_5_0 ps_5_0, D3D11)",
118
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1060 3GB (0x00001C02) Direct3D9Ex vs_3_0 ps_3_0, D3D9Ex)",
119
- "ANGLE (NVIDIA, NVIDIA GeForce GT 635M (0x00002504) Direct3D11 vs_5_0 ps_5_0, D3D11-23.21.13.9124)",
120
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 (0x00001C91) Direct3D11 vs_5_0 ps_5_0, D3D11-26.21.14.3630)",
121
- "ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 (0x00001F51) Direct3D11 vs_5_0 ps_5_0, D3D11-26.21.14.4250)",
122
- "ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 SUPER (0x00001F47) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5167)",
123
- "ANGLE (NVIDIA, NVIDIA Quadro P600 (0x00001CB2) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5239)",
124
- "ANGLE (NVIDIA, NVIDIA Quadro M1000M (0x00002504) Direct3D11 vs_5_0 ps_5_0, D3D11)",
125
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 550 Ti (0x00001244) Direct3D11 vs_5_0 ps_5_0, D3D11)",
126
- "ANGLE (NVIDIA, NVIDIA GeForce 210 (0x00000A65) Direct3D11 vs_4_0 ps_4_0, D3D11)",
127
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1650 SUPER (0x00002187) Direct3D11 vs_5_0 ps_5_0, D3D11-26.21.14.4120)",
128
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1660 Ti (0x00002191) Direct3D11 vs_5_0 ps_5_0, D3D11)",
129
- "ANGLE (NVIDIA, NVIDIA GeForce GT 1030 (0x00001D01) Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.5671)",
130
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 970 (0x000013C2) Direct3D11 vs_5_0 ps_5_0, D3D11)",
131
- "ANGLE (NVIDIA, NVIDIA GeForce GTX 1070 (0x00001BA1) Direct3D11 vs_5_0 ps_5_0, D3D11-23.21.13.8813)",
132
- "ANGLE (NVIDIA, NVIDIA GeForce GT 730 (0x00001287) Direct3D11 vs_5_0 ps_5_0, D3D11-9.18.13.4411)"
133
- ]
134
- },
135
- {
136
- name: "Google Inc. (AMD)",
137
- vendor: "amd",
138
- values: [
139
- "ANGLE (AMD, AMD Radeon(TM) RX 560 Series (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11)",
140
- "ANGLE (AMD, AMD Radeon(TM) Vega 8 Mobile Graphics (0x000015DD) Direct3D9Ex vs_3_0 ps_3_0, D3D11)",
141
- "ANGLE (AMD, Radeon RX RX550/550 Series (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11)",
142
- "ANGLE (AMD, AMD Radeon R7 350 Series (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11-26.20.15029.27017)",
143
- "ANGLE (AMD, AMD Radeon(TM) R7 Graphics (0x0000130F) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.1034.6)",
144
- "ANGLE (AMD, Radeon RX 560 Series (0x000067EF) Direct3D11 vs_5_0 ps_5_0, D3D11-26.20.15029.27017)",
145
- "ANGLE (AMD, AMD Radeon HD 7800 Series (0x00006819) Direct3D9Ex vs_3_0 ps_3_0, aticfx64.dll-26.20.15029.15007)",
146
- "ANGLE (AMD, AMD Radeon RX 580 2048SP (0x00006FDF) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.15003.5017)",
147
- "ANGLE (AMD, AMD Radeon(TM) Vega 8 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.14501.18003)",
148
- "ANGLE (AMD, AMD Radeon(TM) Graphics (0x0000164E) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.14044.2001)",
149
- "ANGLE (AMD, AMD Radeon Series (0x00001636) Direct3D9Ex vs_3_0 ps_3_0, aticfx32.dll-23.20.15002.11)",
150
- "ANGLE (AMD, Radeon (TM) RX 470 Graphics (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11-26.20.13031.18002)",
151
- "ANGLE (AMD, AMD Radeon HD 6530D (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11)",
152
- "ANGLE (AMD, Radeon RX 580 Series (0x000067DF) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.14534.2)",
153
- "ANGLE (AMD, AMD Radeon(TM) RX Vega 10 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11-25.20.14132.2002)",
154
- "ANGLE (AMD, AMD Radeon R7 430 (0x00006611) Direct3D11 vs_5_0 ps_5_0, D3D11)",
155
- "ANGLE (AMD, AMD Radeon (TM) R9 200 Series (0x00006811) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.1034.6)",
156
- "ANGLE (AMD, AMD Radeon(TM) Vega 8 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11-26.20.11008.3003)",
157
- "ANGLE (AMD, AMD Radeon(TM) RX Vega 10 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.1028.1)",
158
- "ANGLE (AMD, AMD Radeon(TM) Graphics (0x0000164E) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.1020.2002)",
159
- "ANGLE (AMD, AMD Radeon(TM) Vega 8 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11)",
160
- "ANGLE (AMD, AMD Radeon R7 200 Series (0x00006658) Direct3D11 vs_5_0 ps_5_0, D3D11)"
161
- ]
162
- },
163
- {
164
- name: "Google Inc. (Intel)",
165
- vendor: "Intel",
166
- values: [
167
- "ANGLE (Intel, Intel(R) UHD Graphics 630 (0x00003E98) Direct3D11 vs_5_0 ps_5_0, D3D11-25.20.100.6617)",
168
- "ANGLE (Intel, Intel(R) UHD Graphics 620 (0x00003EA0) Direct3D11 vs_5_0 ps_5_0, D3D11-24.20.100.6346)",
169
- "ANGLE (Intel, Intel(R) UHD Graphics 630 (0x00003E98) Direct3D11 vs_5_0 ps_5_0, D3D11-26.20.100.7637)",
170
- "ANGLE (Intel, Intel(R) UHD Graphics 630 (0x00003E98) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.8682)",
171
- "ANGLE (Intel, Intel(R) HD Graphics Family (0x00000A16) Direct3D9Ex vs_3_0 ps_3_0, igdumdim64.dll-10.18.10.3907)",
172
- "ANGLE (Intel, Intel(R) HD Graphics 4000 (0x00000162) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.10.4252)",
173
- "ANGLE (Intel, Intel(R) HD Graphics 530 (0x0000191B) Direct3D11 vs_5_0 ps_5_0, D3D11-20.19.15.4364)",
174
- "ANGLE (Intel, Intel(R) UHD Graphics 620 (0x00003EA0) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.9126)",
175
- "ANGLE (Intel, Intel(R) UHD Graphics (0x00009BA4) Direct3D11 vs_5_0 ps_5_0, D3D11-26.20.100.7985)",
176
- "ANGLE (Intel, Intel(R) HD Graphics Family (0x00000A16) Direct3D11 vs_5_0 ps_5_0, D3D11-20.19.15.5058)",
177
- "ANGLE (Intel, Intel(R) UHD Graphics 610 (0x00003EA1) Direct3D11 vs_5_0 ps_5_0, D3D11-25.20.100.6471)",
178
- "ANGLE (Intel, Intel(R) HD Graphics 4600 (0x00000416) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.14.5067)",
179
- "ANGLE (Intel, Intel(R) HD Graphics (0x000022B0) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.10.5100)ANGLE (Intel, Intel(R) HD Graphics (0x000022B0) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.10.5100)",
180
- "ANGLE (Intel, Intel(R) HD Graphics (0x000022B0) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.10.5100)",
181
- "ANGLE (Intel, Intel(R) UHD Graphics 630 (0x00003E98) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.9466)",
182
- "ANGLE (Intel, Intel(R) HD Graphics 4400 (0x0000041E) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.10.3412)",
183
- "ANGLE (Intel, Intel(R) Iris(TM) Graphics 6100 (0x00007DD5) Direct3D11 vs_5_0 ps_5_0, D3D11)",
184
- "ANGLE (Intel, Intel(R) Iris(R) Plus Graphics (0x00008A5A) Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.8853)",
185
- "ANGLE (Intel, Intel(R) HD Graphics 520 (0x00001921) Direct3D11 vs_5_0 ps_5_0, D3D11-21.20.16.4727)",
186
- "ANGLE (Intel, Intel(R) Iris(R) Plus Graphics (0x00008A5A) Direct3D9Ex vs_3_0 ps_3_0, D3D9Ex)",
187
- "ANGLE (Intel, Intel(R) HD Graphics (0x000022B0) Direct3D11 vs_5_0 ps_5_0, D3D11-10.18.10.5059)",
188
- "ANGLE (Intel, Intel(R) HD Graphics 5300 (0x00007DD5) Direct3D11 vs_5_0 ps_5_0, D3D11-20.19.15.4531)",
189
- "ANGLE (Intel, Intel(R) HD Graphics 4000 (0x00000162) Direct3D9Ex vs_3_0 ps_3_0, igdumd64.dll-9.17.10.2849)"
190
- ]
191
- }
192
- ]
193
-
194
- /** 获取系统字体,并且随机返回一些字体(不重复,排除中文字体) */
195
- export async function rSysFonts(): Promise<string[]> {
196
- const fonts = await fontList.getFonts();
197
-
198
- // 过滤掉包含中文字符的字体
199
- const nonChineseFonts = fonts.filter(font => !/[\u4e00-\u9fa5]/.test(font));
200
-
201
- const count = rInt(5, Math.min(50, nonChineseFonts.length)); // 确保不超过可用字体数量
202
-
203
- // 使用 Fisher-Yates 洗牌算法来随机选择不重复的字体
204
- const shuffled = [...nonChineseFonts];
205
- for (let i = shuffled.length - 1; i > 0; i--) {
206
- const j = rInt(0, i);
207
- // 交换元素
208
- const temp = shuffled[i];
209
- shuffled[i] = shuffled[j]!;
210
- shuffled[j] = temp!;
211
- }
212
-
213
- // 返回前 count 个字体
214
- return shuffled.slice(0, count);
215
- }
@@ -1,3 +0,0 @@
1
- import path from "path";
2
-
3
- export const BrowserCachePath = path.join(process.cwd(), "tmp", "browser_cache");