-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat-panel): add vscode bundle script (#2206)
* feat(chat-panel): add vscode bundle script * update * update * update iframe size * rename * update * update * update * add comment * clean * update lock * build
- Loading branch information
Showing
8 changed files
with
531 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import antfu from '@antfu/eslint-config' | ||
|
||
export default antfu() | ||
export default antfu({ | ||
rules: { | ||
curly: ['off', 'all'], | ||
}, | ||
}) |
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,53 @@ | ||
import * as React from 'react' | ||
import { createRoot } from 'react-dom/client' | ||
|
||
import { useClient } from './react' | ||
|
||
declare global { | ||
interface Window { | ||
token?: string | ||
endpoint?: string | ||
} | ||
} | ||
|
||
function ChatPanel() { | ||
const [endpoint, setEndpoint] = React.useState('') | ||
const [token, setToken] = React.useState('') | ||
const iframeRef = React.useRef<HTMLIFrameElement>(null) | ||
|
||
const client = useClient(iframeRef, { | ||
navigate: () => { | ||
// FIXME(wwayne): Send message to VSCode webview to invoke VSCode API | ||
}, | ||
}) | ||
|
||
React.useEffect(() => { | ||
setEndpoint(window.endpoint || '') | ||
setToken(window.token || '') | ||
}, []) | ||
|
||
React.useEffect(() => { | ||
if (iframeRef?.current && token) { | ||
client?.init({ | ||
fetcherOptions: { | ||
authorization: token, | ||
}, | ||
}) | ||
} | ||
}, [iframeRef?.current, client, token]) | ||
|
||
return ( | ||
<iframe | ||
src={`${endpoint}/chat`} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
}} | ||
ref={iframeRef} | ||
/> | ||
) | ||
} | ||
|
||
createRoot(document.getElementById('root') as HTMLElement).render( | ||
<ChatPanel />, | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ generated | |
.vscode-test/ | ||
.vscode-test-web/ | ||
*.vsix | ||
chat-panel/ |
Oops, something went wrong.