File tree 10 files changed +41
-25
lines changed
editor/codemirror/language-server
10 files changed +41
-25
lines changed Original file line number Diff line number Diff line change 16
16
"@codemirror/view" : " ^6.26.3" ,
17
17
"@emotion/react" : " ^11.11.4" ,
18
18
"@emotion/styled" : " ^11.11.5" ,
19
- "@microbit/microbit-connection" : " ^0.0.0-alpha.33 " ,
19
+ "@microbit/microbit-connection" : " ^0.0.0-alpha.35 " ,
20
20
"@microbit/microbit-fs" : " ^0.10.0" ,
21
21
"@sanity/block-content-to-react" : " ^3.0.0" ,
22
22
"@sanity/image-url" : " ^1.0.1" ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import "./App.css";
10
10
import { DialogProvider } from "./common/use-dialogs" ;
11
11
import VisualViewPortCSSVariables from "./common/VisualViewportCSSVariables" ;
12
12
import { deployment , useDeployment } from "./deployment" ;
13
- import { MicrobitWebUSBConnection } from "@microbit/microbit-connection" ;
13
+ import { createWebUSBConnection } from "@microbit/microbit-connection" ;
14
14
import { DeviceContextProvider } from "./device/device-hooks" ;
15
15
import { MockDeviceConnection } from "./device/mock" ;
16
16
import DocumentationProvider from "./documentation/documentation-hooks" ;
@@ -40,7 +40,7 @@ const isMockDeviceMode = () =>
40
40
const logging = deployment . logging ;
41
41
const device = isMockDeviceMode ( )
42
42
? new MockDeviceConnection ( )
43
- : new MicrobitWebUSBConnection ( { logging } ) ;
43
+ : createWebUSBConnection ( { logging } ) ;
44
44
45
45
const host = createHost ( logging ) ;
46
46
const fs = new FileSystem ( logging , host , fetchMicroPython ) ;
Original file line number Diff line number Diff line change @@ -15,13 +15,13 @@ import { useFileSystem } from "../fs/fs-hooks";
15
15
import { useLogging } from "../logging/logging-hooks" ;
16
16
import {
17
17
ConnectionStatus ,
18
- DeviceConnection ,
18
+ MicrobitWebUSBConnection ,
19
19
SerialDataEvent ,
20
20
ConnectionStatusEvent ,
21
21
} from "@microbit/microbit-connection" ;
22
22
import { SimulatorDeviceConnection } from "./simulator" ;
23
23
24
- const DeviceContext = React . createContext < undefined | DeviceConnection > (
24
+ const DeviceContext = React . createContext < undefined | MicrobitWebUSBConnection > (
25
25
undefined
26
26
) ;
27
27
@@ -234,7 +234,7 @@ export const DeviceContextProvider = ({
234
234
value : device ,
235
235
children,
236
236
} : {
237
- value : DeviceConnection ;
237
+ value : MicrobitWebUSBConnection ;
238
238
children : ReactNode ;
239
239
} ) => {
240
240
const syncStatusState = useState < SyncStatus > ( SyncStatus . OUT_OF_SYNC ) ;
Original file line number Diff line number Diff line change 6
6
import {
7
7
BoardVersion ,
8
8
ConnectionStatus ,
9
- DeviceConnection ,
10
9
DeviceConnectionEventMap ,
11
10
FlashDataSource ,
12
11
FlashEvent ,
@@ -15,6 +14,8 @@ import {
15
14
DeviceError ,
16
15
DeviceErrorCode ,
17
16
TypedEventTarget ,
17
+ MicrobitWebUSBConnection ,
18
+ SerialConnectionEventMap ,
18
19
} from "@microbit/microbit-connection" ;
19
20
20
21
/**
@@ -25,8 +26,8 @@ import {
25
26
* the connected state without a real device.
26
27
*/
27
28
export class MockDeviceConnection
28
- extends TypedEventTarget < DeviceConnectionEventMap >
29
- implements DeviceConnection
29
+ extends TypedEventTarget < DeviceConnectionEventMap & SerialConnectionEventMap >
30
+ implements MicrobitWebUSBConnection
30
31
{
31
32
status : ConnectionStatus = ( navigator as any ) . usb
32
33
? ConnectionStatus . NO_AUTHORIZED_DEVICE
@@ -51,6 +52,12 @@ export class MockDeviceConnection
51
52
async initialize ( ) : Promise < void > { }
52
53
53
54
dispose ( ) { }
55
+ getDeviceId ( ) : number | undefined {
56
+ return undefined ;
57
+ }
58
+ setRequestDeviceExclusionFilters ( ) : void { }
59
+ getDevice ( ) { }
60
+ async softwareReset ( ) : Promise < void > { }
54
61
55
62
async connect ( ) : Promise < ConnectionStatus > {
56
63
const next = this . connectResults . shift ( ) ;
Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ import {
7
7
BoardVersion ,
8
8
ConnectionStatus ,
9
9
ConnectionStatusEvent ,
10
- DeviceConnection ,
11
10
DeviceConnectionEventMap ,
12
11
FlashEvent ,
12
+ MicrobitWebUSBConnection ,
13
+ SerialConnectionEventMap ,
13
14
SerialDataEvent ,
14
15
SerialResetEvent ,
15
16
TypedEventTarget ,
@@ -178,8 +179,8 @@ class SimulatorEventMap extends DeviceConnectionEventMap {
178
179
* This communicates with the iframe that is used to embed the simulator.
179
180
*/
180
181
export class SimulatorDeviceConnection
181
- extends TypedEventTarget < SimulatorEventMap >
182
- implements DeviceConnection
182
+ extends TypedEventTarget < SimulatorEventMap & SerialConnectionEventMap >
183
+ implements MicrobitWebUSBConnection
183
184
{
184
185
status : ConnectionStatus = ConnectionStatus . NO_AUTHORIZED_DEVICE ;
185
186
state : SimulatorState | undefined ;
@@ -425,4 +426,12 @@ export class SimulatorDeviceConnection
425
426
"*"
426
427
) ;
427
428
}
429
+
430
+ getDeviceId ( ) : number | undefined {
431
+ return undefined ;
432
+ }
433
+ setRequestDeviceExclusionFilters ( ) : void { }
434
+ async flash ( ) : Promise < void > { }
435
+ getDevice ( ) { }
436
+ async softwareReset ( ) : Promise < void > { }
428
437
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { Text } from "@codemirror/state";
7
7
import * as LSP from "vscode-languageserver-protocol" ;
8
8
import { Action , Diagnostic } from "../lint/lint" ;
9
9
import { positionToOffset } from "./positions" ;
10
- import { DeviceConnection } from "@microbit/microbit-connection" ;
10
+ import { MicrobitWebUSBConnection } from "@microbit/microbit-connection" ;
11
11
12
12
const reportMicrobitVersionApiUnsupported =
13
13
"reportMicrobitVersionApiUnsupported" ;
@@ -22,7 +22,7 @@ const severityMapping = {
22
22
export const diagnosticsMapping = (
23
23
document : Text ,
24
24
lspDiagnostics : LSP . Diagnostic [ ] ,
25
- device : DeviceConnection ,
25
+ device : MicrobitWebUSBConnection ,
26
26
warnOnV2OnlyFeatures : boolean ,
27
27
warnOnV2OnlyFeaturesAction : ( ) => Action
28
28
) : Diagnostic [ ] =>
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import { autocompletion } from "./autocompletion";
17
17
import { BaseLanguageServerView , clientFacet , uriFacet } from "./common" ;
18
18
import { diagnosticsMapping } from "./diagnostics" ;
19
19
import { signatureHelp } from "./signatureHelp" ;
20
- import { DeviceConnection } from "@microbit/microbit-connection" ;
20
+ import { MicrobitWebUSBConnection } from "@microbit/microbit-connection" ;
21
21
22
22
/**
23
23
* The main extension. This synchronises the diagnostics between the client
@@ -60,7 +60,7 @@ class LanguageServerView extends BaseLanguageServerView implements PluginValue {
60
60
61
61
constructor (
62
62
view : EditorView ,
63
- private device : DeviceConnection ,
63
+ private device : MicrobitWebUSBConnection ,
64
64
private intl : IntlShape ,
65
65
private warnOnV2OnlyFeatures : boolean ,
66
66
private disableV2OnlyFeaturesWarning : ( ) => void
@@ -126,7 +126,7 @@ interface Actions {
126
126
*/
127
127
export function languageServer (
128
128
client : LanguageServerClient ,
129
- device : DeviceConnection ,
129
+ device : MicrobitWebUSBConnection ,
130
130
uri : string ,
131
131
intl : IntlShape ,
132
132
logging : Logging ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { ActionFeedback } from "../common/use-action-feedback";
19
19
import { Dialogs } from "../common/use-dialogs" ;
20
20
import {
21
21
ConnectionStatus ,
22
- DeviceConnection ,
22
+ MicrobitWebUSBConnection ,
23
23
AfterRequestDevice ,
24
24
FlashDataError ,
25
25
DeviceError ,
@@ -105,7 +105,7 @@ export enum ConnectionAction {
105
105
export class ProjectActions {
106
106
constructor (
107
107
private fs : FileSystem ,
108
- private device : DeviceConnection ,
108
+ private device : MicrobitWebUSBConnection ,
109
109
private actionFeedback : ActionFeedback ,
110
110
private dialogs : Dialogs ,
111
111
private setSelection : ( selection : WorkbenchSelection ) => void ,
Original file line number Diff line number Diff line change 3
3
*
4
4
* SPDX-License-Identifier: MIT
5
5
*/
6
+ import { MicrobitWebUSBConnection } from "@microbit/microbit-connection" ;
6
7
import { Terminal } from "xterm" ;
7
- import { DeviceConnection } from "@microbit/microbit-connection" ;
8
8
import { Logging } from "../logging/logging" ;
9
9
10
10
/**
@@ -13,7 +13,7 @@ import { Logging } from "../logging/logging";
13
13
export class SerialActions {
14
14
constructor (
15
15
private terminal : React . RefObject < Terminal | undefined > ,
16
- private device : DeviceConnection ,
16
+ private device : MicrobitWebUSBConnection ,
17
17
private onSerialSizeChange : ( size : "compact" | "open" ) => void ,
18
18
private logging : Logging
19
19
) { }
You can’t perform that action at this time.
0 commit comments