Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expose selectedProgrammer + configOptions #14

Merged
merged 4 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
node-version: ${{ matrix.config.node }}
- name: Install Dependencies
run: npm ci
- name: Check API Docs
run: npm run doc && git diff --exit-code
- name: Check Format
run: npm run format && git diff --exit-code
- name: Lint
Expand Down
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ src/**
.prettierignore
CHANGELOG.md
webpack.config.js
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
release.config.js
.nyc_output/**
docs/**
28 changes: 2 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,7 @@ This VS Code extension does not provide any functionality but a bridge between t

## API

### Variables

| Name | Description | Type | Note |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | :---------: |
| `openedSketches` | All opened sketch folders in the window. | `SketchFolder[]` | ⚠️ `@alpha` |
| `currentSketch` | The currently active sketch (folder) or `undefined`. The current sketch is the one that currently has focus or most recently had focus. The current sketch is in the opened sketches. | `SketchFolder \| undefined` | ⚠️ `@alpha` |
| `config` | The currently configured Arduino CLI configuration. | `CliConfig` | ⚠️ `@alpha` |

### Events

| Name | Description | Type | Note |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | :---------: |
| `onDidChangeCurrentSketch` | An event that is emitted when the current sketch has changed. _Note_ that the event also fires when the active editor changes to `undefined`. | `Event<{ currentSketch: SketchFolder \| undefined }>` | ⚠️ `@alpha` |
| `onDidChangeSketchFolders` | An event that is emitted when sketch folders are added or removed. | `Event<SketchFoldersChangeEvent>` | ⚠️ `@alpha` |
| `onDidChangeSketch` | An event that is emitted when the selected board, port, etc., has changed in the sketch folder. | `Event<ChangeEvent<SketchFolder>>` | ⚠️ `@alpha` |
| `onDidChangeConfig` | An event that is emitter when the sketchbook (`directories.data`) or the data directory (`directories.data`) path has changed. | `Event<ChangeEvent<CliConfig>>` | ⚠️ `@alpha` |

### `SketchFolder`

| Name | Description | Type | Note |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | :---------: |
| `sketchPath` | Absolute filesystem path of the sketch folder. | `string` | ⚠️ `@alpha` |
| `compileSummary` | The summary of the latest sketch compilation. When the `sketchPath` is available but the sketch has not been verified (compiled), the compile summary can be `undefined`. | `CompileSummary` | ⚠️ `@alpha` |
| `board` | The currently selected board associated with the sketch. If the `board` is undefined, no board is selected. If the `board` is a `BoardIdentifier`, it could be a recognized board on a detected port, but the board's platform could be absent. If platform is installed, the `board` is the lightweight representation of the board's detail. This information is [provided by the Arduino CLI](https://arduino.github.io/arduino-cli/latest/rpc/commands/#cc.arduino.cli.commands.v1.BoardDetailsResponse) for the currently selected board in the sketch folder. | `string` | ⚠️ `@alpha` |
| `port` | The currently selected port in the sketch folder. | [`Port`](https://arduino.github.io/arduino-cli/latest/rpc/commands/#port) | ⚠️ `@alpha` |
[See](https://github.com/dankeboy36/vscode-arduino-api/blob/main/docs/README.md) the full API on GitHub.

## How to Use

Expand Down Expand Up @@ -70,7 +46,7 @@ If you want to use the Arduino APIs, you have to do the followings:
context.subscriptions.push(
vscode.commands.registerCommand('myExtension.showSketchPath', () => {
vscode.window.showInformationMessage(
`Sketch path: ${arduinoContext.sketchPath}`
`Sketch path: ${context.sketchPath}`
);
})
);
Expand Down
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
140 changes: 140 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# vscode-arduino-api

## Table of contents

### Classes

- [Disposable](classes/Disposable.md)

### Interfaces

- [ArduinoContext](interfaces/ArduinoContext.md)
- [ArduinoState](interfaces/ArduinoState.md)
- [BoardDetails](interfaces/BoardDetails.md)
- [ChangeEvent](interfaces/ChangeEvent.md)
- [CliConfig](interfaces/CliConfig.md)
- [CompileSummary](interfaces/CompileSummary.md)
- [ConfigOption](interfaces/ConfigOption.md)
- [ConfigValue](interfaces/ConfigValue.md)
- [Event](interfaces/Event.md)
- [Port](interfaces/Port.md)
- [Programmer](interfaces/Programmer.md)
- [SketchFolder](interfaces/SketchFolder.md)
- [SketchFoldersChangeEvent](interfaces/SketchFoldersChangeEvent.md)

### Type Aliases

- [BoardIdentifier](README.md#boardidentifier)
- [BuildProperties](README.md#buildproperties)
- [Tool](README.md#tool)
- [Version](README.md#version)

### Variables

- [ConfigOption](README.md#configoption)
- [ConfigValue](README.md#configvalue)
- [Port](README.md#port)
- [Programmer](README.md#programmer)

## Type Aliases

### BoardIdentifier

Ƭ **BoardIdentifier**: `Nullable`\<`ApiBoard`, `"fqbn"`\>

Lightweight information to identify a board:

- The board's `name` is to provide a fallback for the UI. Preferably do not use this property for any sophisticated logic and board comparison. It must never participate in the board's identification.
- The FQBN might contain boards config options if selected from the discovered ports (see [arduino/arduino-ide#1588](https://github.com/arduino/arduino-ide/issues/1588)).

---

### BuildProperties

Ƭ **BuildProperties**: `Readonly`\<`Record`\<`string`, `string`\>\>

Build properties used for compiling. The board-specific properties are retrieved from `board.txt` and `platform.txt`. For example, if the `board.txt` contains the `build.tarch=xtensa` entry for the `esp32:esp32:esp32` board, the record includes the `"build.tarch": "xtensa"` property.

---

### Tool

Ƭ **Tool**: `Readonly`\<`Pick`\<`ToolsDependencies`, `"name"` \| `"version"` \| `"packager"`\>\>

Required Tool dependencies of a board. See [`ToolsDependencies`](https://arduino.github.io/arduino-cli/latest/rpc/commands/#cc.arduino.cli.commands.v1.ToolsDependencies) for the CLI API.

---

### Version

Ƭ **Version**: `string`

Supposed to be a [SemVer](https://semver.org/) as a `string` but it's not enforced by Arduino. You might need to coerce the SemVer string.

## Variables

### ConfigOption

• **ConfigOption**: `Object`

#### Type declaration

| Name | Type |
| :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `create` | (`base?`: \{ `option?`: `string` ; `optionLabel?`: `string` ; `values?`: \{ `selected?`: `boolean` ; `value?`: `string` ; `valueLabel?`: `string` }[] }) => [`ConfigOption`](interfaces/ConfigOption.md) |
| `decode` | (`input`: `Uint8Array` \| `Reader`, `length?`: `number`) => [`ConfigOption`](interfaces/ConfigOption.md) |
| `encode` | (`message`: [`ConfigOption`](interfaces/ConfigOption.md), `writer?`: `Writer`) => `Writer` |
| `fromJSON` | (`object`: `any`) => [`ConfigOption`](interfaces/ConfigOption.md) |
| `fromPartial` | (`object`: \{ `option?`: `string` ; `optionLabel?`: `string` ; `values?`: \{ `selected?`: `boolean` ; `value?`: `string` ; `valueLabel?`: `string` }[] }) => [`ConfigOption`](interfaces/ConfigOption.md) |
| `toJSON` | (`message`: [`ConfigOption`](interfaces/ConfigOption.md)) => `unknown` |

---

### ConfigValue

• **ConfigValue**: `Object`

#### Type declaration

| Name | Type |
| :------------ | :----------------------------------------------------------------------------------------------------------------------------------- |
| `create` | (`base?`: \{ `selected?`: `boolean` ; `value?`: `string` ; `valueLabel?`: `string` }) => [`ConfigValue`](interfaces/ConfigValue.md) |
| `decode` | (`input`: `Uint8Array` \| `Reader`, `length?`: `number`) => [`ConfigValue`](interfaces/ConfigValue.md) |
| `encode` | (`message`: [`ConfigValue`](interfaces/ConfigValue.md), `writer?`: `Writer`) => `Writer` |
| `fromJSON` | (`object`: `any`) => [`ConfigValue`](interfaces/ConfigValue.md) |
| `fromPartial` | (`object`: \{ `selected?`: `boolean` ; `value?`: `string` ; `valueLabel?`: `string` }) => [`ConfigValue`](interfaces/ConfigValue.md) |
| `toJSON` | (`message`: [`ConfigValue`](interfaces/ConfigValue.md)) => `unknown` |

---

### Port

• **Port**: `Object`

#### Type declaration

| Name | Type |
| :------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `create` | (`base?`: \{ `address?`: `string` ; `hardwareId?`: `string` ; `label?`: `string` ; `properties?`: {} ; `protocol?`: `string` ; `protocolLabel?`: `string` }) => [`Port`](interfaces/Port.md) |
| `decode` | (`input`: `Uint8Array` \| `Reader`, `length?`: `number`) => [`Port`](interfaces/Port.md) |
| `encode` | (`message`: [`Port`](interfaces/Port.md), `writer?`: `Writer`) => `Writer` |
| `fromJSON` | (`object`: `any`) => [`Port`](interfaces/Port.md) |
| `fromPartial` | (`object`: \{ `address?`: `string` ; `hardwareId?`: `string` ; `label?`: `string` ; `properties?`: {} ; `protocol?`: `string` ; `protocolLabel?`: `string` }) => [`Port`](interfaces/Port.md) |
| `toJSON` | (`message`: [`Port`](interfaces/Port.md)) => `unknown` |

---

### Programmer

• **Programmer**: `Object`

#### Type declaration

| Name | Type |
| :------------ | :----------------------------------------------------------------------------------------------------------------------- |
| `create` | (`base?`: \{ `id?`: `string` ; `name?`: `string` ; `platform?`: `string` }) => [`Programmer`](interfaces/Programmer.md) |
| `decode` | (`input`: `Uint8Array` \| `Reader`, `length?`: `number`) => [`Programmer`](interfaces/Programmer.md) |
| `encode` | (`message`: [`Programmer`](interfaces/Programmer.md), `writer?`: `Writer`) => `Writer` |
| `fromJSON` | (`object`: `any`) => [`Programmer`](interfaces/Programmer.md) |
| `fromPartial` | (`object`: \{ `id?`: `string` ; `name?`: `string` ; `platform?`: `string` }) => [`Programmer`](interfaces/Programmer.md) |
| `toJSON` | (`message`: [`Programmer`](interfaces/Programmer.md)) => `unknown` |
70 changes: 70 additions & 0 deletions docs/classes/Disposable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Class: Disposable

Represents a type which can release resources, such
as event listening or a timer.

## Table of contents

### Constructors

- [constructor](Disposable.md#constructor)

### Methods

- [dispose](Disposable.md#dispose)
- [from](Disposable.md#from)

## Constructors

### constructor

• **new Disposable**(`callOnDispose`): [`Disposable`](Disposable.md)

Creates a new disposable that calls the provided function
on dispose.

_Note_ that an asynchronous function is not awaited.

#### Parameters

| Name | Type | Description |
| :-------------- | :---------- | :-------------------------------- |
| `callOnDispose` | () => `any` | Function that disposes something. |

#### Returns

[`Disposable`](Disposable.md)

## Methods

### dispose

▸ **dispose**(): `any`

Dispose this object.

#### Returns

`any`

---

### from

▸ **from**(`...disposableLikes`): [`Disposable`](Disposable.md)

Combine many disposable-likes into one. You can use this method when having objects with
a dispose function which aren't instances of `Disposable`.

#### Parameters

| Name | Type | Description |
| :------------------- | :---------------------------- | :--------------------------------------------------------------------------------------------------------------- |
| `...disposableLikes` | \{ `dispose`: () => `any` }[] | Objects that have at least a `dispose`-function member. Note that asynchronous dispose-functions aren't awaited. |

#### Returns

[`Disposable`](Disposable.md)

Returns a new disposable which, upon dispose, will
dispose all provided disposables.
Loading
Loading