@react-native-windows/automation-channel 0.12.115 → 0.12.117

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,32 +1,32 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * @format
6
- */
7
- /// <reference types="node" />
8
- import { Server, Socket } from 'net';
9
- export type InvokeResult = {
10
- type: 'error';
11
- code: any;
12
- message: string;
13
- } | {
14
- type: 'success';
15
- result?: any;
16
- };
17
- export declare class AutomationClient {
18
- private readonly socket;
19
- private readonly server;
20
- private readonly pendingRequests;
21
- private receiveBuffer;
22
- constructor(socket: Socket, server: Server);
23
- invoke(methodName: string, params: any[] | Record<string, any>): Promise<InvokeResult>;
24
- close(): void;
25
- private onData;
26
- private onEnd;
27
- private onError;
28
- private onMessage;
29
- }
30
- export declare function waitForConnection(opts: {
31
- port: number;
32
- }): Promise<AutomationClient>;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ /// <reference types="node" />
8
+ import { Server, Socket } from 'net';
9
+ export type InvokeResult = {
10
+ type: 'error';
11
+ code: any;
12
+ message: string;
13
+ } | {
14
+ type: 'success';
15
+ result?: any;
16
+ };
17
+ export declare class AutomationClient {
18
+ private readonly socket;
19
+ private readonly server;
20
+ private readonly pendingRequests;
21
+ private receiveBuffer;
22
+ constructor(socket: Socket, server: Server);
23
+ invoke(methodName: string, params: any[] | Record<string, any>): Promise<InvokeResult>;
24
+ close(): void;
25
+ private onData;
26
+ private onEnd;
27
+ private onError;
28
+ private onMessage;
29
+ }
30
+ export declare function waitForConnection(opts: {
31
+ port: number;
32
+ }): Promise<AutomationClient>;
@@ -1,122 +1,122 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- *
6
- * @format
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.waitForConnection = exports.AutomationClient = void 0;
13
- const net_1 = require("net");
14
- const jsonrpc_lite_1 = __importDefault(require("jsonrpc-lite"));
15
- let incrementingId = 0;
16
- class AutomationClient {
17
- constructor(socket, server) {
18
- this.socket = socket;
19
- this.server = server;
20
- this.pendingRequests = new Map();
21
- this.receiveBuffer = Buffer.alloc(0);
22
- this.socket.on('data', this.onData.bind(this));
23
- this.socket.on('end', this.onEnd.bind(this));
24
- this.socket.on('error', this.onError.bind(this));
25
- }
26
- invoke(methodName, params) {
27
- return new Promise((resolve, reject) => {
28
- const messageId = ++incrementingId;
29
- this.pendingRequests.set(messageId, (result, err) => {
30
- if (err) {
31
- reject(err);
32
- }
33
- if (result) {
34
- resolve(result);
35
- }
36
- });
37
- const requestString = jsonrpc_lite_1.default
38
- .request(messageId, methodName, params)
39
- .serialize();
40
- const requestBuffer = Buffer.from(requestString, 'utf-8');
41
- const sizeBuffer = Buffer.alloc(4);
42
- sizeBuffer.writeUInt32LE(requestBuffer.length);
43
- this.socket.write(sizeBuffer);
44
- this.socket.write(requestBuffer);
45
- });
46
- }
47
- close() {
48
- this.socket.destroy();
49
- this.server.close();
50
- }
51
- onData(chunk) {
52
- this.receiveBuffer = Buffer.concat([this.receiveBuffer, chunk]);
53
- if (this.receiveBuffer.length >= 4) {
54
- const messageLength = this.receiveBuffer.readUInt32LE();
55
- const totalLength = messageLength + 4;
56
- if (this.receiveBuffer.length >= totalLength) {
57
- const messageBuffer = this.receiveBuffer.slice(4, totalLength);
58
- if (totalLength < this.receiveBuffer.length) {
59
- this.receiveBuffer = Buffer.from(this.receiveBuffer, totalLength);
60
- }
61
- else {
62
- this.receiveBuffer = Buffer.alloc(0);
63
- }
64
- this.onMessage(messageBuffer);
65
- }
66
- }
67
- }
68
- onEnd() {
69
- this.pendingRequests.forEach(req => req(null, new Error('Unexpected disconnect from RPC server')));
70
- }
71
- onError(error) {
72
- this.pendingRequests.forEach(req => req(null, error));
73
- }
74
- onMessage(message) {
75
- const response = jsonrpc_lite_1.default.parseJsonRpcString(message.toString('utf8'));
76
- if (Array.isArray(response)) {
77
- throw new Error('Expected single message');
78
- }
79
- switch (response.type) {
80
- case "request" /* RpcStatusType.request */:
81
- throw new Error('Received JSON-RPC request instead of response');
82
- case "notification" /* RpcStatusType.notification */:
83
- throw new Error('Unexpected JSON-RPC notification');
84
- case "invalid" /* RpcStatusType.invalid */:
85
- throw new Error('Invalid JSON-RPC2 response: ' +
86
- JSON.stringify(response.payload, null, 2));
87
- case "success" /* RpcStatusType.success */: {
88
- const pendingReq = this.pendingRequests.get(response.payload.id);
89
- if (!pendingReq) {
90
- throw new Error('Could not find pending request from response ID');
91
- }
92
- this.pendingRequests.delete(response.payload.id);
93
- pendingReq({ type: 'success', result: response.payload.result }, null);
94
- break;
95
- }
96
- case "error" /* RpcStatusType.error */: {
97
- const pendingReq = this.pendingRequests.get(response.payload.id);
98
- if (!pendingReq) {
99
- throw new Error('Could not find pending request from response ID');
100
- }
101
- this.pendingRequests.delete(response.payload.id);
102
- pendingReq({ type: 'error', ...response.payload.error }, null);
103
- break;
104
- }
105
- }
106
- }
107
- }
108
- exports.AutomationClient = AutomationClient;
109
- function waitForConnection(opts) {
110
- return new Promise((resolve, reject) => {
111
- const server = new net_1.Server();
112
- server.listen(opts.port);
113
- const onError = (err) => reject(err);
114
- server.on('error', onError);
115
- server.on('connection', socket => {
116
- server.off('error', onError);
117
- resolve(new AutomationClient(socket, server));
118
- });
119
- });
120
- }
121
- exports.waitForConnection = waitForConnection;
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * @format
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.waitForConnection = exports.AutomationClient = void 0;
13
+ const net_1 = require("net");
14
+ const jsonrpc_lite_1 = __importDefault(require("jsonrpc-lite"));
15
+ let incrementingId = 0;
16
+ class AutomationClient {
17
+ constructor(socket, server) {
18
+ this.socket = socket;
19
+ this.server = server;
20
+ this.pendingRequests = new Map();
21
+ this.receiveBuffer = Buffer.alloc(0);
22
+ this.socket.on('data', this.onData.bind(this));
23
+ this.socket.on('end', this.onEnd.bind(this));
24
+ this.socket.on('error', this.onError.bind(this));
25
+ }
26
+ invoke(methodName, params) {
27
+ return new Promise((resolve, reject) => {
28
+ const messageId = ++incrementingId;
29
+ this.pendingRequests.set(messageId, (result, err) => {
30
+ if (err) {
31
+ reject(err);
32
+ }
33
+ if (result) {
34
+ resolve(result);
35
+ }
36
+ });
37
+ const requestString = jsonrpc_lite_1.default
38
+ .request(messageId, methodName, params)
39
+ .serialize();
40
+ const requestBuffer = Buffer.from(requestString, 'utf-8');
41
+ const sizeBuffer = Buffer.alloc(4);
42
+ sizeBuffer.writeUInt32LE(requestBuffer.length);
43
+ this.socket.write(sizeBuffer);
44
+ this.socket.write(requestBuffer);
45
+ });
46
+ }
47
+ close() {
48
+ this.socket.destroy();
49
+ this.server.close();
50
+ }
51
+ onData(chunk) {
52
+ this.receiveBuffer = Buffer.concat([this.receiveBuffer, chunk]);
53
+ if (this.receiveBuffer.length >= 4) {
54
+ const messageLength = this.receiveBuffer.readUInt32LE();
55
+ const totalLength = messageLength + 4;
56
+ if (this.receiveBuffer.length >= totalLength) {
57
+ const messageBuffer = this.receiveBuffer.slice(4, totalLength);
58
+ if (totalLength < this.receiveBuffer.length) {
59
+ this.receiveBuffer = Buffer.from(this.receiveBuffer, totalLength);
60
+ }
61
+ else {
62
+ this.receiveBuffer = Buffer.alloc(0);
63
+ }
64
+ this.onMessage(messageBuffer);
65
+ }
66
+ }
67
+ }
68
+ onEnd() {
69
+ this.pendingRequests.forEach(req => req(null, new Error('Unexpected disconnect from RPC server')));
70
+ }
71
+ onError(error) {
72
+ this.pendingRequests.forEach(req => req(null, error));
73
+ }
74
+ onMessage(message) {
75
+ const response = jsonrpc_lite_1.default.parseJsonRpcString(message.toString('utf8'));
76
+ if (Array.isArray(response)) {
77
+ throw new Error('Expected single message');
78
+ }
79
+ switch (response.type) {
80
+ case "request" /* RpcStatusType.request */:
81
+ throw new Error('Received JSON-RPC request instead of response');
82
+ case "notification" /* RpcStatusType.notification */:
83
+ throw new Error('Unexpected JSON-RPC notification');
84
+ case "invalid" /* RpcStatusType.invalid */:
85
+ throw new Error('Invalid JSON-RPC2 response: ' +
86
+ JSON.stringify(response.payload, null, 2));
87
+ case "success" /* RpcStatusType.success */: {
88
+ const pendingReq = this.pendingRequests.get(response.payload.id);
89
+ if (!pendingReq) {
90
+ throw new Error('Could not find pending request from response ID');
91
+ }
92
+ this.pendingRequests.delete(response.payload.id);
93
+ pendingReq({ type: 'success', result: response.payload.result }, null);
94
+ break;
95
+ }
96
+ case "error" /* RpcStatusType.error */: {
97
+ const pendingReq = this.pendingRequests.get(response.payload.id);
98
+ if (!pendingReq) {
99
+ throw new Error('Could not find pending request from response ID');
100
+ }
101
+ this.pendingRequests.delete(response.payload.id);
102
+ pendingReq({ type: 'error', ...response.payload.error }, null);
103
+ break;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ exports.AutomationClient = AutomationClient;
109
+ function waitForConnection(opts) {
110
+ return new Promise((resolve, reject) => {
111
+ const server = new net_1.Server();
112
+ server.listen(opts.port);
113
+ const onError = (err) => reject(err);
114
+ server.on('error', onError);
115
+ server.on('connection', socket => {
116
+ server.off('error', onError);
117
+ resolve(new AutomationClient(socket, server));
118
+ });
119
+ });
120
+ }
121
+ exports.waitForConnection = waitForConnection;
122
122
  //# sourceMappingURL=automationChannel.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/automation-channel",
3
- "version": "0.12.115",
3
+ "version": "0.12.117",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,18 +22,18 @@
22
22
  "jsonrpc-lite": "^2.2.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@rnw-scripts/eslint-config": "1.2.5",
26
- "@rnw-scripts/just-task": "2.3.20",
25
+ "@rnw-scripts/eslint-config": "1.2.6",
26
+ "@rnw-scripts/just-task": "2.3.22",
27
27
  "@rnw-scripts/ts-config": "2.0.5",
28
28
  "@types/find-up": "^4.0.0",
29
29
  "@types/node": "^18.0.0",
30
30
  "eslint": "^8.19.0",
31
31
  "just-scripts": "^1.3.2",
32
- "prettier": "^2.4.1",
32
+ "prettier": "2.8.8",
33
33
  "react": "18.2.0",
34
34
  "react-native": "0.74.0-nightly-20240115-0c7008f28",
35
- "react-native-windows": "^0.0.0-canary.776",
36
- "typescript": "^4.9.5"
35
+ "react-native-windows": "^0.0.0-canary.778",
36
+ "typescript": "5.0.4"
37
37
  },
38
38
  "files": [
39
39
  "lib-commonjs",