@intuned/runtime-dev 0.1.0-test.22 → 0.1.0-test.24

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.
@@ -1 +1 @@
1
- export declare function tsNodeImport(apiFilePath: string): Promise<any>;
1
+ export declare function tsNodeImport(apiName: string): Promise<any>;
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.tsNodeImport = tsNodeImport;
7
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
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
- async function tsNodeImport(apiFilePath) {
9
+ async function tsNodeImport(apiName) {
10
10
  require("ts-node").register({
11
11
  transpileOnly: true,
12
12
  compilerOptions: {
13
13
  lib: ["dom", "es2020"]
14
14
  }
15
15
  });
16
- const imported = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(apiFilePath);
17
- return imported.default;
16
+ const imported = await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`./${apiName}.ts`);
17
+ return imported;
18
18
  }
@@ -87,6 +87,26 @@ async function* runApiGenerator({
87
87
  page,
88
88
  context
89
89
  } = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth === null || auth === void 0 ? void 0 : auth.session));
90
+ let isPageStable = false;
91
+ let retry = 0;
92
+ while (!isPageStable && retry < 10) {
93
+ try {
94
+ await page.locator("html").all();
95
+ isPageStable = true;
96
+ break;
97
+ } catch (error) {
98
+ var _error$message;
99
+ if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes("Execution context was destroyed")) {
100
+ await new Promise(resolve => setTimeout(resolve, 200));
101
+ } else {
102
+ throw error;
103
+ }
104
+ }
105
+ retry++;
106
+ }
107
+ if (!isPageStable) {
108
+ return (0, _neverthrow.err)(new _errors.AutomationError("The page is not stable, try to run again"));
109
+ }
90
110
  }
91
111
  const executionContext = (0, _asyncLocalStorage.getExecutionContext)();
92
112
  if (!executionContext) {
@@ -230,7 +250,7 @@ async function checkAuthSessionWithRetries(page, context, importFunction, retrie
230
250
  }
231
251
  async function importUsingImportFunction(path, importFunction) {
232
252
  try {
233
- const imported = importFunction ? await importFunction(path) : await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(path);
253
+ const imported = importFunction ? await importFunction(path) : await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`./${path}.ts`);
234
254
  if (!imported || !imported.default || !imported.default.constructor) {
235
255
  return (0, _neverthrow.err)(new _errors.InvalidApiError("API file path does not have a default export"));
236
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "0.1.0-test.22",
3
+ "version": "0.1.0-test.24",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -94,7 +94,8 @@
94
94
  "typescript": "^5.1.6",
95
95
  "wait-on": "^7.2.0",
96
96
  "zod": "^3.21.4",
97
- "zod-validation-error": "^3.0.3"
97
+ "zod-validation-error": "^3.0.3",
98
+ "ts-node": "^10.9.1"
98
99
  },
99
100
  "devDependencies": {
100
101
  "@babel/cli": "^7.23.4",