added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
export declare const STATIC_RETURNS: {
[type: string]: string;
};
export declare const INTRO_MESSAGE = "\nThe execution has stopped!\nYou can now go into the browser or use the command line as REPL\n(To exit, press ^C again or type .exit)\n";
export declare const DEFAULT_CONFIG: {
commandTimeout: number;
prompt: string;
useGlobal: boolean;
useColor: boolean;
};
//# sourceMappingURL=constants.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAKpD,CAAA;AAED,eAAO,MAAM,aAAa,6IAIzB,CAAA;AAED,eAAO,MAAM,cAAc;;;;;CAK1B,CAAA"}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CONFIG = exports.INTRO_MESSAGE = exports.STATIC_RETURNS = void 0;
exports.STATIC_RETURNS = {
driver: '[WebdriverIO REPL client]',
browser: '[WebdriverIO REPL client]',
$: '[Function: findElement]',
$$: '[Function: findElements]'
};
exports.INTRO_MESSAGE = `
The execution has stopped!
You can now go into the browser or use the command line as REPL
(To exit, press ^C again or type .exit)
`;
exports.DEFAULT_CONFIG = {
commandTimeout: 5000,
prompt: '\u203A ',
useGlobal: true,
useColor: true
};
+23
View File
@@ -0,0 +1,23 @@
/// <reference types="node" />
import vm from 'vm';
import repl from 'repl';
export interface ReplConfig {
commandTimeout: number;
eval: repl.REPLEval;
prompt: string;
useGlobal: boolean;
useColor: boolean;
}
export declare type ReplCallback = (err: Error | null, result: any) => void;
export default class WDIORepl {
static introMessage: string;
private _config;
private _isCommandRunning;
private _replServer;
constructor(config?: ReplConfig);
eval(cmd: string, context: vm.Context, filename: string | undefined, callback: ReplCallback): void | Promise<any>;
private _runCmd;
private _handleResult;
start(context?: vm.Context): Promise<unknown>;
}
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAgCA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAMvB,MAAM,WAAW,UAAU;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CACpB;AAED,oBAAY,YAAY,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,MAAM,CAAC,YAAY,SAAgB;IACnC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,WAAW,CAA6B;gBAEpC,MAAM,CAAC,EAAE,UAAU;IAQ/B,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,YAAY;IAqB5F,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,aAAa;IA2CrB,KAAK,CAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO;CAkB9B"}
+86
View File
@@ -0,0 +1,86 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vm_1 = __importDefault(require("vm"));
const repl_1 = __importDefault(require("repl"));
const utils_1 = require("@wdio/utils");
const constants_1 = require("./constants");
class WDIORepl {
constructor(config) {
this._isCommandRunning = false;
this._config = Object.assign(constants_1.DEFAULT_CONFIG, { eval: this.eval.bind(this) }, config);
}
eval(cmd, context, filename, callback) {
if (this._isCommandRunning) {
return;
}
if (cmd && constants_1.STATIC_RETURNS[cmd.trim()]) {
return callback(null, constants_1.STATIC_RETURNS[cmd.trim()]);
}
vm_1.default.createContext(context);
this._isCommandRunning = true;
if (utils_1.hasWdioSyncSupport) {
return utils_1.runFnInFiberContext(() => this._runCmd(cmd, context, callback))();
}
return this._runCmd(cmd, context, callback);
}
_runCmd(cmd, context, callback) {
try {
const result = vm_1.default.runInContext(cmd, context);
return this._handleResult(result, callback);
}
catch (e) {
this._isCommandRunning = false;
return callback(e, undefined);
}
}
_handleResult(result, callback) {
if (!result || typeof result.then !== 'function') {
this._isCommandRunning = false;
return callback(null, result);
}
let timeoutCalled = false;
const timeout = setTimeout(() => {
callback(new Error('Command execution timed out'), undefined);
this._isCommandRunning = false;
timeoutCalled = true;
}, this._config.commandTimeout);
result.then((res) => {
if (timeoutCalled) {
return;
}
this._isCommandRunning = false;
clearTimeout(timeout);
return callback(null, res);
}, (e) => {
if (timeoutCalled) {
return;
}
this._isCommandRunning = false;
clearTimeout(timeout);
const errorMessage = e ? e.message : 'Command execution timed out';
const commandError = new Error(errorMessage);
delete commandError.stack;
return callback(commandError, undefined);
});
}
start(context) {
if (this._replServer) {
throw new Error('a repl was already initialised');
}
if (context) {
const evalFn = this._config.eval;
this._config.eval = function (cmd, _, filename, callback) {
return evalFn.call(this, cmd, context, filename, callback);
};
}
this._replServer = repl_1.default.start(this._config);
return new Promise((resolve) => {
return this._replServer.on('exit', resolve);
});
}
}
exports.default = WDIORepl;
WDIORepl.introMessage = constants_1.INTRO_MESSAGE;