@intuned/runtime-dev 1.2.1-hooks.0 → 1.2.1-hooks.1
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.
|
@@ -33,10 +33,14 @@ async function createUserDirWithPreferences() {
|
|
|
33
33
|
await (0, _fsExtra.writeFile)((0, _path.join)(defaultDir, "Preferences"), JSON.stringify(preferences));
|
|
34
34
|
return userDir;
|
|
35
35
|
}
|
|
36
|
-
async function
|
|
37
|
-
const result = await importFunction("hooks/
|
|
36
|
+
async function loadInitializeContextHook(importFunction) {
|
|
37
|
+
const result = await importFunction("hooks/initializeContext");
|
|
38
38
|
if (result.isErr()) {
|
|
39
|
-
|
|
39
|
+
if (result.error.type === "not_found") {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
console.error("Error loading initializeBrowser hook");
|
|
43
|
+
throw result.error.error;
|
|
40
44
|
}
|
|
41
45
|
return result.value.default;
|
|
42
46
|
}
|
|
@@ -51,13 +55,14 @@ async function getProductionPlaywrightConstructs({
|
|
|
51
55
|
let page;
|
|
52
56
|
let hook = null;
|
|
53
57
|
if (importFunction) {
|
|
54
|
-
hook = await
|
|
58
|
+
hook = await loadInitializeContextHook(importFunction);
|
|
55
59
|
}
|
|
56
60
|
if (hook) {
|
|
57
61
|
({
|
|
58
62
|
page,
|
|
59
63
|
context
|
|
60
64
|
} = await hook({
|
|
65
|
+
type: "launch",
|
|
61
66
|
proxy,
|
|
62
67
|
headless
|
|
63
68
|
}));
|
|
@@ -108,27 +113,23 @@ async function getProductionPlaywrightConstructs({
|
|
|
108
113
|
context
|
|
109
114
|
};
|
|
110
115
|
}
|
|
111
|
-
async function loadGetIDEPageAndContextHook(importFunction) {
|
|
112
|
-
const result = await importFunction("hooks/createDeployedContextAndPage");
|
|
113
|
-
if (result.isErr()) {
|
|
114
|
-
throw result.error;
|
|
115
|
-
}
|
|
116
|
-
return result.value.default;
|
|
117
|
-
}
|
|
118
116
|
async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession, importFunction) {
|
|
119
117
|
let hook = null;
|
|
120
118
|
if (importFunction) {
|
|
121
|
-
hook = await
|
|
119
|
+
hook = await loadInitializeContextHook(importFunction);
|
|
122
120
|
}
|
|
123
121
|
if (mode == "playwright-standalone") {
|
|
124
122
|
if (!cdpAddress) {
|
|
125
123
|
throw new Error("cdpAddress is required");
|
|
126
124
|
}
|
|
127
125
|
let context;
|
|
126
|
+
let page = null;
|
|
128
127
|
if (hook) {
|
|
129
128
|
({
|
|
130
|
-
context
|
|
129
|
+
context,
|
|
130
|
+
page
|
|
131
131
|
} = await hook({
|
|
132
|
+
type: "cdp",
|
|
132
133
|
cdpAddress
|
|
133
134
|
}));
|
|
134
135
|
} else {
|
|
@@ -143,14 +144,15 @@ async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession, imp
|
|
|
143
144
|
await context.addInitScript({
|
|
144
145
|
path: assetsFile
|
|
145
146
|
});
|
|
146
|
-
const pages =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
const pages = context.pages();
|
|
148
|
+
if (!page) {
|
|
149
|
+
if (pages.length > 0) {
|
|
150
|
+
page = pages[0];
|
|
151
|
+
const scriptString = await fs.readFile(assetsFile, "utf8");
|
|
152
|
+
await page.evaluate(scriptString);
|
|
153
|
+
} else {
|
|
154
|
+
page = await context.newPage();
|
|
155
|
+
}
|
|
154
156
|
}
|
|
155
157
|
if (authSession) {
|
|
156
158
|
await loadSessionToContext({
|