@intuned/runtime-dev 1.3.25-sm.0 → 1.3.27-dev2
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/CHANGELOG.md +3 -2
- package/dist/common/intunedJson.js +1 -1
- package/dist/common/launchBrowser.d.ts +2 -0
- package/dist/common/launchBrowser.js +51 -12
- package/dist/common/playwrightContext.d.ts +2 -0
- package/dist/common/playwrightContext.js +9 -4
- package/dist/common/runApi/index.js +2 -0
- package/dist/vendor/runtime-interface.js +4 -2
- package/package.json +1 -1
- package/template.tsconfig.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# UNRELEASED
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# 1.3.26
|
|
4
|
+
|
|
5
|
+
- change default browser dimensions
|
|
5
6
|
|
|
6
7
|
# 1.3.11
|
|
7
8
|
|
|
@@ -22,11 +22,13 @@ export type LaunchChromiumStandaloneOptions = {
|
|
|
22
22
|
appModeInitialUrl?: string;
|
|
23
23
|
executablePath?: string;
|
|
24
24
|
ignoreHttpErrors?: boolean;
|
|
25
|
+
profileTemplatePath?: string;
|
|
25
26
|
timeout?: number;
|
|
26
27
|
};
|
|
27
28
|
export type LaunchChromiumCdpOptions = {
|
|
28
29
|
cdpAddress: string;
|
|
29
30
|
cdpTargetId?: string;
|
|
31
|
+
profileTemplatePath?: string;
|
|
30
32
|
timeout?: number;
|
|
31
33
|
};
|
|
32
34
|
export declare function launchChromium(options: LaunchChromiumStandaloneOptions): Promise<LaunchBrowserResult>;
|
|
@@ -34,25 +34,63 @@ function getMacKeychainBypassArgs() {
|
|
|
34
34
|
}
|
|
35
35
|
return ["--use-mock-keychain", "--password-store=basic"];
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
const DEFAULT_USER_PREFERENCES = {
|
|
38
|
+
plugins: {
|
|
39
|
+
always_open_pdf_externally: true
|
|
40
|
+
},
|
|
41
|
+
credentials_enable_service: false,
|
|
42
|
+
profile: {
|
|
43
|
+
password_manager_enabled: false
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
async function createUserDirWithPreferences(profileTemplatePath) {
|
|
38
47
|
const playwrightTempDir = await (0, _fsExtra.mkdtemp)("/tmp/pw-");
|
|
39
48
|
const userDir = (0, _path.join)(playwrightTempDir, "userdir");
|
|
40
49
|
const defaultDir = (0, _path.join)(userDir, "Default");
|
|
50
|
+
const preferencesPath = (0, _path.join)(defaultDir, "Preferences");
|
|
51
|
+
if (profileTemplatePath && (await fs.pathExists(profileTemplatePath))) {
|
|
52
|
+
await fs.copy(profileTemplatePath, defaultDir, {
|
|
53
|
+
overwrite: true,
|
|
54
|
+
errorOnExist: false
|
|
55
|
+
});
|
|
56
|
+
let templatePreferences = {};
|
|
57
|
+
if (await fs.pathExists(preferencesPath)) {
|
|
58
|
+
try {
|
|
59
|
+
templatePreferences = await fs.readJson(preferencesPath);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.warn(`Failed to parse Preferences from profile template at ${preferencesPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const mergedPreferences = mergePreferences(templatePreferences, DEFAULT_USER_PREFERENCES);
|
|
65
|
+
await (0, _fsExtra.mkdir)(defaultDir, {
|
|
66
|
+
recursive: true
|
|
67
|
+
});
|
|
68
|
+
await (0, _fsExtra.writeFile)(preferencesPath, JSON.stringify(mergedPreferences));
|
|
69
|
+
return userDir;
|
|
70
|
+
}
|
|
41
71
|
await (0, _fsExtra.mkdir)(defaultDir, {
|
|
42
72
|
recursive: true
|
|
43
73
|
});
|
|
44
|
-
|
|
45
|
-
plugins: {
|
|
46
|
-
always_open_pdf_externally: true
|
|
47
|
-
},
|
|
48
|
-
credentials_enable_service: false,
|
|
49
|
-
profile: {
|
|
50
|
-
password_manager_enabled: false
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
await (0, _fsExtra.writeFile)((0, _path.join)(defaultDir, "Preferences"), JSON.stringify(preferences));
|
|
74
|
+
await (0, _fsExtra.writeFile)(preferencesPath, JSON.stringify(DEFAULT_USER_PREFERENCES));
|
|
54
75
|
return userDir;
|
|
55
76
|
}
|
|
77
|
+
function isPlainObject(value) {
|
|
78
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
79
|
+
}
|
|
80
|
+
function mergePreferences(base, overrides) {
|
|
81
|
+
const result = {
|
|
82
|
+
...base
|
|
83
|
+
};
|
|
84
|
+
for (const [key, overrideValue] of Object.entries(overrides)) {
|
|
85
|
+
const baseValue = result[key];
|
|
86
|
+
if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {
|
|
87
|
+
result[key] = mergePreferences(baseValue, overrideValue);
|
|
88
|
+
} else {
|
|
89
|
+
result[key] = overrideValue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
56
94
|
async function getIgnoreHttpErrorsFromConfig(cliOption) {
|
|
57
95
|
if (cliOption === true) {
|
|
58
96
|
return true;
|
|
@@ -105,6 +143,7 @@ async function launchChromium(options) {
|
|
|
105
143
|
proxy,
|
|
106
144
|
downloadsPath,
|
|
107
145
|
ignoreHttpErrors: ignoreHttpErrorsParam,
|
|
146
|
+
profileTemplatePath,
|
|
108
147
|
timeout
|
|
109
148
|
} = options;
|
|
110
149
|
let {
|
|
@@ -119,7 +158,7 @@ async function launchChromium(options) {
|
|
|
119
158
|
if (stealthConfig.enabled) {
|
|
120
159
|
extraArgs.push("--stealth-mode");
|
|
121
160
|
}
|
|
122
|
-
const userDataDir = await createUserDirWithPreferences();
|
|
161
|
+
const userDataDir = await createUserDirWithPreferences(profileTemplatePath);
|
|
123
162
|
if ((0, _extensionsHelpers.isIntunedExtensionLoaded)()) {
|
|
124
163
|
const extensionsList = (0, _extensionsHelpers.buildExtensionsList)();
|
|
125
164
|
const extensions = extensionsList.join(",");
|
|
@@ -18,10 +18,12 @@ export declare function withPlaywrightContext<R>(options: {
|
|
|
18
18
|
headless: boolean;
|
|
19
19
|
downloadsPath: string;
|
|
20
20
|
ignoreHttpErrors?: boolean;
|
|
21
|
+
profileTemplatePath?: string;
|
|
21
22
|
} & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
22
23
|
export declare function withPlaywrightContext<R>(options: {
|
|
23
24
|
cdpAddress: string;
|
|
24
25
|
cdpTargetId?: string;
|
|
26
|
+
profileTemplatePath?: string;
|
|
25
27
|
} & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
|
|
26
28
|
export declare function loadSessionToContext({ context, session, }: {
|
|
27
29
|
context: playwright.BrowserContext;
|
|
@@ -21,6 +21,7 @@ async function withPlaywrightContext({
|
|
|
21
21
|
headless = true,
|
|
22
22
|
downloadsPath,
|
|
23
23
|
ignoreHttpErrors: cliIgnoreHttpErrors,
|
|
24
|
+
profileTemplatePath,
|
|
24
25
|
importFunction,
|
|
25
26
|
apiName,
|
|
26
27
|
apiParameters
|
|
@@ -43,7 +44,8 @@ async function withPlaywrightContext({
|
|
|
43
44
|
context
|
|
44
45
|
} = await (0, _launchBrowser.launchBrowser)({
|
|
45
46
|
cdpAddress,
|
|
46
|
-
cdpTargetId
|
|
47
|
+
cdpTargetId,
|
|
48
|
+
profileTemplatePath
|
|
47
49
|
}));
|
|
48
50
|
} else {
|
|
49
51
|
({
|
|
@@ -53,7 +55,8 @@ async function withPlaywrightContext({
|
|
|
53
55
|
proxy,
|
|
54
56
|
headless,
|
|
55
57
|
downloadsPath,
|
|
56
|
-
ignoreHttpErrors
|
|
58
|
+
ignoreHttpErrors,
|
|
59
|
+
profileTemplatePath
|
|
57
60
|
}));
|
|
58
61
|
}
|
|
59
62
|
return await fn(context, page);
|
|
@@ -66,7 +69,8 @@ async function withPlaywrightContext({
|
|
|
66
69
|
page
|
|
67
70
|
} = await (0, _launchBrowser.launchBrowser)({
|
|
68
71
|
cdpAddress,
|
|
69
|
-
cdpTargetId
|
|
72
|
+
cdpTargetId,
|
|
73
|
+
profileTemplatePath
|
|
70
74
|
}));
|
|
71
75
|
} else {
|
|
72
76
|
const port = await (0, _portfinder.getPort)({
|
|
@@ -80,7 +84,8 @@ async function withPlaywrightContext({
|
|
|
80
84
|
headless,
|
|
81
85
|
downloadsPath,
|
|
82
86
|
cdpPort: port,
|
|
83
|
-
ignoreHttpErrors
|
|
87
|
+
ignoreHttpErrors,
|
|
88
|
+
profileTemplatePath
|
|
84
89
|
}));
|
|
85
90
|
hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
|
|
86
91
|
}
|
|
@@ -148,6 +148,7 @@ async function runApi({
|
|
|
148
148
|
proxy: runOptions.proxy,
|
|
149
149
|
downloadsPath,
|
|
150
150
|
ignoreHttpErrors: runOptions.ignoreHttpErrors,
|
|
151
|
+
profileTemplatePath: runOptions.profileTemplatePath,
|
|
151
152
|
...playwrightContextParameters
|
|
152
153
|
}, runAutomationWithContext);
|
|
153
154
|
} finally {
|
|
@@ -157,6 +158,7 @@ async function runApi({
|
|
|
157
158
|
return await (0, _playwrightContext.withPlaywrightContext)({
|
|
158
159
|
cdpAddress: runOptions.cdpAddress,
|
|
159
160
|
cdpTargetId: runOptions.cdpTargetId,
|
|
161
|
+
profileTemplatePath: runOptions.profileTemplatePath,
|
|
160
162
|
...playwrightContextParameters
|
|
161
163
|
}, runAutomationWithContext);
|
|
162
164
|
}
|
|
@@ -226,12 +226,14 @@ var require_types = __commonJS({
|
|
|
226
226
|
environment: zod_1.default.literal("standalone"),
|
|
227
227
|
headless: zod_1.default.boolean().default(true),
|
|
228
228
|
proxy: exports2.runApiProxySchema.optional(),
|
|
229
|
-
ignoreHttpErrors: zod_1.default.boolean().optional()
|
|
229
|
+
ignoreHttpErrors: zod_1.default.boolean().optional(),
|
|
230
|
+
profileTemplatePath: zod_1.default.string().optional()
|
|
230
231
|
});
|
|
231
232
|
exports2.runApiCdpRunOptionsSchema = zod_1.default.object({
|
|
232
233
|
environment: zod_1.default.literal("cdp"),
|
|
233
234
|
cdpAddress: zod_1.default.string(),
|
|
234
|
-
cdpTargetId: zod_1.default.string().optional()
|
|
235
|
+
cdpTargetId: zod_1.default.string().optional(),
|
|
236
|
+
profileTemplatePath: zod_1.default.string().optional()
|
|
235
237
|
});
|
|
236
238
|
exports2.runApiRunOptionsSchema = zod_1.default.discriminatedUnion("environment", [
|
|
237
239
|
exports2.runApiStandaloneRunOptionsSchema,
|
package/package.json
CHANGED