@intuned/runtime-dev 0.1.0-test.7 → 0.1.0-test.8
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/.babelrc +2 -0
- package/Intuned.json +1 -1
- package/api/test2.ts +1 -4
- package/dist/commands/common/getDefaultExportFromFile.js +1 -3
- package/dist/common/getPlaywrightConstructs.js +1 -1
- package/dist/common/runApi/index.js +6 -6
- package/package.json +3 -1
- package/preserve-dynamic-imports.js +16 -0
package/.babelrc
CHANGED
package/Intuned.json
CHANGED
package/api/test2.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
2
|
import { extendTimeout } from "../src/runtime/extendTimeout";
|
|
3
|
-
import { requestOTP } from "../src/runtime/requestMoreInfo";
|
|
4
3
|
|
|
5
|
-
export default async function
|
|
4
|
+
export default async function test2(
|
|
6
5
|
{ n }: { n?: number },
|
|
7
6
|
page: Page,
|
|
8
7
|
context: BrowserContext
|
|
@@ -10,8 +9,6 @@ export default async function* test2(
|
|
|
10
9
|
await page.goto("https://wikipedia.org/");
|
|
11
10
|
await page.waitForTimeout(1000);
|
|
12
11
|
|
|
13
|
-
yield requestOTP("Please enter the OTP");
|
|
14
|
-
|
|
15
12
|
const titles: string[] = [];
|
|
16
13
|
|
|
17
14
|
for (let i = 0; i < (n ?? 2); i++) {
|
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDefaultExportFromFile = getDefaultExportFromFile;
|
|
7
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
7
|
async function getDefaultExportFromFile(apiFilePath) {
|
|
10
8
|
require("ts-node").register({
|
|
11
9
|
transpileOnly: true,
|
|
@@ -13,7 +11,7 @@ async function getDefaultExportFromFile(apiFilePath) {
|
|
|
13
11
|
lib: ["dom", "es2020"]
|
|
14
12
|
}
|
|
15
13
|
});
|
|
16
|
-
const imported = await
|
|
14
|
+
const imported = await Promise.resolve(require(apiFilePath));
|
|
17
15
|
const defaultExport = imported.default;
|
|
18
16
|
return defaultExport;
|
|
19
17
|
}
|
|
@@ -159,7 +159,7 @@ async function loadSessionToContext({
|
|
|
159
159
|
await (0, _contextStorageStateHelpers.setContextStorageState)(context, sessionToLoad);
|
|
160
160
|
}
|
|
161
161
|
async function getRemotePlaywrightContext(cdpAddress) {
|
|
162
|
-
const playwright = await Promise.resolve(
|
|
162
|
+
const playwright = await Promise.resolve(require("@intuned/playwright-core"));
|
|
163
163
|
let browser = null;
|
|
164
164
|
if (!cdpAddress) {
|
|
165
165
|
throw new Error("cdpAddress is required");
|
|
@@ -239,22 +239,22 @@ async function importFunction(path) {
|
|
|
239
239
|
let imported = undefined;
|
|
240
240
|
switch (functionNameDepth) {
|
|
241
241
|
case 1:
|
|
242
|
-
imported = await
|
|
242
|
+
imported = await Promise.resolve(require(`../../../${functionNameParts[0]}.ts`));
|
|
243
243
|
break;
|
|
244
244
|
case 2:
|
|
245
|
-
imported = await
|
|
245
|
+
imported = await Promise.resolve(require(`../../../${functionNameParts[0]}/${functionNameParts[1]}.ts`));
|
|
246
246
|
break;
|
|
247
247
|
case 3:
|
|
248
|
-
imported = await
|
|
248
|
+
imported = await Promise.resolve(require(`../../../${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}.ts`));
|
|
249
249
|
break;
|
|
250
250
|
case 4:
|
|
251
|
-
imported = await
|
|
251
|
+
imported = await Promise.resolve(require(`../../../${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}.ts`));
|
|
252
252
|
break;
|
|
253
253
|
case 5:
|
|
254
|
-
imported = await
|
|
254
|
+
imported = await Promise.resolve(require(`../../../${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}.ts`));
|
|
255
255
|
break;
|
|
256
256
|
case 6:
|
|
257
|
-
imported = await
|
|
257
|
+
imported = await Promise.resolve(require(`../../../${functionNameParts[0]}/${functionNameParts[1]}/${functionNameParts[2]}/${functionNameParts[3]}/${functionNameParts[4]}/${functionNameParts[5]}.ts`));
|
|
258
258
|
break;
|
|
259
259
|
default:
|
|
260
260
|
return (0, _neverthrow.err)(new _errors.MaxLevelsExceededError(5));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "0.1.0-test.
|
|
3
|
+
"version": "0.1.0-test.8",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"intuned-ts-check": "./bin/intuned-ts-check"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
54
55
|
"@intuned/playwright": "^1.44.1-4",
|
|
55
56
|
"@intuned/playwright-core": "^1.44.1-4",
|
|
56
57
|
"@rollup/plugin-commonjs": "^25.0.2",
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"@types/node": "^20.4.1",
|
|
66
67
|
"applicationinsights": "^2.9.2",
|
|
67
68
|
"async-retry": "^1.3.3",
|
|
69
|
+
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
68
70
|
"chalk": "^4.1.2",
|
|
69
71
|
"commander": "^11.0.0",
|
|
70
72
|
"cross-fetch": "^4.0.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = function ({ template }) {
|
|
2
|
+
return {
|
|
3
|
+
visitor: {
|
|
4
|
+
CallExpression(path) {
|
|
5
|
+
if (path.node.callee.type === "Import") {
|
|
6
|
+
const buildRequire = template(`Promise.resolve(require(ARGUMENT))`);
|
|
7
|
+
path.replaceWith(
|
|
8
|
+
buildRequire({
|
|
9
|
+
ARGUMENT: path.node.arguments[0],
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|