AI-native design editor. Open-source Figma alternative.
fix(app): use callable fetch adapter type (#535)
Danila Poyarkov97bc86fa70f1
diff --git a/src/app/ai/chat/model.ts b/src/app/ai/chat/model.tsindex 62f35f7a0..c3c235e0e 100644--- a/src/app/ai/chat/model.ts+++ b/src/app/ai/chat/model.ts@@ -2,6 +2,7 @@ import type { LanguageModel } from 'ai'import { modelProviderAdapter } from '@/app/ai/providers/registry'import type { ModelConfig } from '@/app/ai/providers/types'+import type { FetchFunction } from '@/app/http/types'import { isTauri } from '@/app/tauri/env'import { tauriFetch } from '@/app/tauri/http'@@ -20,7 +21,7 @@ export function resolveLanguageModelID(return config.modelID}-function desktopFetch(): typeof fetch | undefined {+function desktopFetch(): FetchFunction | undefined {return isTauri() ? tauriFetch : undefined}diff --git a/src/app/ai/providers/types.ts b/src/app/ai/providers/types.tsindex bdfaf2692..0eb83641f 100644--- a/src/app/ai/providers/types.ts+++ b/src/app/ai/providers/types.ts@@ -2,6 +2,8 @@ import type { LanguageModel } from 'ai'import type { AIProviderID } from '@open-pencil/core/constants'+import type { FetchFunction } from '@/app/http/types'+export type ModelConfig = {providerID: AIProviderIDapiKey: string@@ -12,7 +14,7 @@ export type ModelConfig = {}export type ModelProviderRuntime = {- fetch?: typeof fetch+ fetch?: FetchFunction}export interface ModelProviderAdapter {diff --git a/src/app/http/types.ts b/src/app/http/types.tsnew file mode 100644index 000000000..fc54c0116--- /dev/null+++ b/src/app/http/types.ts@@ -0,0 +1 @@+export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>diff --git a/src/app/tauri/http.ts b/src/app/tauri/http.tsindex 3a4227f9a..29fefb760 100644--- a/src/app/tauri/http.ts+++ b/src/app/tauri/http.ts@@ -1,3 +1,5 @@+import type { FetchFunction } from '@/app/http/types'+export interface ProxyHttpHeader {name: stringvalue: string@@ -72,7 +74,7 @@ export interface TauriFetchOptions {maxResponseBytes?: number}-export function createTauriFetch(options: TauriFetchOptions = {}): typeof fetch {+export function createTauriFetch(options: TauriFetchOptions = {}): FetchFunction {return (input, init) => tauriFetch(input, init, options.maxResponseBytes, options.timeoutMs)}