Skip to content

Commit aa83f84

Browse files
committed
temp [ci skip]
1 parent 404c6b3 commit aa83f84

6 files changed

Lines changed: 10 additions & 759 deletions

File tree

tooling/vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"label": "react-dev",
27-
"script": "dev",
27+
"script": "build:watch",
2828
"type": "npm",
2929
"options": {
3030
"cwd": "${workspaceFolder}/vscode/react"

vscode/extension/src/webviews/lineagePanel.ts

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Callback, CallbackEvent } from '@bus/callbacks'
1+
import { CallbackEvent } from '@bus/callbacks'
22
import {
33
Disposable,
44
Uri,
@@ -58,7 +58,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
5858
// Set up message listener for events from the iframe
5959
webviewView.webview.onDidReceiveMessage(
6060
async request => {
61-
console.log('received message', request)
6261
if (!request) {
6362
return
6463
}
@@ -82,7 +81,7 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
8281
const requestId = message.payload.requestId
8382
const response = await this.lsp.call_custom_method(
8483
'sqlmesh/api',
85-
payload,
84+
payload as any,
8685
)
8786
webviewView.webview.postMessage({
8887
key: 'query_response',
@@ -101,73 +100,10 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
101100
undefined,
102101
[],
103102
)
104-
105-
webviewView.webview.html = isProduction()
106-
? this.getProductionHTML(webviewView.webview)
107-
: this.getHtml()
108-
}
109-
110-
externalUrlAndAutority(): { externalUrl: string; externalAuthority: string } {
111-
const isProd = isProduction()
112-
if (isProd) {
113-
throw new Error(
114-
'External url and authority is not supported in production mode',
115-
)
116-
}
117-
const externalUrl = 'http://localhost:5173/lineage'
118-
const externalAuthority = new URL(externalUrl).origin
119-
return { externalUrl, externalAuthority }
120-
}
121-
122-
getHtml() {
123-
const { externalUrl, externalAuthority } = this.externalUrlAndAutority()
124-
// The CSP is too restrictive - it only allows frame-src but no other resources
125-
// Adding connect-src for API calls, img-src for images, and style-src for CSS
126-
return `
127-
<!DOCTYPE html>
128-
<html>
129-
<head>
130-
<script>
131-
// Listen for messages from the iframe and forward them to the extension
132-
window.addEventListener('message', (event) => {
133-
// Forward messages from the iframe to the extension
134-
const message = event.data;
135-
if (message && message.key) {
136-
// Post the message to the extension host
137-
vscode.postMessage(message);
138-
}
139-
});
140-
141-
// Define a function to handle events from the extension and send them to the iframe
142-
const vscode = acquireVsCodeApi();
143-
vscode.postMessage = function(message) {
144-
// Forward the message to the iframe
145-
const iframe = document.querySelector('iframe');
146-
if (iframe && iframe.contentWindow) {
147-
iframe.contentWindow.postMessage(message, '*');
148-
}
149-
};
150-
151-
// Listen for messages from the extension
152-
window.addEventListener('message', (event) => {
153-
// Only handle messages that are from the extension
154-
if (event.data && event.data.key === 'vscode_send' || event.data.key === 'query_response') {
155-
const iframe = document.querySelector('iframe');
156-
if (iframe && iframe.contentWindow) {
157-
iframe.contentWindow.postMessage(event.data, '*');
158-
}
159-
}
160-
});
161-
</script>
162-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; frame-src ${externalAuthority}; connect-src ${externalAuthority}; img-src ${externalAuthority} data:; script-src 'unsafe-inline' ${externalAuthority}; style-src 'unsafe-inline' ${externalAuthority};">
163-
</head>
164-
<body>
165-
<iframe src="${externalUrl}" style="width:100%; height:100vh;" frameborder="0" allow="clipboard-read; clipboard-write"></iframe>
166-
</body>
167-
</html> `
103+
webviewView.webview.html = this.getHTML(webviewView.webview)
168104
}
169105

170-
private getProductionHTML(panel: Webview) {
106+
private getHTML(panel: Webview) {
171107
const cssUri = panel.asWebviewUri(
172108
Uri.joinPath(this._extensionUri, 'src_react', 'assets', 'index.css'),
173109
)
@@ -177,9 +113,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
177113
const faviconUri = panel.asWebviewUri(
178114
Uri.joinPath(this._extensionUri, 'src_react', 'favicon.ico'),
179115
)
180-
const manifestUri = panel.asWebviewUri(
181-
Uri.joinPath(this._extensionUri, 'src_react', 'manifest.json'),
182-
)
183116
const logoUri = panel.asWebviewUri(
184117
Uri.joinPath(this._extensionUri, 'src_react', 'logo192.png'),
185118
)
@@ -199,7 +132,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
199132
content="Web site created using create-tsrouter-app"
200133
/>
201134
<link rel="apple-touch-icon" href="${logoUri}" />
202-
<link rel="manifest" href="${manifestUri}" />
203135
<title>Create TanStack App - react</title>
204136
<script type="module" crossorigin src="${jsUri}"></script>
205137
<link rel="stylesheet" crossorigin href="${cssUri}">

vscode/react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"start": "vite --port 3000",
77
"dev": "vite",
88
"build": "vite build",
9+
"build:watch": "vite build --watch --outDir ./../extension/src_react --emptyOutDir",
910
"serve": "vite preview",
1011
"test": "vitest run",
1112
"generate:api": "orval --config ./orval.config.ts",

0 commit comments

Comments
 (0)