lenses.ts (hoppscotch-2.2.1) | : | lenses.ts (hoppscotch-3.0.0) | ||
---|---|---|---|---|
import { HoppRESTResponse } from "../types/HoppRESTResponse" | import { HoppRESTResponse } from "../types/HoppRESTResponse" | |||
import jsonLens from "./jsonLens" | import jsonLens from "./jsonLens" | |||
import rawLens from "./rawLens" | import rawLens from "./rawLens" | |||
import imageLens from "./imageLens" | import imageLens from "./imageLens" | |||
import htmlLens from "./htmlLens" | import htmlLens from "./htmlLens" | |||
import xmlLens from "./xmlLens" | import xmlLens from "./xmlLens" | |||
import pdfLens from "./pdfLens" | ||||
import { defineAsyncComponent } from "vue" | ||||
export type Lens = { | export type Lens = { | |||
lensName: string | lensName: string | |||
isSupportedContentType: (contentType: string) => boolean | isSupportedContentType: (contentType: string) => boolean | |||
renderer: string | renderer: string | |||
rendererImport: () => Promise<typeof import("*.vue")> | rendererImport: ReturnType<typeof defineAsyncComponent> | |||
} | } | |||
export const lenses: Lens[] = [jsonLens, imageLens, htmlLens, xmlLens, rawLens] | export const lenses: Lens[] = [ | |||
jsonLens, | ||||
imageLens, | ||||
htmlLens, | ||||
xmlLens, | ||||
pdfLens, | ||||
rawLens, | ||||
] | ||||
export function getSuitableLenses(response: HoppRESTResponse): Lens[] { | export function getSuitableLenses(response: HoppRESTResponse): Lens[] { | |||
// return empty array if response is loading or error | // return empty array if response is loading or error | |||
if ( | if ( | |||
response.type === "loading" || | response.type === "loading" || | |||
response.type === "network_fail" || | response.type === "network_fail" || | |||
response.type === "script_fail" || | response.type === "script_fail" || | |||
response.type === "fail" | response.type === "fail" | |||
) | ) | |||
return [] | return [] | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 11 lines changed or added |