cursor-feedback 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,134 @@
1
+ import * as vscode from 'vscode';
2
+
3
+ /**
4
+ * 独立的反馈面板(用于在编辑器区域显示)
5
+ */
6
+ export class FeedbackPanel {
7
+ public static currentPanel: FeedbackPanel | undefined;
8
+ public static readonly viewType = 'cursorFeedback';
9
+
10
+ private readonly _panel: vscode.WebviewPanel;
11
+ private readonly _extensionUri: vscode.Uri;
12
+ private _disposables: vscode.Disposable[] = [];
13
+
14
+ public static createOrShow(extensionUri: vscode.Uri) {
15
+ const column = vscode.window.activeTextEditor
16
+ ? vscode.window.activeTextEditor.viewColumn
17
+ : undefined;
18
+
19
+ // 如果面板已存在,显示它
20
+ if (FeedbackPanel.currentPanel) {
21
+ FeedbackPanel.currentPanel._panel.reveal(column);
22
+ return;
23
+ }
24
+
25
+ // 创建新面板
26
+ const panel = vscode.window.createWebviewPanel(
27
+ FeedbackPanel.viewType,
28
+ 'Cursor Feedback',
29
+ column || vscode.ViewColumn.One,
30
+ {
31
+ enableScripts: true,
32
+ localResourceRoots: [extensionUri],
33
+ retainContextWhenHidden: true,
34
+ }
35
+ );
36
+
37
+ FeedbackPanel.currentPanel = new FeedbackPanel(panel, extensionUri);
38
+ }
39
+
40
+ private constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
41
+ this._panel = panel;
42
+ this._extensionUri = extensionUri;
43
+
44
+ // 设置 HTML 内容
45
+ this._update();
46
+
47
+ // 监听面板关闭
48
+ this._panel.onDidDispose(() => this.dispose(), null, this._disposables);
49
+
50
+ // 监听面板状态变化
51
+ this._panel.onDidChangeViewState(
52
+ () => {
53
+ if (this._panel.visible) {
54
+ this._update();
55
+ }
56
+ },
57
+ null,
58
+ this._disposables
59
+ );
60
+
61
+ // 处理来自 webview 的消息
62
+ this._panel.webview.onDidReceiveMessage(
63
+ (message) => {
64
+ switch (message.type) {
65
+ case 'submitFeedback':
66
+ vscode.window.showInformationMessage(
67
+ `Feedback received: ${message.payload.interactive_feedback}`
68
+ );
69
+ break;
70
+ }
71
+ },
72
+ null,
73
+ this._disposables
74
+ );
75
+ }
76
+
77
+ public dispose() {
78
+ FeedbackPanel.currentPanel = undefined;
79
+
80
+ this._panel.dispose();
81
+
82
+ while (this._disposables.length) {
83
+ const x = this._disposables.pop();
84
+ if (x) {
85
+ x.dispose();
86
+ }
87
+ }
88
+ }
89
+
90
+ private _update() {
91
+ const webview = this._panel.webview;
92
+ this._panel.title = 'Cursor Feedback';
93
+ this._panel.webview.html = this._getHtmlForWebview(webview);
94
+ }
95
+
96
+ private _getHtmlForWebview(webview: vscode.Webview): string {
97
+ return `<!DOCTYPE html>
98
+ <html lang="zh-CN">
99
+ <head>
100
+ <meta charset="UTF-8">
101
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
102
+ <title>Cursor Feedback</title>
103
+ <style>
104
+ body {
105
+ font-family: var(--vscode-font-family);
106
+ padding: 20px;
107
+ color: var(--vscode-foreground);
108
+ background-color: var(--vscode-editor-background);
109
+ }
110
+
111
+ h1 {
112
+ color: var(--vscode-foreground);
113
+ border-bottom: 1px solid var(--vscode-panel-border);
114
+ padding-bottom: 10px;
115
+ }
116
+
117
+ .info {
118
+ background: var(--vscode-textBlockQuote-background);
119
+ padding: 15px;
120
+ border-radius: 4px;
121
+ margin: 20px 0;
122
+ }
123
+ </style>
124
+ </head>
125
+ <body>
126
+ <h1>Cursor Feedback Panel</h1>
127
+ <div class="info">
128
+ <p>此面板用于显示独立的反馈界面。</p>
129
+ <p>通常情况下,请使用侧边栏中的反馈面板进行交互。</p>
130
+ </div>
131
+ </body>
132
+ </html>`;
133
+ }
134
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "ES2020",
5
+ "outDir": "dist",
6
+ "lib": ["ES2020"],
7
+ "sourceMap": true,
8
+ "rootDir": "src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }