Skip to content

Commit 4695007

Browse files
committed
feat: add explo.showView command to VS Code extension (#2)
1 parent 207760d commit 4695007

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1212
-62
lines changed

.github/workflows/ci.yaml

+55-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
env:
1212
MELOS_VERSION: 1.0.0-dev.14
13+
EXPLO_CODE_DIR: explo-code
1314

1415
jobs:
1516
formatting-prettier:
@@ -19,8 +20,6 @@ jobs:
1920

2021
- name: Setup node
2122
uses: actions/setup-node@v2
22-
with:
23-
node-version: 16.0
2423

2524
- name: Install npm dependencies
2625
run: npm ci
@@ -43,3 +42,57 @@ jobs:
4342

4443
- name: Check formatting
4544
run: melos run formatting:check
45+
46+
explo-code-lint:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Setup node
52+
uses: actions/setup-node@v2
53+
54+
- name: Install npm dependencies
55+
working-directory: ${{ env.EXPLO_CODE_DIR }}
56+
run: npm ci
57+
58+
- name: Run linter
59+
working-directory: ${{ env.EXPLO_CODE_DIR }}
60+
run: npm run lint
61+
62+
explo-code-tests:
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
runs-on: [ubuntu-latest, macos-latest, windows-latest]
67+
runs-on: ${{ matrix.runs-on }}
68+
steps:
69+
- uses: actions/checkout@v2
70+
71+
- name: Setup node
72+
uses: actions/setup-node@v2
73+
74+
- name: Install npm dependencies
75+
working-directory: ${{ env.EXPLO_CODE_DIR }}
76+
run: npm ci
77+
78+
- name: Setup Flutter
79+
uses: subosito/flutter-action@v1
80+
81+
- name: Install melos
82+
run: dart pub global activate melos $MELOS_VERSION
83+
84+
- name: Build explo_ide_view
85+
shell: bash
86+
run: |
87+
./tools/explo_ide_view.sh build
88+
./tools/explo_ide_view.sh copyToExploCode
89+
90+
- name: Start Xvfb
91+
if: runner.os == 'Linux'
92+
run: |
93+
Xvfb :99 -screen 0 1280x1024x24 &
94+
echo "DISPLAY=:99" >> "$GITHUB_ENV"
95+
96+
- name: Run tests
97+
working-directory: ${{ env.EXPLO_CODE_DIR }}
98+
run: npm test

.prettierignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
.vscode-test
2+
.dart_tool
13
node_modules
24
build
35
dist
6+
out
47
coverage
5-
.dart_tool
68
*.xcassets
7-
CHANGELOG.md
9+
CHANGELOG.md

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Monorepo for explo, a tool which allows you to explore the render tree of a
22
Flutter app in 3D, through an exploded representation
33

4-
| Component | Description | Location | Published at |
5-
| ------------- | ---------------------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------- |
6-
| explo | Flutter package to receive captured render tree data and visualize it. | [packages/explo](./packages/explo) | [![pub.dev](https://badgen.net/pub/v/explo)](https://pub.dev/packages/explo) |
7-
| explo_capture | Flutter package to capture render tree data in a Flutter app. | [packages/explo_capture](./packages/explo_capture) | [![pub.dev](https://badgen.net/pub/v/explo_capture)](https://pub.dev/packages/explo_capture) |
4+
| Component | Description | Location | Published at |
5+
| -------------- | ---------------------------------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
6+
| explo | Flutter package to receive captured render tree data and visualize it. | [packages/explo](./packages/explo) | [![pub.dev](https://badgen.net/pub/v/explo)](https://pub.dev/packages/explo) |
7+
| explo_capture | Flutter package to capture render tree data in a Flutter app. | [packages/explo_capture](./packages/explo_capture) | [![pub.dev](https://badgen.net/pub/v/explo_capture)](https://pub.dev/packages/explo_capture) |
8+
| explo_ide_view | Explo web view for IDE plugins. | [packages/explo_ide_view](./packages/explo_ide_view) | |
9+
| explo-code | VS Code extension to add support for Explo | [explo-code](./explo-code) | [![VS Marketplace](https://badgen.net/vs-marketplace/v/blaugold.explo-code)](https://marketplace.visualstudio.com/items?itemName=blaugold.explo-code) |

explo-code/.vscode/launch.json

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,31 @@
1111
"request": "launch",
1212
"args": [
1313
"--extensionDevelopmentPath=${workspaceFolder}",
14-
"${workspaceFolder}/.."
14+
"${workspaceFolder}/src/test/workspaces/hello_flutter"
1515
],
1616
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
17-
"preLaunchTask": "${defaultBuildTask}"
17+
"preLaunchTask": "${defaultBuildTask}",
18+
"env": {
19+
"EXPLO_CODE_DEV_MODE": "true"
20+
}
1821
},
1922
{
2023
"name": "Extension Tests",
2124
"type": "extensionHost",
2225
"request": "launch",
2326
"args": [
2427
"--extensionDevelopmentPath=${workspaceFolder}",
25-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
28+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
29+
"${workspaceFolder}/src/test/workspaces/hello_flutter"
2630
],
2731
"outFiles": [
2832
"${workspaceFolder}/out/**/*.js",
2933
"${workspaceFolder}/dist/**/*.js"
3034
],
31-
"preLaunchTask": "tasks: watch-tests"
35+
"preLaunchTask": "tasks: watch-tests",
36+
"env": {
37+
"EXPLO_CODE_DEV_MODE": "true"
38+
}
3239
}
3340
]
3441
}

explo-code/package.json

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "explo-code",
3+
"publisher": "blaugold",
34
"displayName": "Explo",
45
"description": "",
56
"version": "0.0.1",
@@ -10,20 +11,30 @@
1011
"Other"
1112
],
1213
"activationEvents": [
13-
"onDebug"
14+
"onStartupFinished"
1415
],
1516
"main": "./dist/extension.js",
1617
"contributes": {
17-
"commands": []
18+
"commands": [
19+
{
20+
"command": "explo.openView",
21+
"title": "Open view",
22+
"category": "Explo",
23+
"enablement": "inDebugMode && debugType == 'dart'"
24+
}
25+
]
1826
},
27+
"extensionDependencies": [
28+
"Dart-Code.dart-code"
29+
],
1930
"scripts": {
20-
"vscode:prepublish": "npm run package",
31+
"vscode:prepublish": "melos run explo_ide_view:vs_code && npm run package",
2132
"compile": "webpack",
2233
"watch": "webpack --watch",
2334
"package": "webpack --mode production --devtool hidden-source-map",
2435
"compile-tests": "tsc -p . --outDir out",
2536
"watch-tests": "tsc -p . -w --outDir out",
26-
"pretest": "npm run compile-tests && npm run compile && npm run lint",
37+
"pretest": "npm run compile-tests && npm run compile",
2738
"lint": "eslint src --ext ts",
2839
"test": "node ./out/test/runTest.js"
2940
},

explo-code/src/api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const exploViewCommandsSymbol = Symbol.for('exploViewCommands')

explo-code/src/explo_debug_session.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import {
33
DebugSession,
44
DebugSessionCustomEvent,
55
Disposable,
6+
EventEmitter,
67
workspace,
78
} from 'vscode'
89
import { isFlutterDebugSession } from './dart_debug_session'
910
import { Logger } from './logging'
10-
import { disposeAll } from './utils/basic'
11+
import { disposeAll } from './utils/resources'
1112

1213
/**
1314
* Coordinates debug sessions between apps that are capturing render tree data
@@ -25,20 +26,28 @@ export class ExploDebugSessionsCoordinator implements Disposable {
2526
this.subscriptions.push(
2627
debug.onDidReceiveDebugSessionCustomEvent(this.handleCustomEvent, this)
2728
)
29+
30+
this.subscriptions.push(this.didTerminateSessionEmitter)
2831
}
2932

3033
private readonly subscriptions: Disposable[] = []
3134

32-
private activeSession: ExploDebugSession[] = []
35+
readonly activeSession: ExploDebugSession[] = []
3336

34-
private get viewerSessions(): ExploDebugSession[] {
37+
get viewerSessions(): ExploDebugSession[] {
3538
return this.activeSession.filter((session) => session.isViewerApp)
3639
}
3740

38-
private get nonViewerSessions(): ExploDebugSession[] {
41+
get nonViewerSessions(): ExploDebugSession[] {
3942
return this.activeSession.filter((session) => !session.isViewerApp)
4043
}
4144

45+
private onDidMakeSessionReadyEmitter = new EventEmitter<ExploDebugSession>()
46+
onDidMakeSessionReady = this.onDidMakeSessionReadyEmitter.event
47+
48+
private didTerminateSessionEmitter = new EventEmitter<ExploDebugSession>()
49+
didTerminateSession = this.didTerminateSessionEmitter.event
50+
4251
private handleSessionStart(session: DebugSession) {
4352
if (!isFlutterDebugSession(session)) {
4453
return
@@ -61,6 +70,7 @@ export class ExploDebugSessionsCoordinator implements Disposable {
6170
this.activeSession.splice(this.activeSession.indexOf(exploSession), 1)
6271

6372
this.handleExploSessionEnd(exploSession)
73+
this.didTerminateSessionEmitter.fire(exploSession)
6474
}
6575

6676
private handleCustomEvent(event: DebugSessionCustomEvent) {
@@ -75,6 +85,7 @@ export class ExploDebugSessionsCoordinator implements Disposable {
7585
exploSession.vmServiceUri = event.body.vmServiceUri
7686

7787
this.handleExploSessionReady(exploSession)
88+
this.onDidMakeSessionReadyEmitter.fire(exploSession)
7889
} else if (
7990
event.event === 'dart.serviceExtensionAdded' &&
8091
event.body.extensionRPC === 'ext.explo.removeTargetApp'
@@ -145,23 +156,30 @@ export class ExploDebugSessionsCoordinator implements Disposable {
145156
}
146157
}
147158

148-
interface TargetApp {
159+
export interface TargetApp {
149160
id: string
150161
label: string
151162
vmServiceUri: string
152163
}
153164

154-
class ExploDebugSession {
165+
export class ExploDebugSession {
155166
constructor(public readonly session: DebugSession) {
156167
const program = this.session.configuration.program as string
157168
this.label = workspace
158169
.asRelativePath(program)
159170
.replace(/\/lib\/.*\.dart/g, '')
160171
}
161172

162-
label: string
173+
readonly label: string
174+
163175
vmServiceUri?: string
176+
164177
isolateId?: string
178+
179+
get isReady(): boolean {
180+
return this.vmServiceUri !== undefined
181+
}
182+
165183
isViewerApp?: boolean
166184

167185
get targetApp(): TargetApp {

0 commit comments

Comments
 (0)