Saoud Rizwan 1 год назад
Родитель
Сommit
c1012dcd99
2 измененных файлов с 5 добавлено и 36 удалено
  1. 1 36
      src/providers/ClaudeDevProvider.ts
  2. 4 0
      src/utils/index.ts

+ 1 - 36
src/providers/ClaudeDevProvider.ts

@@ -1,12 +1,9 @@
 import * as vscode from "vscode"
-import { Uri, Webview } from "vscode"
 import { ClaudeDev } from "../ClaudeDev"
 import { ApiProvider } from "../shared/api"
 import { ExtensionMessage } from "../shared/ExtensionMessage"
 import { WebviewMessage } from "../shared/WebviewMessage"
-import { downloadTask } from "../utils/export-markdown"
-import { selectImages } from "../utils/process-images"
-
+import { downloadTask, getNonce, getUri, selectImages } from "../utils"
 /*
 https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
 
@@ -500,35 +497,3 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
 		return await this.context.secrets.get(key)
 	}
 }
-
-/**
- * A helper function that returns a unique alphanumeric identifier called a nonce.
- *
- * @remarks This function is primarily used to help enforce content security
- * policies for resources/scripts being executed in a webview context.
- *
- * @returns A nonce
- */
-export function getNonce() {
-	let text = ""
-	const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
-	for (let i = 0; i < 32; i++) {
-		text += possible.charAt(Math.floor(Math.random() * possible.length))
-	}
-	return text
-}
-
-/**
- * A helper function which will get the webview URI of a given file or resource.
- *
- * @remarks This URI can be used within a webview's HTML as a link to the
- * given file/resource.
- *
- * @param webview A reference to the extension webview
- * @param extensionUri The URI of the directory containing the extension
- * @param pathList An array of strings representing the path to a file/resource
- * @returns A URI pointing to the file/resource
- */
-export function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
-	return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList))
-}

+ 4 - 0
src/utils/index.ts

@@ -0,0 +1,4 @@
+export * from "./getNonce"
+export * from "./getUri"
+export * from "./process-images"
+export * from "./export-markdown"