vzcode 1.43.0 → 1.44.0

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,32 @@
1
+ import { useCallback, useState } from 'react';
2
+
3
+ // Custom hook to manage runtime error state
4
+ export const useRuntimeError = () => {
5
+ // State to hold the runtime error message
6
+ // `null` means no errors
7
+ // If this is a string, it's the
8
+ // error message from runtime execution.
9
+ const [runtimeError, setRuntimeError] = useState<
10
+ string | null
11
+ >(null);
12
+
13
+ // Callback function to handle runtime errors
14
+ // This will be passed to the createRuntime function
15
+ const handleRuntimeError = useCallback(
16
+ (formattedErrorMessage: string) => {
17
+ setRuntimeError(formattedErrorMessage);
18
+ },
19
+ [],
20
+ );
21
+
22
+ // Function to clear runtime errors
23
+ const clearRuntimeError = useCallback(() => {
24
+ setRuntimeError(null);
25
+ }, []);
26
+
27
+ return {
28
+ runtimeError,
29
+ handleRuntimeError,
30
+ clearRuntimeError,
31
+ };
32
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Utility function to check if a file is an image based on its name.
3
+ * @param fileName - The name of the file (e.g., "image.png", "photo.jpg")
4
+ * @returns true if the file is an image, false otherwise
5
+ */
6
+ export const isImageFile = (fileName: string): boolean => {
7
+ return (
8
+ fileName.match(
9
+ /\.(png|jpg|jpeg|gif|bmp|svg|webp)$/i,
10
+ ) !== null
11
+ );
12
+ };