@react-native-windows/automation-channel 0.0.35 → 0.1.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.
@@ -66,10 +66,10 @@ class AutomationClient {
66
66
  }
67
67
  }
68
68
  onEnd() {
69
- this.pendingRequests.forEach(req => req(null, new Error('Unexpected disconnect from RPC server')));
69
+ this.pendingRequests.forEach((req) => req(null, new Error('Unexpected disconnect from RPC server')));
70
70
  }
71
71
  onError(error) {
72
- this.pendingRequests.forEach(req => req(null, error));
72
+ this.pendingRequests.forEach((req) => req(null, error));
73
73
  }
74
74
  onMessage(message) {
75
75
  const response = jsonrpc_lite_1.default.parseJsonRpcString(message.toString('utf8'));
@@ -112,7 +112,7 @@ function waitForConnection(opts) {
112
112
  server.listen(opts.port);
113
113
  const onError = (err) => reject(err);
114
114
  server.on('error', onError);
115
- server.on('connection', socket => {
115
+ server.on('connection', (socket) => {
116
116
  server.off('error', onError);
117
117
  resolve(new AutomationClient(socket, server));
118
118
  });
@@ -1 +1 @@
1
- {"version":3,"file":"automationChannel.js","sourceRoot":"","sources":["../src/automationChannel.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,6BAAmC;AACnC,gEAAmC;AAGnC,IAAI,cAAc,GAAG,CAAC,CAAC;AAMvB,MAAa,gBAAgB;IAS3B,YAAY,MAAc,EAAE,MAAc;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KA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7D,MAAM;aACP;SACF;IACH,CAAC;CACF;AA5HD,4CA4HC;AAED,SAAgB,iBAAiB,CAAC,IAEjC;IACC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,YAAM,EAAE,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzB,MAAM,OAAO,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE;YAC/B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,8CAcC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport {Server, Socket} from 'net';\nimport jsonrpc from 'jsonrpc-lite';\nimport {RpcStatusType} from 'jsonrpc-lite';\n\nlet incrementingId = 0;\n\nexport type InvokeResult =\n | {type: 'error'; code: any; message: string}\n | {type: 'success'; result?: any};\n\nexport class AutomationClient {\n private readonly socket: Socket;\n private readonly server: Server;\n private readonly pendingRequests: Map<\n any,\n (result: InvokeResult | null, err: Error | null) => void\n >;\n private receiveBuffer: Buffer;\n\n constructor(socket: Socket, server: Server) {\n this.socket = socket;\n this.server = server;\n\n this.pendingRequests = new Map();\n this.receiveBuffer = Buffer.alloc(0);\n\n this.socket.on('data', this.onData.bind(this));\n this.socket.on('end', this.onEnd.bind(this));\n this.socket.on('error', this.onError.bind(this));\n }\n\n invoke(\n methodName: string,\n params: any[] | Record<string, any>,\n ): Promise<InvokeResult> {\n return new Promise((resolve, reject) => {\n const messageId = ++incrementingId;\n this.pendingRequests.set(messageId, (result, err) => {\n if (err) {\n reject(err);\n }\n if (result) {\n resolve(result);\n }\n });\n\n const requestString = jsonrpc\n .request(messageId, methodName, params)\n .serialize();\n\n const requestBuffer = Buffer.from(requestString, 'utf-8');\n const sizeBuffer = Buffer.alloc(4);\n sizeBuffer.writeUInt32LE(requestBuffer.length);\n\n this.socket.write(sizeBuffer);\n this.socket.write(requestBuffer);\n });\n }\n\n close() {\n this.socket.destroy();\n this.server.close();\n }\n\n private onData(chunk: Buffer) {\n this.receiveBuffer = Buffer.concat([this.receiveBuffer, chunk]);\n if (this.receiveBuffer.length >= 4) {\n const messageLength = this.receiveBuffer.readUInt32LE();\n const totalLength = messageLength + 4;\n\n if (this.receiveBuffer.length >= totalLength) {\n const messageBuffer = this.receiveBuffer.slice(4, totalLength);\n\n if (totalLength < this.receiveBuffer.length) {\n this.receiveBuffer = Buffer.from(this.receiveBuffer, totalLength);\n } else {\n this.receiveBuffer = Buffer.alloc(0);\n }\n\n this.onMessage(messageBuffer);\n }\n }\n }\n\n private onEnd() {\n this.pendingRequests.forEach(req =>\n req(null, new Error('Unexpected disconnect from RPC server')),\n );\n }\n\n private onError(error: Error) {\n this.pendingRequests.forEach(req => req(null, error));\n }\n\n private onMessage(message: Buffer) {\n const response = jsonrpc.parseJsonRpcString(message.toString('utf8'));\n if (Array.isArray(response)) {\n throw new Error('Expected single message');\n }\n\n switch (response.type) {\n case RpcStatusType.request:\n throw new Error('Recieved JSON-RPC request instead of response');\n case RpcStatusType.notification:\n throw new Error('Unexpected JSON-RPC notification');\n case RpcStatusType.invalid:\n throw new Error(\n 'Invalid JSON-RPC2 response: ' +\n JSON.stringify(response.payload, null, 2),\n );\n\n case RpcStatusType.success: {\n const pendingReq = this.pendingRequests.get(response.payload.id);\n if (!pendingReq) {\n throw new Error('Could not find pending request from response ID');\n }\n\n this.pendingRequests.delete(response.payload.id);\n pendingReq({type: 'success', result: response.payload.result}, null);\n break;\n }\n\n case RpcStatusType.error: {\n const pendingReq = this.pendingRequests.get(response.payload.id);\n if (!pendingReq) {\n throw new Error('Could not find pending request from response ID');\n }\n\n this.pendingRequests.delete(response.payload.id);\n pendingReq({type: 'error', ...response.payload.error}, null);\n break;\n }\n }\n }\n}\n\nexport function waitForConnection(opts: {\n port: number;\n}): Promise<AutomationClient> {\n return new Promise((resolve, reject) => {\n const server = new Server();\n server.listen(opts.port);\n\n const onError = (err: Error) => reject(err);\n server.on('error', onError);\n server.on('connection', socket => {\n server.off('error', onError);\n resolve(new AutomationClient(socket, server));\n });\n });\n}\n"]}
1
+ {"version":3,"file":"automationChannel.js","sourceRoot":"","sources":["../src/automationChannel.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,6BAAmC;AACnC,gEAAmC;AAGnC,IAAI,cAAc,GAAG,CAAC,CAAC;AAMvB,MAAa,gBAAgB;IAS3B,YAAY,MAAc,EAAE,MAAc;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CACJ,UAAkB,EAClB,MA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MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzB,MAAM,OAAO,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;YACjC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,8CAcC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport {Server, Socket} from 'net';\nimport jsonrpc from 'jsonrpc-lite';\nimport {RpcStatusType} from 'jsonrpc-lite';\n\nlet incrementingId = 0;\n\nexport type InvokeResult =\n | {type: 'error'; code: any; message: string}\n | {type: 'success'; result?: any};\n\nexport class AutomationClient {\n private readonly socket: Socket;\n private readonly server: Server;\n private readonly pendingRequests: Map<\n any,\n (result: InvokeResult | null, err: Error | null) => void\n >;\n private receiveBuffer: Buffer;\n\n constructor(socket: Socket, server: Server) {\n this.socket = socket;\n this.server = server;\n\n this.pendingRequests = new Map();\n this.receiveBuffer = Buffer.alloc(0);\n\n this.socket.on('data', this.onData.bind(this));\n this.socket.on('end', this.onEnd.bind(this));\n this.socket.on('error', this.onError.bind(this));\n }\n\n invoke(\n methodName: string,\n params: any[] | Record<string, any>,\n ): Promise<InvokeResult> {\n return new Promise((resolve, reject) => {\n const messageId = ++incrementingId;\n this.pendingRequests.set(messageId, (result, err) => {\n if (err) {\n reject(err);\n }\n if (result) {\n resolve(result);\n }\n });\n\n const requestString = jsonrpc\n .request(messageId, methodName, params)\n .serialize();\n\n const requestBuffer = Buffer.from(requestString, 'utf-8');\n const sizeBuffer = Buffer.alloc(4);\n sizeBuffer.writeUInt32LE(requestBuffer.length);\n\n this.socket.write(sizeBuffer);\n this.socket.write(requestBuffer);\n });\n }\n\n close() {\n this.socket.destroy();\n this.server.close();\n }\n\n private onData(chunk: Buffer) {\n this.receiveBuffer = Buffer.concat([this.receiveBuffer, chunk]);\n if (this.receiveBuffer.length >= 4) {\n const messageLength = this.receiveBuffer.readUInt32LE();\n const totalLength = messageLength + 4;\n\n if (this.receiveBuffer.length >= totalLength) {\n const messageBuffer = this.receiveBuffer.slice(4, totalLength);\n\n if (totalLength < this.receiveBuffer.length) {\n this.receiveBuffer = Buffer.from(this.receiveBuffer, totalLength);\n } else {\n this.receiveBuffer = Buffer.alloc(0);\n }\n\n this.onMessage(messageBuffer);\n }\n }\n }\n\n private onEnd() {\n this.pendingRequests.forEach((req) =>\n req(null, new Error('Unexpected disconnect from RPC server')),\n );\n }\n\n private onError(error: Error) {\n this.pendingRequests.forEach((req) => req(null, error));\n }\n\n private onMessage(message: Buffer) {\n const response = jsonrpc.parseJsonRpcString(message.toString('utf8'));\n if (Array.isArray(response)) {\n throw new Error('Expected single message');\n }\n\n switch (response.type) {\n case RpcStatusType.request:\n throw new Error('Recieved JSON-RPC request instead of response');\n case RpcStatusType.notification:\n throw new Error('Unexpected JSON-RPC notification');\n case RpcStatusType.invalid:\n throw new Error(\n 'Invalid JSON-RPC2 response: ' +\n JSON.stringify(response.payload, null, 2),\n );\n\n case RpcStatusType.success: {\n const pendingReq = this.pendingRequests.get(response.payload.id);\n if (!pendingReq) {\n throw new Error('Could not find pending request from response ID');\n }\n\n this.pendingRequests.delete(response.payload.id);\n pendingReq({type: 'success', result: response.payload.result}, null);\n break;\n }\n\n case RpcStatusType.error: {\n const pendingReq = this.pendingRequests.get(response.payload.id);\n if (!pendingReq) {\n throw new Error('Could not find pending request from response ID');\n }\n\n this.pendingRequests.delete(response.payload.id);\n pendingReq({type: 'error', ...response.payload.error}, null);\n break;\n }\n }\n }\n}\n\nexport function waitForConnection(opts: {\n port: number;\n}): Promise<AutomationClient> {\n return new Promise((resolve, reject) => {\n const server = new Server();\n server.listen(opts.port);\n\n const onError = (err: Error) => reject(err);\n server.on('error', onError);\n server.on('connection', (socket) => {\n server.off('error', onError);\n resolve(new AutomationClient(socket, server));\n });\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/automation-channel",
3
- "version": "0.0.35",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,17 +20,17 @@
20
20
  "jsonrpc-lite": "^2.2.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@rnw-scripts/eslint-config": "1.1.9",
24
- "@rnw-scripts/just-task": "2.2.1",
23
+ "@rnw-scripts/eslint-config": "1.1.10",
24
+ "@rnw-scripts/just-task": "2.2.2",
25
25
  "@rnw-scripts/ts-config": "2.0.1",
26
26
  "@types/find-up": "^4.0.0",
27
27
  "@types/node": "^14.14.22",
28
- "eslint": "7.12.0",
28
+ "eslint": "^7.32.0",
29
29
  "just-scripts": "^1.3.2",
30
- "prettier": "1.19.1",
30
+ "prettier": "^2.4.1",
31
31
  "react": "17.0.2",
32
- "react-native": "0.0.0-20211028-2008-61e1b6f86",
33
- "react-native-windows": "^0.0.0-canary.424",
32
+ "react-native": "0.0.0-20211111-2008-2ae06df58",
33
+ "react-native-windows": "^0.0.0-canary.428",
34
34
  "typescript": "^4.4.4"
35
35
  },
36
36
  "files": [
@@ -12,7 +12,6 @@
12
12
  </ItemGroup>
13
13
  <ItemGroup>
14
14
  <None Include="PropertySheet.props" />
15
- <None Include="packages.config" />
16
15
  <None Include="AutomationChannel.def" />
17
16
  </ItemGroup>
18
17
  <ItemGroup>
@@ -1,6 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.props')" />
4
3
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Defaults.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.WindowsSdk.Defaults.props')" />
5
4
  <PropertyGroup Label="Globals">
6
5
  <CppWinRTOptimized>true</CppWinRTOptimized>
@@ -15,6 +14,9 @@
15
14
  <ApplicationType>Windows Store</ApplicationType>
16
15
  <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
17
16
  </PropertyGroup>
17
+ <PropertyGroup Label="NuGet">
18
+ <ResolveNuGetPackages>false</ResolveNuGetPackages>
19
+ </PropertyGroup>
18
20
  <PropertyGroup Label="ReactNativeWindowsProps">
19
21
  <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(SolutionDir), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
20
22
  </PropertyGroup>
@@ -71,7 +73,6 @@
71
73
  </ImportGroup>
72
74
  <ImportGroup Label="ReactNativeWindowsPropertySheets">
73
75
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\external\Microsoft.ReactNative.Uwp.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" />
74
- <Import Project="$(SolutionDir)\packages\$(WinUIPackageProps)" Condition="'$(WinUIPackageProps)'!='' And Exists('$(SolutionDir)\packages\$(WinUIPackageProps)')" />
75
76
  </ImportGroup>
76
77
  <PropertyGroup Label="UserMacros" />
77
78
  <ItemDefinitionGroup>
@@ -138,9 +139,11 @@
138
139
  </ItemGroup>
139
140
  <ItemGroup>
140
141
  <None Include="AutomationChannel.def" />
141
- <None Include="packages.config" />
142
142
  <None Include="PropertySheet.props" />
143
143
  </ItemGroup>
144
+ <ItemGroup>
145
+ <PackageReference Include="Microsoft.Windows.CppWinRT" Version="$(CppWinRTVersion)" />
146
+ </ItemGroup>
144
147
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
145
148
  <ImportGroup Label="ReactNativeWindowsTargets">
146
149
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" />
@@ -152,16 +155,4 @@
152
155
  <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props'))" />
153
156
  <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets'))" />
154
157
  </Target>
155
- <ImportGroup Label="ExtensionTargets">
156
- <Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.targets')" />
157
- <Import Project="$(SolutionDir)\packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets" Condition="Exists('$(SolutionDir)\packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" />
158
- </ImportGroup>
159
- <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
160
- <PropertyGroup>
161
- <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
162
- </PropertyGroup>
163
- <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.props'))" />
164
- <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.210312.4\build\native\Microsoft.Windows.CppWinRT.targets'))" />
165
- <Error Condition="!Exists('$(SolutionDir)\packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\$(WinUIPackageName).$(WinUIPackageVersion)\build\native\$(WinUIPackageName).targets'))" />
166
- </Target>
167
158
  </Project>