askui 0.1.6 → 0.2.2
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/README.md +6 -0
- package/bin/askui-postinstall +35 -0
- package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +2 -2
- package/dist/cjs/core/model/test-case-dto/custom-element.js +2 -2
- package/dist/cjs/core/model/test-case-dto/custom-element.spec.js +7 -6
- package/dist/cjs/core/model/test-case-dto/index.js +1 -3
- package/dist/cjs/core/model/test-case-dto/test-step.d.ts +3 -7
- package/dist/cjs/core/model/test-case-dto/test-step.js +0 -12
- package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -0
- package/dist/cjs/core/ui-control-commands/control-command.js +5 -0
- package/dist/cjs/core/ui-control-commands/input-event.d.ts +1 -2
- package/dist/cjs/core/ui-control-commands/input-event.js +0 -1
- package/dist/cjs/execution/dsl.d.ts +6 -17
- package/dist/cjs/execution/dsl.js +4 -21
- package/dist/cjs/execution/execution-runtime.d.ts +7 -5
- package/dist/cjs/execution/execution-runtime.js +35 -23
- package/dist/cjs/execution/index.d.ts +2 -1
- package/dist/cjs/execution/index.js +5 -3
- package/dist/cjs/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +4 -4
- package/dist/cjs/execution/{control-your-ui-api.js → inference-client.js} +9 -9
- package/dist/cjs/execution/ui-control-client-error.d.ts +2 -0
- package/dist/cjs/execution/ui-control-client-error.js +6 -0
- package/dist/cjs/execution/ui-control-client.d.ts +79 -0
- package/dist/cjs/execution/ui-control-client.js +185 -0
- package/dist/cjs/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
- package/dist/cjs/execution/ui-controller-client-connection-state.js +10 -0
- package/dist/cjs/execution/ui-controller-client-interface.d.ts +27 -0
- package/dist/cjs/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
- package/dist/cjs/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
- package/dist/cjs/execution/{control-your-ui-client.js → ui-controller-client.js} +28 -28
- package/dist/cjs/lib/copy-example-project.js +2 -1
- package/dist/cjs/lib/download-binaries.js +10 -9
- package/dist/cjs/lib/index.d.ts +1 -1
- package/dist/cjs/lib/index.js +3 -3
- package/dist/cjs/lib/libfuse-error.d.ts +2 -0
- package/dist/cjs/lib/libfuse-error.js +6 -0
- package/dist/cjs/lib/logger.js +1 -1
- package/dist/cjs/lib/timeout-error.d.ts +0 -2
- package/dist/cjs/lib/timeout-error.js +0 -5
- package/dist/cjs/lib/ui-controller-args.d.ts +47 -0
- package/dist/cjs/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
- package/dist/cjs/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
- package/dist/cjs/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +7 -7
- package/dist/cjs/lib/ui-controller-darwin.d.ts +6 -0
- package/dist/cjs/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +8 -8
- package/dist/cjs/lib/ui-controller-facade.d.ts +17 -0
- package/dist/cjs/lib/{control-ui-server-facade.js → ui-controller-facade.js} +22 -16
- package/dist/cjs/lib/ui-controller-linux.d.ts +5 -0
- package/dist/cjs/lib/ui-controller-linux.js +52 -0
- package/dist/cjs/lib/ui-controller-win32.d.ts +3 -0
- package/dist/cjs/lib/ui-controller-win32.js +7 -0
- package/dist/cjs/lib/ui-controller.d.ts +8 -0
- package/dist/cjs/lib/{askui-control-server.js → ui-controller.js} +9 -9
- package/dist/cjs/lib/unkown-error.d.ts +0 -2
- package/dist/cjs/lib/unkown-error.js +0 -5
- package/dist/cjs/lib/wayland-error.d.ts +2 -0
- package/dist/cjs/lib/wayland-error.js +6 -0
- package/dist/cjs/main.d.ts +3 -2
- package/dist/cjs/main.js +6 -3
- package/dist/cjs/shared/index.d.ts +1 -0
- package/dist/cjs/shared/index.js +5 -0
- package/dist/cjs/utils/analytics/analytics-interface.d.ts +3 -0
- package/dist/cjs/utils/analytics/analytics-interface.js +2 -0
- package/dist/cjs/utils/analytics/analytics.d.ts +5 -0
- package/dist/cjs/utils/analytics/analytics.js +38 -0
- package/dist/cjs/utils/analytics/index.d.ts +1 -0
- package/dist/cjs/utils/analytics/index.js +5 -0
- package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
- package/dist/cjs/utils/analytics/installation-timestamp-create-error.js +9 -0
- package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
- package/dist/cjs/utils/analytics/installation-timestamp-get-error.js +9 -0
- package/dist/cjs/utils/analytics/installation-timestamp.d.ts +7 -0
- package/dist/cjs/utils/analytics/installation-timestamp.js +68 -0
- package/dist/cjs/utils/analytics/user-identifier-interface.d.ts +3 -0
- package/dist/cjs/utils/analytics/user-identifier-interface.js +2 -0
- package/dist/cjs/utils/analytics/user-identifier.d.ts +4 -0
- package/dist/cjs/utils/analytics/user-identifier.js +22 -0
- package/dist/cjs/utils/base_64_image/base-64-image-error.d.ts +2 -0
- package/dist/cjs/utils/base_64_image/base-64-image-error.js +6 -0
- package/dist/cjs/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
- package/dist/cjs/utils/base_64_image/base-64-image-string-error.js +11 -0
- package/dist/cjs/utils/base_64_image/base-64-image.d.ts +18 -0
- package/dist/cjs/utils/base_64_image/base-64-image.js +86 -0
- package/dist/cjs/utils/http/custom-errors/http-client-error.d.ts +0 -2
- package/dist/cjs/utils/http/custom-errors/http-client-error.js +0 -5
- package/dist/cjs/utils/http/http-client-got.d.ts +6 -5
- package/dist/cjs/utils/http/http-client-got.js +11 -11
- package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
- package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js +0 -5
- package/dist/cjs/utils/image-resize-errors/index.d.ts +0 -1
- package/dist/cjs/utils/image-resize-errors/index.js +1 -3
- package/dist/cjs/utils/path.d.ts +1 -0
- package/dist/cjs/utils/path.js +11 -0
- package/dist/cjs/utils/transformations.d.ts +0 -2
- package/dist/cjs/utils/transformations.js +11 -44
- package/dist/esm/core/model/test-case-dto/custom-element.d.ts +2 -2
- package/dist/esm/core/model/test-case-dto/custom-element.js +2 -2
- package/dist/esm/core/model/test-case-dto/custom-element.spec.js +7 -6
- package/dist/esm/core/model/test-case-dto/index.js +0 -1
- package/dist/esm/core/model/test-case-dto/test-step.d.ts +3 -7
- package/dist/esm/core/model/test-case-dto/test-step.js +1 -10
- package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -0
- package/dist/esm/core/ui-control-commands/control-command.js +5 -0
- package/dist/esm/core/ui-control-commands/input-event.d.ts +1 -2
- package/dist/esm/core/ui-control-commands/input-event.js +0 -1
- package/dist/esm/execution/dsl.d.ts +6 -17
- package/dist/esm/execution/dsl.js +3 -21
- package/dist/esm/execution/execution-runtime.d.ts +7 -5
- package/dist/esm/execution/execution-runtime.js +35 -23
- package/dist/esm/execution/index.d.ts +2 -1
- package/dist/esm/execution/index.js +2 -1
- package/dist/esm/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +4 -4
- package/dist/esm/execution/{control-your-ui-api.js → inference-client.js} +7 -7
- package/dist/esm/execution/ui-control-client-error.d.ts +2 -0
- package/dist/esm/execution/ui-control-client-error.js +2 -0
- package/dist/esm/execution/ui-control-client.d.ts +79 -0
- package/dist/esm/execution/ui-control-client.js +181 -0
- package/dist/esm/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
- package/dist/esm/execution/ui-controller-client-connection-state.js +7 -0
- package/dist/esm/execution/ui-controller-client-interface.d.ts +27 -0
- package/dist/esm/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
- package/dist/esm/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
- package/dist/esm/execution/{control-your-ui-client.js → ui-controller-client.js} +26 -26
- package/dist/esm/lib/copy-example-project.js +2 -1
- package/dist/esm/lib/download-binaries.js +10 -9
- package/dist/esm/lib/index.d.ts +1 -1
- package/dist/esm/lib/index.js +1 -1
- package/dist/esm/lib/libfuse-error.d.ts +2 -0
- package/dist/esm/lib/libfuse-error.js +2 -0
- package/dist/esm/lib/logger.js +1 -1
- package/dist/esm/lib/timeout-error.d.ts +0 -2
- package/dist/esm/lib/timeout-error.js +0 -5
- package/dist/esm/lib/ui-controller-args.d.ts +47 -0
- package/dist/esm/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
- package/dist/esm/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
- package/dist/esm/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +1 -1
- package/dist/esm/lib/ui-controller-darwin.d.ts +6 -0
- package/dist/esm/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +6 -6
- package/dist/esm/lib/ui-controller-facade.d.ts +17 -0
- package/dist/esm/lib/{control-ui-server-facade.js → ui-controller-facade.js} +17 -11
- package/dist/esm/lib/ui-controller-linux.d.ts +5 -0
- package/dist/esm/lib/ui-controller-linux.js +48 -0
- package/dist/esm/lib/ui-controller-win32.d.ts +3 -0
- package/dist/esm/lib/ui-controller-win32.js +3 -0
- package/dist/esm/lib/ui-controller.d.ts +8 -0
- package/dist/esm/lib/{askui-control-server.js → ui-controller.js} +7 -7
- package/dist/esm/lib/unkown-error.d.ts +0 -2
- package/dist/esm/lib/unkown-error.js +0 -5
- package/dist/esm/lib/wayland-error.d.ts +2 -0
- package/dist/esm/lib/wayland-error.js +2 -0
- package/dist/esm/main.d.ts +3 -2
- package/dist/esm/main.js +3 -2
- package/dist/esm/shared/index.d.ts +1 -0
- package/dist/esm/shared/index.js +1 -0
- package/dist/esm/utils/analytics/analytics-interface.d.ts +3 -0
- package/dist/esm/utils/analytics/analytics-interface.js +1 -0
- package/dist/esm/utils/analytics/analytics.d.ts +5 -0
- package/dist/esm/utils/analytics/analytics.js +31 -0
- package/dist/esm/utils/analytics/index.d.ts +1 -0
- package/dist/esm/utils/analytics/index.js +1 -0
- package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
- package/dist/esm/utils/analytics/installation-timestamp-create-error.js +5 -0
- package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
- package/dist/esm/utils/analytics/installation-timestamp-get-error.js +5 -0
- package/dist/esm/utils/analytics/installation-timestamp.d.ts +7 -0
- package/dist/esm/utils/analytics/installation-timestamp.js +61 -0
- package/dist/esm/utils/analytics/user-identifier-interface.d.ts +3 -0
- package/dist/esm/utils/analytics/user-identifier-interface.js +1 -0
- package/dist/esm/utils/analytics/user-identifier.d.ts +4 -0
- package/dist/esm/utils/analytics/user-identifier.js +18 -0
- package/dist/esm/utils/base_64_image/base-64-image-error.d.ts +2 -0
- package/dist/esm/utils/base_64_image/base-64-image-error.js +2 -0
- package/dist/esm/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
- package/dist/esm/utils/base_64_image/base-64-image-string-error.js +7 -0
- package/dist/esm/utils/base_64_image/base-64-image.d.ts +18 -0
- package/dist/esm/utils/base_64_image/base-64-image.js +79 -0
- package/dist/esm/utils/http/custom-errors/http-client-error.d.ts +0 -2
- package/dist/esm/utils/http/custom-errors/http-client-error.js +0 -5
- package/dist/esm/utils/http/http-client-got.d.ts +6 -5
- package/dist/esm/utils/http/http-client-got.js +11 -11
- package/dist/esm/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
- package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js +0 -5
- package/dist/esm/utils/image-resize-errors/index.d.ts +0 -1
- package/dist/esm/utils/image-resize-errors/index.js +0 -1
- package/dist/esm/utils/path.d.ts +1 -0
- package/dist/esm/utils/path.js +4 -0
- package/dist/esm/utils/transformations.d.ts +0 -2
- package/dist/esm/utils/transformations.js +11 -39
- package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +7 -7
- package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +3 -0
- package/package.json +15 -8
- package/dist/cjs/execution/client-connection-state.js +0 -10
- package/dist/cjs/execution/client-error.d.ts +0 -2
- package/dist/cjs/execution/client-error.js +0 -6
- package/dist/cjs/execution/client-interface.d.ts +0 -13
- package/dist/cjs/execution/client.d.ts +0 -25
- package/dist/cjs/execution/client.js +0 -116
- package/dist/cjs/lib/askui-control-server.d.ts +0 -8
- package/dist/cjs/lib/control-ui-server-args.d.ts +0 -21
- package/dist/cjs/lib/control-ui-server-darwin.d.ts +0 -6
- package/dist/cjs/lib/control-ui-server-facade.d.ts +0 -16
- package/dist/cjs/lib/control-ui-server-linux.d.ts +0 -4
- package/dist/cjs/lib/control-ui-server-linux.js +0 -13
- package/dist/cjs/lib/control-ui-server-win32.d.ts +0 -3
- package/dist/cjs/lib/control-ui-server-win32.js +0 -7
- package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
- package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.js +0 -7
- package/dist/esm/execution/client-connection-state.js +0 -7
- package/dist/esm/execution/client-error.d.ts +0 -2
- package/dist/esm/execution/client-error.js +0 -2
- package/dist/esm/execution/client-interface.d.ts +0 -13
- package/dist/esm/execution/client.d.ts +0 -25
- package/dist/esm/execution/client.js +0 -112
- package/dist/esm/lib/askui-control-server.d.ts +0 -8
- package/dist/esm/lib/control-ui-server-args.d.ts +0 -21
- package/dist/esm/lib/control-ui-server-darwin.d.ts +0 -6
- package/dist/esm/lib/control-ui-server-facade.d.ts +0 -16
- package/dist/esm/lib/control-ui-server-linux.d.ts +0 -4
- package/dist/esm/lib/control-ui-server-linux.js +0 -9
- package/dist/esm/lib/control-ui-server-win32.d.ts +0 -3
- package/dist/esm/lib/control-ui-server-win32.js +0 -3
- package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
- package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.js +0 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
2
|
import { CaptureScreenshotRequest, ControlRequest, StartRecordingRequest, StopRecordingRequest, ReadRecordingRequest, InteractiveAnnotationRequest, GetProcessPidRequest, } from '../core/runner-protocol';
|
|
3
3
|
import { logger } from '../lib/logger';
|
|
4
|
-
import {
|
|
4
|
+
import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
|
|
5
5
|
import { ReadRecordingResponseStreamHandler } from './read-recording-response-stream-handler';
|
|
6
|
-
import {
|
|
7
|
-
export class
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
10
|
-
this.connectionState =
|
|
11
|
-
this.currentReject =
|
|
12
|
-
this.currentResolve =
|
|
6
|
+
import { UiControlClientError } from './ui-control-client-error';
|
|
7
|
+
export class UiControllerClient {
|
|
8
|
+
constructor(url) {
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.connectionState = UiControllerClientConnectionState.NOT_CONNECTED;
|
|
11
|
+
this.currentReject = UiControllerClient.EMPTY_REJECT;
|
|
12
|
+
this.currentResolve = UiControllerClient.EMPTY_RESOLVE;
|
|
13
13
|
}
|
|
14
14
|
clearResponse() {
|
|
15
|
-
this.currentReject =
|
|
16
|
-
this.currentResolve =
|
|
15
|
+
this.currentReject = UiControllerClient.EMPTY_REJECT;
|
|
16
|
+
this.currentResolve = UiControllerClient.EMPTY_RESOLVE;
|
|
17
17
|
}
|
|
18
18
|
onMessage(data) {
|
|
19
19
|
clearTimeout(this.timeout);
|
|
@@ -30,24 +30,24 @@ export class ControlYourUiClient {
|
|
|
30
30
|
this.clearResponse();
|
|
31
31
|
}
|
|
32
32
|
connect() {
|
|
33
|
-
this.connectionState =
|
|
33
|
+
this.connectionState = UiControllerClientConnectionState.CONNECTING;
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
35
35
|
try {
|
|
36
|
-
this.ws = new WebSocket(this.
|
|
36
|
+
this.ws = new WebSocket(this.url);
|
|
37
37
|
this.ws.on('message', (data) => { this.onMessage(data); });
|
|
38
38
|
this.ws.on('open', () => {
|
|
39
|
-
this.connectionState =
|
|
39
|
+
this.connectionState = UiControllerClientConnectionState.CONNECTED;
|
|
40
40
|
resolve(this.connectionState);
|
|
41
41
|
});
|
|
42
42
|
this.ws.on('error', (error) => {
|
|
43
|
-
this.connectionState =
|
|
44
|
-
reject(new
|
|
45
|
-
Probably it was not started. Makse sure you started
|
|
46
|
-
Url ${this.
|
|
43
|
+
this.connectionState = UiControllerClientConnectionState.ERROR;
|
|
44
|
+
reject(new UiControlClientError(`Connection to UI Controller cannot be established,
|
|
45
|
+
Probably it was not started. Makse sure you started UI Controller with this
|
|
46
|
+
Url ${this.url}. Error message ${error.message}`));
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
50
|
-
reject(new
|
|
50
|
+
reject(new UiControlClientError(`Connection to UI Controller cannot be established. Reason: ${error}`));
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -55,21 +55,21 @@ export class ControlYourUiClient {
|
|
|
55
55
|
var _a;
|
|
56
56
|
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
57
57
|
}
|
|
58
|
-
sendAndReceive(msg, requestTimeout =
|
|
58
|
+
sendAndReceive(msg, requestTimeout = UiControllerClient.REQUEST_TIMEOUT_IN_MS) {
|
|
59
59
|
return new Promise((resolve, reject) => {
|
|
60
60
|
this.currentResolve = resolve;
|
|
61
61
|
this.currentReject = reject;
|
|
62
62
|
try {
|
|
63
63
|
this.send(msg, requestTimeout);
|
|
64
|
-
this.timeout = setTimeout(() => this.currentReject(`Request to
|
|
65
|
-
|
|
64
|
+
this.timeout = setTimeout(() => this.currentReject(`Request to UI Controller timed out.
|
|
65
|
+
It seems that the UI Controller is not running. Please, make sure that it is running when executing tests.`), UiControllerClient.REQUEST_TIMEOUT_IN_MS);
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
68
|
-
this.currentReject(`The communication to the
|
|
68
|
+
this.currentReject(`The communication to the UI Controller is broken. Reason: ${error}`);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
send(msg, _requestTimeout =
|
|
72
|
+
send(msg, _requestTimeout = UiControllerClient.REQUEST_TIMEOUT_IN_MS) {
|
|
73
73
|
if (!this.currentReject || !this.currentResolve) {
|
|
74
74
|
throw Error('Request is not finished! It is not possible to have multiple requests at the same time.');
|
|
75
75
|
}
|
|
@@ -107,6 +107,6 @@ export class ControlYourUiClient {
|
|
|
107
107
|
return this.sendAndReceive(new ControlRequest(controlCommand));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
UiControllerClient.EMPTY_REJECT = (_reason) => { };
|
|
111
|
+
UiControllerClient.EMPTY_RESOLVE = (_value) => { };
|
|
112
|
+
UiControllerClient.REQUEST_TIMEOUT_IN_MS = 30000;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
|
+
import { getPathToNodeModulesRoot } from '../utils/path';
|
|
4
5
|
const createProgram = () => {
|
|
5
6
|
const program = new Command('askui');
|
|
6
7
|
program.usage('<command> [options]');
|
|
@@ -8,7 +9,7 @@ const createProgram = () => {
|
|
|
8
9
|
};
|
|
9
10
|
function copyExampleProject() {
|
|
10
11
|
const exampleProjectPath = path.join('example_projects_templates', 'typescript_jest');
|
|
11
|
-
fs.copySync(path.join(
|
|
12
|
+
fs.copySync(path.join(getPathToNodeModulesRoot(), exampleProjectPath), '.');
|
|
12
13
|
}
|
|
13
14
|
export function init(argv) {
|
|
14
15
|
const args = argv || process.argv;
|
|
@@ -2,6 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import got from 'got';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import { getPathToNodeModulesRoot } from '../utils/path';
|
|
5
6
|
import { logger } from './logger';
|
|
6
7
|
var SupportedPlatform;
|
|
7
8
|
(function (SupportedPlatform) {
|
|
@@ -10,9 +11,9 @@ var SupportedPlatform;
|
|
|
10
11
|
SupportedPlatform["WIN32"] = "win32";
|
|
11
12
|
})(SupportedPlatform || (SupportedPlatform = {}));
|
|
12
13
|
const binarySubPathsByPlatform = {
|
|
13
|
-
linux: ['linux', '
|
|
14
|
-
darwin: ['darwin', '
|
|
15
|
-
win32: ['windows', '
|
|
14
|
+
linux: ['linux', 'askui-ui-controller.AppImage'],
|
|
15
|
+
darwin: ['darwin', 'askui-ui-controller.dmg'],
|
|
16
|
+
win32: ['windows', 'askui-ui-controller.exe'],
|
|
16
17
|
};
|
|
17
18
|
function isSupportedPlatform(value) {
|
|
18
19
|
return Object.values(SupportedPlatform).includes(value);
|
|
@@ -25,13 +26,13 @@ export function platform() {
|
|
|
25
26
|
throw new Error(`Platform "${pf}" is not supported.`);
|
|
26
27
|
}
|
|
27
28
|
function buildBinaryNotAvailbleError(binaryVersion) {
|
|
28
|
-
return new Error(`It seems that the
|
|
29
|
+
return new Error(`It seems that the UI Controller version "${binaryVersion}" for your system "${platform()} ${os.arch}" is not availble, Please contact as at info@askui.com for more information`);
|
|
29
30
|
}
|
|
30
31
|
export function getBinaryPath(version) {
|
|
31
|
-
return path.join(
|
|
32
|
+
return path.join(getPathToNodeModulesRoot(), 'release', version, ...binarySubPathsByPlatform[platform()]);
|
|
32
33
|
}
|
|
33
34
|
function getBinaryDownloadUrl(binaryVersion) {
|
|
34
|
-
const baseUrl = `https://askui-public.s3.eu-central-1.amazonaws.com/releases/
|
|
35
|
+
const baseUrl = `https://askui-public.s3.eu-central-1.amazonaws.com/releases/askui-ui-controller/${binaryVersion}`;
|
|
35
36
|
const arch = os.arch();
|
|
36
37
|
return `${baseUrl}/${platform()}/${arch}/${binarySubPathsByPlatform[platform()][1]}`;
|
|
37
38
|
}
|
|
@@ -40,7 +41,7 @@ export function downloadServerBinaries(binaryVersion) {
|
|
|
40
41
|
const url = getBinaryDownloadUrl(binaryVersion);
|
|
41
42
|
const binaryOutputPath = getBinaryPath(binaryVersion);
|
|
42
43
|
const binaryFolder = path.dirname(binaryOutputPath);
|
|
43
|
-
logger.info(`Start downloading
|
|
44
|
+
logger.info(`Start downloading UI Controller version "${binaryVersion}"`);
|
|
44
45
|
if (!(fs.existsSync(binaryFolder))) {
|
|
45
46
|
fs.mkdirSync(binaryFolder, { recursive: true });
|
|
46
47
|
}
|
|
@@ -57,8 +58,8 @@ export function downloadServerBinaries(binaryVersion) {
|
|
|
57
58
|
reject(new Error('oops, an error during the downloaded occurred, try again with fresh install'));
|
|
58
59
|
})
|
|
59
60
|
.on('finish', () => {
|
|
60
|
-
logger.info(`
|
|
61
|
-
logger.debug(`Binary of
|
|
61
|
+
logger.info(`UI Controller version ${binaryVersion} for your system "${platform()} ${os.arch}" was downloaded`);
|
|
62
|
+
logger.debug(`Binary of UI Controller is located at "${binaryOutputPath}".`);
|
|
62
63
|
resolve();
|
|
63
64
|
});
|
|
64
65
|
downloadStream.pipe(fileWriterStream);
|
package/dist/esm/lib/index.d.ts
CHANGED
package/dist/esm/lib/index.js
CHANGED
package/dist/esm/lib/logger.js
CHANGED
|
@@ -17,7 +17,7 @@ const stream = pretty({
|
|
|
17
17
|
const defaultLogLevel = 'info';
|
|
18
18
|
const pinoLevel = isProcessEnvLogLevelValid() ? process.env['LOG_LEVEL'] : defaultLogLevel;
|
|
19
19
|
const logger = pino({
|
|
20
|
-
name: '
|
|
20
|
+
name: 'askuiUiControlClient',
|
|
21
21
|
level: pinoLevel,
|
|
22
22
|
customLevels: {
|
|
23
23
|
verbose: 5,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LogLevels } from '../shared/log-levels';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the askui UI Controller
|
|
4
|
+
*
|
|
5
|
+
* @param {number} display - Default: `0`
|
|
6
|
+
* You can choose on which display you want to excecute all tests.
|
|
7
|
+
* 0 is your main monitor.
|
|
8
|
+
* If you want to use your second monitor you can change
|
|
9
|
+
* the value to `1` (`2` for your third monitor etc.).
|
|
10
|
+
* @param {string} binaryVersion - Default: `'latest'`
|
|
11
|
+
* Choose the version of the askui UI Controller Server.
|
|
12
|
+
* @param {number} port - Default: `6769`
|
|
13
|
+
* The port the askui UI Controller is running on.
|
|
14
|
+
* @param {string} host - Default: `'127.0.0.1'`
|
|
15
|
+
* The host the askui UI Controller is running on.
|
|
16
|
+
* @param {boolean} minimize - Default: `true`
|
|
17
|
+
* askui UI Controller will be started as minimized window.
|
|
18
|
+
* @param {boolean} overWriteBinary - Default: `false`
|
|
19
|
+
* Download the provided Version of askui UI Controller.
|
|
20
|
+
* If a version is already downloaded. This version will be overwritten
|
|
21
|
+
* @param {LogLevels} logLevel - Default: `'debug'`
|
|
22
|
+
* You can use different types of Log Level.
|
|
23
|
+
* Options: "fatal", "error", "warn", "info", "debug", "trace", "silent", "verbose".
|
|
24
|
+
* @param {string} logFilePath - Default: `'<temp-dir>/askui/askui-server.log'`
|
|
25
|
+
* It is possible to specify a path for your log files.
|
|
26
|
+
* Per default we create the askui-server.log file and askui folder in your temp folder.
|
|
27
|
+
*/
|
|
28
|
+
export interface UiControllerArgs {
|
|
29
|
+
readonly display?: number;
|
|
30
|
+
readonly binaryVersion?: string;
|
|
31
|
+
readonly port?: number;
|
|
32
|
+
readonly host?: string;
|
|
33
|
+
readonly minimize?: boolean;
|
|
34
|
+
readonly overWriteBinary?: boolean;
|
|
35
|
+
readonly logLevel?: LogLevels;
|
|
36
|
+
readonly logFilePath?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface UiControllerArgsWithDefaults extends UiControllerArgs {
|
|
39
|
+
readonly display: number;
|
|
40
|
+
readonly binaryVersion: string;
|
|
41
|
+
readonly overWriteBinary: boolean;
|
|
42
|
+
readonly port: number;
|
|
43
|
+
readonly host: string;
|
|
44
|
+
readonly logLevel?: LogLevels;
|
|
45
|
+
}
|
|
46
|
+
export declare function createArgsWithDefaults(args?: UiControllerArgs): UiControllerArgsWithDefaults;
|
|
47
|
+
export declare function createCliFlagsFromArgs(args: UiControllerArgsWithDefaults): string[];
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createArgsWithDefaults, createCliFlagsFromArgs } from './
|
|
1
|
+
import { createArgsWithDefaults, createCliFlagsFromArgs } from './ui-controller-args';
|
|
2
2
|
describe('createCliFlagsFromArgs()', () => {
|
|
3
3
|
test('test createCliFlagsFromArgs should return -d 0 as default output', () => {
|
|
4
4
|
const expected = ['-d 0', '-p 6769', '--host 127.0.0.1', '-m ', '--log-level debug'];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { exec, execSync } from 'child_process';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import {
|
|
4
|
+
import { UiControllerFacade } from './ui-controller-facade';
|
|
5
5
|
import { logger } from './logger';
|
|
6
|
-
export class
|
|
6
|
+
export class UiControllerDarwin extends UiControllerFacade {
|
|
7
7
|
makeBinaryExecutable() {
|
|
8
8
|
this.makeDiskImageExecutable();
|
|
9
9
|
}
|
|
10
10
|
getStartingCommand() {
|
|
11
|
-
return
|
|
11
|
+
return `"${path.dirname(this.binaryPath)}/controlui-server.app/Contents/MacOS/controlui-server"`;
|
|
12
12
|
}
|
|
13
13
|
makeDiskImageExecutable() {
|
|
14
14
|
const mountPoint = '/Volumes/controlui-server.dmg';
|
|
@@ -18,14 +18,14 @@ export class ControlUiServerDarwin extends ControlUiServerFacade {
|
|
|
18
18
|
'-quiet',
|
|
19
19
|
'-noautofsck',
|
|
20
20
|
'-noautoopen',
|
|
21
|
-
`-mountpoint ${mountPoint}`,
|
|
22
|
-
this.binaryPath
|
|
21
|
+
`-mountpoint "${mountPoint}"`,
|
|
22
|
+
`"${this.binaryPath}"`,
|
|
23
23
|
].join(' '));
|
|
24
24
|
const appBaseName = 'controlui-server.app';
|
|
25
25
|
const appSrcPath = `${mountPoint}/${appBaseName}`;
|
|
26
26
|
const appDestPath = `${path.dirname(this.binaryPath)}/${appBaseName}`;
|
|
27
27
|
fs.removeSync(appDestPath);
|
|
28
28
|
fs.copySync(appSrcPath, appDestPath);
|
|
29
|
-
exec(`hdiutil detach ${mountPoint}`, (_exception, stdout) => logger.debug(stdout));
|
|
29
|
+
exec(`hdiutil detach "${mountPoint}"`, (_exception, stdout) => logger.debug(stdout));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UiControllerArgs, UiControllerArgsWithDefaults } from './ui-controller-args';
|
|
2
|
+
export declare abstract class UiControllerFacade {
|
|
3
|
+
protected binaryPath: string;
|
|
4
|
+
protected serverLogFile: string;
|
|
5
|
+
protected readonly DefaultmaxWaitingForStartingInMs: number;
|
|
6
|
+
start(args?: UiControllerArgs, maxWaitingForStartingInSeconds?: number): Promise<void>;
|
|
7
|
+
stop(args?: UiControllerArgs, forceStop?: boolean): Promise<void>;
|
|
8
|
+
protected serverLogFilePath(args?: UiControllerArgsWithDefaults): UiControllerArgsWithDefaults;
|
|
9
|
+
protected killPort(port: number, forceStop?: boolean): Promise<void>;
|
|
10
|
+
protected getStartingCommand(): string;
|
|
11
|
+
protected makeBinaryExecutable(): void;
|
|
12
|
+
protected runPreStartChecks(): Promise<void>;
|
|
13
|
+
protected waitUntilStarted(args: UiControllerArgsWithDefaults, maxWaitingForStartingInSeconds?: number): Promise<void>;
|
|
14
|
+
private isBinaryValid;
|
|
15
|
+
private getBinary;
|
|
16
|
+
private startWithDefaults;
|
|
17
|
+
}
|
|
@@ -13,24 +13,25 @@ import waitPort from 'wait-port';
|
|
|
13
13
|
import fkill from 'fkill';
|
|
14
14
|
import os from 'os';
|
|
15
15
|
import path from 'path';
|
|
16
|
-
import { createArgsWithDefaults, createCliFlagsFromArgs, } from './
|
|
16
|
+
import { createArgsWithDefaults, createCliFlagsFromArgs, } from './ui-controller-args';
|
|
17
17
|
import { downloadServerBinaries, getBinaryPath } from './download-binaries';
|
|
18
18
|
import { logger } from './logger';
|
|
19
19
|
import { TimeoutError } from './timeout-error';
|
|
20
20
|
import { UnkownError } from './unkown-error';
|
|
21
|
-
export class
|
|
21
|
+
export class UiControllerFacade {
|
|
22
22
|
constructor() {
|
|
23
23
|
this.binaryPath = getBinaryPath('latest');
|
|
24
24
|
this.DefaultmaxWaitingForStartingInMs = 30 * 1000;
|
|
25
25
|
}
|
|
26
26
|
start(args, maxWaitingForStartingInSeconds) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
yield this.runPreStartChecks();
|
|
28
29
|
const argsWithDefaults = createArgsWithDefaults(args);
|
|
29
30
|
const argsWithLogPath = this.serverLogFilePath(argsWithDefaults);
|
|
30
31
|
this.binaryPath = getBinaryPath(argsWithLogPath.binaryVersion);
|
|
31
32
|
yield this.getBinary(argsWithLogPath.binaryVersion, argsWithLogPath.overWriteBinary);
|
|
32
33
|
this.makeBinaryExecutable();
|
|
33
|
-
logger.debug(`
|
|
34
|
+
logger.debug(`UI Controller log path "${this.serverLogFile}"`);
|
|
34
35
|
yield this.startWithDefaults(argsWithLogPath, maxWaitingForStartingInSeconds);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -41,7 +42,7 @@ export class ControlUiServerFacade {
|
|
|
41
42
|
yield this.killPort(argsWithDefaults.port, forceStop);
|
|
42
43
|
}
|
|
43
44
|
catch (err) {
|
|
44
|
-
throw new Error(`An unknown error occured while closing of the
|
|
45
|
+
throw new Error(`An unknown error occured while closing of the UI Controller. Log file: "${this.serverLogFile}". ErrorReason: ${err}`);
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
}
|
|
@@ -51,7 +52,7 @@ export class ControlUiServerFacade {
|
|
|
51
52
|
return args;
|
|
52
53
|
}
|
|
53
54
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'askui'));
|
|
54
|
-
this.serverLogFile = path.join(tmpDir, 'askui-
|
|
55
|
+
this.serverLogFile = path.join(tmpDir, 'askui-ui-controller.log');
|
|
55
56
|
const argPath = { logFilePath: this.serverLogFile };
|
|
56
57
|
return Object.assign(argPath, args);
|
|
57
58
|
}
|
|
@@ -63,13 +64,17 @@ export class ControlUiServerFacade {
|
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
getStartingCommand() {
|
|
66
|
-
return this.binaryPath
|
|
67
|
+
return `"${this.binaryPath}"`;
|
|
67
68
|
}
|
|
68
69
|
// eslint-disable-next-line class-methods-use-this
|
|
69
70
|
makeBinaryExecutable() {
|
|
70
71
|
/* Executable out of the box */
|
|
71
72
|
}
|
|
72
73
|
// eslint-disable-next-line class-methods-use-this
|
|
74
|
+
runPreStartChecks() {
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
}
|
|
77
|
+
// eslint-disable-next-line class-methods-use-this
|
|
73
78
|
waitUntilStarted(args, maxWaitingForStartingInSeconds) {
|
|
74
79
|
return new Promise((resolve, reject) => {
|
|
75
80
|
try {
|
|
@@ -89,7 +94,7 @@ export class ControlUiServerFacade {
|
|
|
89
94
|
});
|
|
90
95
|
}
|
|
91
96
|
catch (err) {
|
|
92
|
-
reject(new UnkownError(`An unknown error occured while waiting for the
|
|
97
|
+
reject(new UnkownError(`An unknown error occured while waiting for the UI Controller: ${err}`));
|
|
93
98
|
}
|
|
94
99
|
});
|
|
95
100
|
}
|
|
@@ -101,23 +106,24 @@ export class ControlUiServerFacade {
|
|
|
101
106
|
getBinary(binaryVersion, overWriteBinary = false) {
|
|
102
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
108
|
if (!fs.existsSync(this.binaryPath) || overWriteBinary || !this.isBinaryValid()) {
|
|
104
|
-
logger.debug(`Currently, no binary of the
|
|
109
|
+
logger.debug(`Currently, no binary of the UI Controller is available at "${this.binaryPath}"`);
|
|
105
110
|
yield downloadServerBinaries(binaryVersion);
|
|
106
111
|
}
|
|
107
112
|
else {
|
|
108
|
-
logger.debug(`Binary of
|
|
113
|
+
logger.debug(`Binary of UI Controller is already present at "${this.binaryPath}".`);
|
|
109
114
|
}
|
|
110
115
|
});
|
|
111
116
|
}
|
|
112
117
|
startWithDefaults(args, maxWaitingForStartingInSeconds) {
|
|
113
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
119
|
try {
|
|
115
|
-
logger.debug('Starting the
|
|
120
|
+
logger.debug('Starting the UI Controller...');
|
|
116
121
|
spawn(this.getStartingCommand(), createCliFlagsFromArgs(args), { shell: true });
|
|
117
122
|
yield this.waitUntilStarted(args, maxWaitingForStartingInSeconds);
|
|
118
123
|
}
|
|
119
124
|
catch (err) {
|
|
120
|
-
throw new Error(`The
|
|
125
|
+
throw new Error(`The UI Controller could not be started. Log file : ${this.serverLogFile}. ErrorReason: ${err}
|
|
126
|
+
Check this website for more information: https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller-starting-problems`);
|
|
121
127
|
}
|
|
122
128
|
});
|
|
123
129
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { exec } from 'child_process';
|
|
11
|
+
import { promisify } from 'util';
|
|
12
|
+
import { UiControllerFacade } from './ui-controller-facade';
|
|
13
|
+
import { logger } from './logger';
|
|
14
|
+
import { WaylandError } from './wayland-error';
|
|
15
|
+
import { LibfuseError } from './libfuse-error';
|
|
16
|
+
export class UiControllerLinux extends UiControllerFacade {
|
|
17
|
+
// eslint-disable-next-line class-methods-use-this
|
|
18
|
+
makeBinaryExecutable() {
|
|
19
|
+
exec(`chmod +x "${this.binaryPath}"`, (_exception, stdout) => logger.debug(stdout));
|
|
20
|
+
}
|
|
21
|
+
// eslint-disable-next-line class-methods-use-this
|
|
22
|
+
runPreStartChecks() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const runCommand = promisify(exec);
|
|
25
|
+
const waylandStatus = yield runCommand('echo $WAYLAND_DISPLAY');
|
|
26
|
+
if (waylandStatus.stdout.trim().includes('wayland')) {
|
|
27
|
+
throw new WaylandError('Wayland is not supported: https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller#wayland');
|
|
28
|
+
}
|
|
29
|
+
/* First we want to check if the user is using a debian distribution.
|
|
30
|
+
* and in the following if libfuse2 is installed.
|
|
31
|
+
* With Ubunutu 22.04 libfuse2 is not installed per default.
|
|
32
|
+
* For more information: https://discourse.joplinapp.org/t/appimage-incompatibility-in-ubuntu-22-04/25173
|
|
33
|
+
*/
|
|
34
|
+
try {
|
|
35
|
+
yield runCommand('dpkg --version');
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
yield runCommand('dpkg -s libfuse2 | grep Status');
|
|
42
|
+
}
|
|
43
|
+
catch (_a) {
|
|
44
|
+
throw new LibfuseError('Libfuse2 package is missing: https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller#libfuse2');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UiControllerArgs } from './ui-controller-args';
|
|
2
|
+
export declare class UiController {
|
|
3
|
+
private args?;
|
|
4
|
+
private server;
|
|
5
|
+
constructor(args?: UiControllerArgs | undefined);
|
|
6
|
+
start(timeoutInSeconds?: number): Promise<void>;
|
|
7
|
+
stop(forceStop?: boolean): Promise<void>;
|
|
8
|
+
}
|
|
@@ -7,22 +7,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { UiControllerDarwin } from './ui-controller-darwin';
|
|
11
|
+
import { UiControllerLinux } from './ui-controller-linux';
|
|
12
|
+
import { UiControllerWin32 } from './ui-controller-win32';
|
|
13
13
|
import { platform } from './download-binaries';
|
|
14
|
-
export class
|
|
14
|
+
export class UiController {
|
|
15
15
|
constructor(args) {
|
|
16
16
|
this.args = args;
|
|
17
17
|
switch (platform()) {
|
|
18
18
|
case 'darwin':
|
|
19
|
-
this.server = new
|
|
19
|
+
this.server = new UiControllerDarwin();
|
|
20
20
|
break;
|
|
21
21
|
case 'linux':
|
|
22
|
-
this.server = new
|
|
22
|
+
this.server = new UiControllerLinux();
|
|
23
23
|
break;
|
|
24
24
|
case 'win32':
|
|
25
|
-
this.server = new
|
|
25
|
+
this.server = new UiControllerWin32();
|
|
26
26
|
break;
|
|
27
27
|
default:
|
|
28
28
|
throw new Error(`Platform "${platform()}" not supported.`);
|
package/dist/esm/main.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { UiController } from './lib';
|
|
2
|
+
export { UiControlClient, AnnotationLevel } from './execution';
|
|
3
|
+
export { LogLevels } from './shared';
|
package/dist/esm/main.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { UiController } from './lib';
|
|
2
|
+
export { UiControlClient, AnnotationLevel } from './execution';
|
|
3
|
+
export { LogLevels } from './shared';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LogLevels } from './log-levels';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LogLevels } from './log-levels';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|