-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use Arduino CLI
0.36.0-rc.1
APIs
Signed-off-by: Akos Kitta <[email protected]>
- Loading branch information
Showing
43 changed files
with
5,530 additions
and
3,268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
arduino-ide-extension/src/node/arduino-core-service-client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { credentials, makeClientConstructor } from '@grpc/grpc-js'; | ||
import * as commandsGrpcPb from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb'; | ||
import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb'; | ||
|
||
export interface CreateClientOptions { | ||
/** | ||
* The port to the Arduino CLI daemon. | ||
*/ | ||
readonly port: number; | ||
/** | ||
* Defaults to `'localhost'`. | ||
*/ | ||
readonly host?: string; | ||
|
||
/** | ||
* gRCP channel options. Defaults to `createDefaultChannelOptions` with `'0.0.0'` `appVersion` | ||
*/ | ||
readonly channelOptions?: Record<string, unknown>; | ||
} | ||
|
||
export function createDefaultChannelOptions( | ||
appVersion = '0.0.0' | ||
): Record<string, unknown> { | ||
return { | ||
'grpc.max_send_message_length': 512 * 1024 * 1024, | ||
'grpc.max_receive_message_length': 512 * 1024 * 1024, | ||
'grpc.primary_user_agent': `arduino-ide/${appVersion}`, | ||
}; | ||
} | ||
|
||
export function createArduinoCoreServiceClient( | ||
options: CreateClientOptions | ||
): ArduinoCoreServiceClient { | ||
const { | ||
port, | ||
host = 'localhost', | ||
channelOptions = createDefaultChannelOptions(), | ||
} = options; | ||
const address = `${host}:${port}`; | ||
// https://github.com/agreatfool/grpc_tools_node_protoc_ts/blob/master/doc/grpcjs_support.md#usage | ||
const ArduinoCoreServiceClient = makeClientConstructor( | ||
// @ts-expect-error: ignore | ||
commandsGrpcPb['cc.arduino.cli.commands.v1.ArduinoCoreService'], | ||
'ArduinoCoreServiceService' | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
) as any; | ||
const client = new ArduinoCoreServiceClient( | ||
address, | ||
credentials.createInsecure(), | ||
channelOptions | ||
) as ArduinoCoreServiceClient; | ||
return client; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.