@oro-dxeco/playwright-aws-lambda 133.0.0-alpha.2 → 133.0.0-alpha.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.
package/dist/src/chromium.js
CHANGED
|
@@ -12,7 +12,7 @@ const isHeadlessModeEnabled_1 = require("./util/isHeadlessModeEnabled");
|
|
|
12
12
|
const fileExists_1 = require("./util/fileExists");
|
|
13
13
|
const getEnvironmentVariables_1 = require("./util/getEnvironmentVariables");
|
|
14
14
|
const isLambdaRuntimeEnvironmentNode20_1 = require("./util/isLambdaRuntimeEnvironmentNode20");
|
|
15
|
-
const
|
|
15
|
+
const lambdafs_1 = require("@sparticuz/chromium/build/lambdafs");
|
|
16
16
|
/**
|
|
17
17
|
* Returns a list of recommended additional Chromium flags.
|
|
18
18
|
*/
|
|
@@ -80,14 +80,14 @@ async function getChromiumExecutablePath(headless) {
|
|
|
80
80
|
}
|
|
81
81
|
const input = path.join(__dirname, 'bin');
|
|
82
82
|
const promises = [
|
|
83
|
-
inflate(
|
|
84
|
-
inflate(
|
|
83
|
+
lambdafs_1.default.inflate(path.join(input, 'chromium.br')),
|
|
84
|
+
lambdafs_1.default.inflate(path.join(input, 'swiftshader.tar.br')),
|
|
85
85
|
];
|
|
86
86
|
if (isLambdaRuntimeEnvironment_1.default()) {
|
|
87
|
-
promises.push(inflate(
|
|
87
|
+
promises.push(lambdafs_1.default.inflate(path.join(input, 'al2.tar.br')));
|
|
88
88
|
}
|
|
89
89
|
if (isLambdaRuntimeEnvironmentNode20_1.default()) {
|
|
90
|
-
promises.push(inflate(
|
|
90
|
+
promises.push(lambdafs_1.default.inflate(path.join(input, 'al2023.tar.br')));
|
|
91
91
|
}
|
|
92
92
|
const result = await Promise.all(promises);
|
|
93
93
|
return result.shift();
|
|
@@ -96,8 +96,13 @@ async function launchChromium(launchOptions) {
|
|
|
96
96
|
const headless = isHeadlessModeEnabled_1.default();
|
|
97
97
|
const args = getChromiumArgs(headless);
|
|
98
98
|
const executablePath = await getChromiumExecutablePath(headless);
|
|
99
|
+
const baselibPath = isLambdaRuntimeEnvironment_1.default()
|
|
100
|
+
? '/tmp/al2/lib'
|
|
101
|
+
: isLambdaRuntimeEnvironmentNode20_1.default()
|
|
102
|
+
? '/tmp/al2023/lib'
|
|
103
|
+
: '/tmp/aws/lib';
|
|
99
104
|
const env = {
|
|
100
|
-
...(await getEnvironmentVariables_1.default()),
|
|
105
|
+
...(await getEnvironmentVariables_1.default(baselibPath)),
|
|
101
106
|
...((launchOptions === null || launchOptions === void 0 ? void 0 : launchOptions.env) || {}),
|
|
102
107
|
};
|
|
103
108
|
const browser = await playwright.chromium.launch({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const AWS_TMP_DIR = "/tmp/aws";
|
|
2
2
|
export declare const AWS_FONT_DIR = "/tmp/fonts";
|
|
3
|
-
export default function getEnvironmentVariables(): Promise<Record<string, string>>;
|
|
3
|
+
export default function getEnvironmentVariables(baselibPath: string): Promise<Record<string, string>>;
|
|
@@ -7,8 +7,8 @@ const isLambdaRuntimeEnvironment_1 = require("./isLambdaRuntimeEnvironment");
|
|
|
7
7
|
const isLambdaRuntimeEnvironmentNode20_1 = require("./isLambdaRuntimeEnvironmentNode20");
|
|
8
8
|
exports.AWS_TMP_DIR = '/tmp/aws';
|
|
9
9
|
exports.AWS_FONT_DIR = '/tmp/fonts';
|
|
10
|
-
const AWS_LIB_DIR = `${
|
|
11
|
-
async function getEnvironmentVariables() {
|
|
10
|
+
//const AWS_LIB_DIR = `${AWS_TMP_DIR}/lib`;
|
|
11
|
+
async function getEnvironmentVariables(baselibPath) {
|
|
12
12
|
if (!isLambdaRuntimeEnvironment_1.default() && !isLambdaRuntimeEnvironmentNode20_1.default()) {
|
|
13
13
|
return {};
|
|
14
14
|
}
|
|
@@ -18,23 +18,23 @@ async function getEnvironmentVariables() {
|
|
|
18
18
|
// alternatively set it to a non-existing directory.
|
|
19
19
|
if (!process.env.FONTCONFIG_PATH && fs_1.existsSync(exports.AWS_FONT_DIR)) {
|
|
20
20
|
env.FONTCONFIG_PATH = exports.AWS_FONT_DIR;
|
|
21
|
-
await fs_1.promises.writeFile(path.join(exports.AWS_FONT_DIR, 'fonts.conf'), `<?xml version="1.0"?>
|
|
22
|
-
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
|
23
|
-
<fontconfig>
|
|
24
|
-
<dir>${exports.AWS_FONT_DIR}</dir>
|
|
25
|
-
<cachedir>/tmp/fonts-cache/</cachedir>
|
|
26
|
-
<config></config>
|
|
21
|
+
await fs_1.promises.writeFile(path.join(exports.AWS_FONT_DIR, 'fonts.conf'), `<?xml version="1.0"?>
|
|
22
|
+
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
|
23
|
+
<fontconfig>
|
|
24
|
+
<dir>${exports.AWS_FONT_DIR}</dir>
|
|
25
|
+
<cachedir>/tmp/fonts-cache/</cachedir>
|
|
26
|
+
<config></config>
|
|
27
27
|
</fontconfig>`);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
env.FONTCONFIG_PATH = exports.AWS_TMP_DIR;
|
|
31
31
|
}
|
|
32
32
|
if (!process.env.LD_LIBRARY_PATH) {
|
|
33
|
-
env.LD_LIBRARY_PATH =
|
|
33
|
+
env.LD_LIBRARY_PATH = baselibPath;
|
|
34
34
|
}
|
|
35
|
-
else if (!process.env.LD_LIBRARY_PATH.startsWith(
|
|
35
|
+
else if (!process.env.LD_LIBRARY_PATH.startsWith(baselibPath)) {
|
|
36
36
|
env.LD_LIBRARY_PATH = [
|
|
37
|
-
...new Set([
|
|
37
|
+
...new Set([baselibPath, ...process.env.LD_LIBRARY_PATH.split(':')]),
|
|
38
38
|
].join(':');
|
|
39
39
|
}
|
|
40
40
|
return env;
|
package/package.json
CHANGED