-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add new execute command (#16)
* feature: add new execute command * fix * rename * simplify code * remove unused code * build * remove unused code * build * build * build
- Loading branch information
Showing
16 changed files
with
38 additions
and
113 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 was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/extension/src/parts/FilterAggregates/FilterAggregates.ts
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
packages/extension/src/parts/GetOrCreateWorker/GetOrCreateWorker.ts
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/extension/src/parts/LaunchRestClientWorker/LaunchRestClientWorker.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1 @@ | ||
import * as RestClientWorker from '../RestClientWorker/RestClientWorker.ts' | ||
|
||
const webViewProvider = { | ||
id: 'builtin.rest-client', | ||
async create(webView, uri) { | ||
// @ts-ignore | ||
const content = await vscode.readFile(uri) | ||
const [method, url] = content.split(' ') | ||
await webView.invoke('initialize', method, url) | ||
// @ts-ignore | ||
this.webView = webView | ||
}, | ||
async open(uri, webView) {}, | ||
commands: { | ||
async handleSubmit(method, url) { | ||
const result = await RestClientWorker.invoke('RestClient.execute', method, url) | ||
// @ts-ignore | ||
const webView = webViewProvider.webView | ||
await webView.invoke('setOutput', result) | ||
}, | ||
}, | ||
} | ||
|
||
export const activate = () => { | ||
// @ts-ignore | ||
vscode.registerWebViewProvider(webViewProvider) | ||
} | ||
export const activate = () => {} |
6 changes: 0 additions & 6 deletions
6
packages/extension/src/parts/RestClientWorker/RestClientWorker.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
packages/extension/src/parts/RestClientWorkerUrl/RestClientWorkerUrl.ts
This file was deleted.
Oops, something went wrong.
10 changes: 8 additions & 2 deletions
10
packages/rest-client-worker/src/parts/CommandMap/CommandMap.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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import * as Execute from '../Execute/Execute.ts' | ||
import * as Create2 from '../Create2/Create2.ts' | ||
import * as Execute from '../Execute/Execute.ts' | ||
import * as Execute2 from '../Execute2/Execute2.ts' | ||
import * as WrapCommand from '../WrapCommand/WrapCommand.ts' | ||
|
||
export const commandMap = { | ||
'RestClient.execute': Execute.execute, | ||
// new | ||
handleSubmit: WrapCommand.wrapCommand(Execute2.execute2), | ||
'Webview.create': Create2.create2, | ||
|
||
// old | ||
'RestClient.execute': Execute.execute, | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import type { WebView } from '../WebView/WebView.ts' | ||
import * as WebViewStates from '../WebViewStates/WebViewStates.ts' | ||
|
||
export const create = (id: number, port: MessagePort): void => { | ||
export const create = (id: number, port: MessagePort, method: string, url: string): void => { | ||
const webview: WebView = { | ||
port, | ||
method, | ||
url, | ||
} | ||
WebViewStates.set(id, webview) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as Execute from '../Execute/Execute.ts' | ||
import * as WebViewStates from '../WebViewStates/WebViewStates.ts' | ||
|
||
export const execute2 = async (id: number) => { | ||
const { method, url, port } = WebViewStates.get(id) | ||
const result = await Execute.execute(method, url) | ||
await port.invoke('setOutput', result) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export interface WebView { | ||
readonly port: any | ||
readonly method: string | ||
readonly url: string | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/rest-client-worker/src/parts/WrapCommand/WrapCommand.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,7 @@ | ||
import { id } from '../Id/Id.ts' | ||
|
||
export const wrapCommand = (fn) => { | ||
return async (...args) => { | ||
await fn(id, ...args) | ||
} | ||
} |