@skrillex1224/playwright-toolkit 3.0.24 → 3.0.26
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/README.md +1 -1
- package/dist/browser.js +232 -1
- package/dist/browser.js.map +3 -3
- package/dist/index.cjs +13 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +13 -6
- package/dist/index.js.map +2 -2
- package/index.d.ts +2 -1
- package/package.json +2 -8
- package/scripts/postinstall.js +40 -1
package/index.d.ts
CHANGED
|
@@ -207,6 +207,7 @@ export interface RunStepOptions {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
export interface ApifyKitInstance {
|
|
210
|
+
isAtHome(): boolean;
|
|
210
211
|
runStep<T>(step: string, page: Page | null, actionFn: () => Promise<T>, options?: RunStepOptions): Promise<T>;
|
|
211
212
|
runStepLoose<T>(step: string, page: Page | null, fn: () => Promise<T>, options?: RunStepOptions): Promise<T>;
|
|
212
213
|
pushSuccess(data: Record<string, any>, options?: { page?: Page | null }): Promise<void>;
|
|
@@ -444,7 +445,7 @@ export interface GetPlaywrightCrawlerOptionsInput {
|
|
|
444
445
|
};
|
|
445
446
|
runInHeadfulMode?: boolean;
|
|
446
447
|
debugMode?: boolean;
|
|
447
|
-
|
|
448
|
+
isRunningAtHome?: boolean;
|
|
448
449
|
launcher?: any;
|
|
449
450
|
runtimeState?: RuntimeEnvState | null;
|
|
450
451
|
hooks?: LaunchHooks;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skrillex1224/playwright-toolkit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.26",
|
|
4
4
|
"description": "一个在 Apify/Crawlee Actor 中启用实时截图视图的实用工具库。",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "node build.js",
|
|
25
|
-
"postinstall": "node ./scripts/postinstall.js",
|
|
26
25
|
"release": "npm run build && npm version patch && npm publish --registry https://registry.npmjs.org --access public --userconfig ../.npmrc",
|
|
26
|
+
"postinstall": "node ./scripts/postinstall.js",
|
|
27
27
|
"prepublishOnly": "npm run build",
|
|
28
28
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
29
29
|
},
|
|
@@ -61,16 +61,10 @@
|
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"apify": "*",
|
|
64
|
-
"cloakbrowser": "*",
|
|
65
64
|
"crawlee": "*",
|
|
66
65
|
"ghost-cursor-playwright": "*",
|
|
67
66
|
"playwright": "*"
|
|
68
67
|
},
|
|
69
|
-
"peerDependenciesMeta": {
|
|
70
|
-
"cloakbrowser": {
|
|
71
|
-
"optional": true
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
68
|
"devDependencies": {
|
|
75
69
|
"esbuild": "^0.24.2"
|
|
76
70
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -14,6 +14,13 @@ const warn = (message) => console.warn(`${PREFIX} ${message}`);
|
|
|
14
14
|
|
|
15
15
|
const isTruthy = (value) => /^(1|true|yes|on)$/i.test(String(value || '').trim());
|
|
16
16
|
|
|
17
|
+
const toPositiveInteger = (value, fallback) => {
|
|
18
|
+
const parsed = Number(value);
|
|
19
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
23
|
+
|
|
17
24
|
const readTrimmedFile = (filePath) => {
|
|
18
25
|
try {
|
|
19
26
|
return fs.readFileSync(filePath, 'utf8').trim();
|
|
@@ -124,6 +131,35 @@ const clearStaleVersionMarkers = ({ cacheDir, expectedVersion, platformTag }) =>
|
|
|
124
131
|
return clearedMarkers;
|
|
125
132
|
};
|
|
126
133
|
|
|
134
|
+
const ensureBinaryWithRetries = async ({ cloakModule, expectedBinaryPath }) => {
|
|
135
|
+
const attempts = toPositiveInteger(process.env.PLAYWRIGHT_TOOLKIT_CLOAK_POSTINSTALL_RETRIES, 4);
|
|
136
|
+
const baseDelayMs = toPositiveInteger(process.env.PLAYWRIGHT_TOOLKIT_CLOAK_POSTINSTALL_RETRY_DELAY_MS, 15000);
|
|
137
|
+
let lastError = null;
|
|
138
|
+
|
|
139
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
140
|
+
try {
|
|
141
|
+
return await cloakModule.ensureBinary();
|
|
142
|
+
} catch (error) {
|
|
143
|
+
lastError = error;
|
|
144
|
+
if (isBinaryReady(expectedBinaryPath)) {
|
|
145
|
+
warn(`ensureBinary failed after installing the expected binary; continuing with ${expectedBinaryPath}.`);
|
|
146
|
+
return expectedBinaryPath;
|
|
147
|
+
}
|
|
148
|
+
if (attempt >= attempts) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const delayMs = baseDelayMs * attempt;
|
|
152
|
+
warn(
|
|
153
|
+
`cloakbrowser install attempt ${attempt}/${attempts} failed: ${error?.message || String(error)}. `
|
|
154
|
+
+ `Retrying in ${delayMs}ms.`,
|
|
155
|
+
);
|
|
156
|
+
await sleep(delayMs);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
throw lastError;
|
|
161
|
+
};
|
|
162
|
+
|
|
127
163
|
const main = async () => {
|
|
128
164
|
if (isTruthy(process.env[SKIP_ENV])) {
|
|
129
165
|
log(`Skipped because ${SKIP_ENV} is set.`);
|
|
@@ -178,7 +214,10 @@ const main = async () => {
|
|
|
178
214
|
}
|
|
179
215
|
|
|
180
216
|
log(`Installing cloakbrowser ${expectedVersion} for ${platformTag}...`);
|
|
181
|
-
const resolvedBinaryPath = await
|
|
217
|
+
const resolvedBinaryPath = await ensureBinaryWithRetries({
|
|
218
|
+
cloakModule,
|
|
219
|
+
expectedBinaryPath,
|
|
220
|
+
});
|
|
182
221
|
|
|
183
222
|
if (!isBinaryReady(expectedBinaryPath)) {
|
|
184
223
|
throw new Error(
|