diff --git a/packages/hoppscotch-common/src/components/app/WhatsNewDialog.vue b/packages/hoppscotch-common/src/components/app/WhatsNewDialog.vue index 44fb5dce..c0b65972 100644 --- a/packages/hoppscotch-common/src/components/app/WhatsNewDialog.vue +++ b/packages/hoppscotch-common/src/components/app/WhatsNewDialog.vue @@ -48,7 +48,8 @@ defineEmits<{ }>() const openWhatsNew = () => { - if (props.notesUrl) platform.kernelIO.openExternalLink(props.notesUrl) + if (props.notesUrl) + platform.kernelIO.openExternalLink({ url: props.notesUrl }) } diff --git a/packages/hoppscotch-common/src/components/collections/ImportExport.vue b/packages/hoppscotch-common/src/components/collections/ImportExport.vue index ced13a9b..66268a4b 100644 --- a/packages/hoppscotch-common/src/components/collections/ImportExport.vue +++ b/packages/hoppscotch-common/src/components/collections/ImportExport.vue @@ -625,7 +625,7 @@ const HoppGistCollectionsExporter: ImporterOrExporter = { platform: "rest", }) - platform.kernelIO.openExternalLink(res.right) + platform.kernelIO.openExternalLink({ url: res.right }) } else { toast.error(collectionJSON.left) } diff --git a/packages/hoppscotch-common/src/components/collections/graphql/ImportExport.vue b/packages/hoppscotch-common/src/components/collections/graphql/ImportExport.vue index 2934197d..94d13ba7 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/ImportExport.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/ImportExport.vue @@ -208,7 +208,7 @@ const GqlCollectionsGistExporter: ImporterOrExporter = { exporter: "gist", }) - platform.kernelIO.openExternalLink(res.right) + platform.kernelIO.openExternalLink({ url: res.right }) } isGqlCollectionGistExportInProgress.value = false diff --git a/packages/hoppscotch-common/src/components/environments/ImportExport.vue b/packages/hoppscotch-common/src/components/environments/ImportExport.vue index 12210863..2f61a49c 100644 --- a/packages/hoppscotch-common/src/components/environments/ImportExport.vue +++ b/packages/hoppscotch-common/src/components/environments/ImportExport.vue @@ -328,7 +328,7 @@ const HoppEnvironmentsGistExporter: ImporterOrExporter = { platform: "rest", }) - platform.kernelIO.openExternalLink(res.right) + platform.kernelIO.openExternalLink({ url: res.right }) } isEnvironmentGistExportInProgress.value = false diff --git a/packages/hoppscotch-common/src/platform/kernel-io.ts b/packages/hoppscotch-common/src/platform/kernel-io.ts index be168940..dbefeef8 100644 --- a/packages/hoppscotch-common/src/platform/kernel-io.ts +++ b/packages/hoppscotch-common/src/platform/kernel-io.ts @@ -42,11 +42,24 @@ export type SaveFileWithDialogOptions = { }> } +/** + * Options for opening an external link. + */ +export type OpenExternalLinkOptions = { + /** + * The URL to open. + */ + url: string +} + +/** + * Response from a file save operation. + */ export type SaveFileResponse = | { /** * The implementation was unable to determine the status of the save operation. - * This cannot be considered a success or a failure and should be handled as an uncertainity. + * This cannot be considered a success or a failure and should be handled as an uncertainty. * The browser standard implementation (std) returns this value as there is no way to * check if the user downloaded the file or not. */ @@ -70,6 +83,29 @@ export type SaveFileResponse = path: string } +/** + * Response from an external link operation. + */ +export type OpenExternalLinkResponse = + | { + /** + * The implementation was unable to determine the status of the open operation. + */ + type: "unknown" + } + | { + /** + * The result is known and the user cancelled the open action. + */ + type: "cancelled" + } + | { + /** + * The result is known and the link was opened successfully. + */ + type: "opened" + } + /** * Platform definitions for how to handle IO operations. */ @@ -85,7 +121,8 @@ export type KernelIO = { /** * Opens a link in the user's browser. * The expected behaviour is for the browser to open a new tab/window (for example in desktop app) with the given URL. - * @param url The URL to open */ - openExternalLink: (url: string) => Promise + openExternalLink: ( + opts: OpenExternalLinkOptions + ) => Promise } diff --git a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts index 8ed97d53..0cb63e6b 100644 --- a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts +++ b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts @@ -1,4 +1,4 @@ -import { computed, markRaw, ref } from "vue" +import { computed, markRaw } from "vue" import { Service } from "dioc" import type { RelayRequest, RelayResponse } from "@hoppscotch/kernel" import { body } from "@hoppscotch/kernel" @@ -147,10 +147,7 @@ export class ExtensionKernelInterceptorService status: response.status, statusText: response.statusText, headers: response.headers, - body: body.body( - response.data, - response.headers["content-type"] - ), + body: body.body(response.data, response.headers["content-type"]), }) } } diff --git a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/store.ts b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/store.ts index a2a62e0c..51a6dc53 100644 --- a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/store.ts +++ b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/store.ts @@ -119,9 +119,8 @@ export class KernelInterceptorExtensionStore extends Service { }) window.__HOPP_EXTENSION_STATUS_PROXY__ = statusProxy - statusProxy.subscribe( - "status", - (status: ExtensionStatus) => this.updateSettings({ status }) + statusProxy.subscribe("status", (status: ExtensionStatus) => + this.updateSettings({ status }) ) /** diff --git a/packages/hoppscotch-common/src/platform/std/kernel-io.ts b/packages/hoppscotch-common/src/platform/std/kernel-io.ts index 5e7803a5..2293baf7 100644 --- a/packages/hoppscotch-common/src/platform/std/kernel-io.ts +++ b/packages/hoppscotch-common/src/platform/std/kernel-io.ts @@ -5,7 +5,7 @@ export const kernelIO: KernelIO = { saveFileWithDialog(opts) { return Io.saveFileWithDialog(opts) }, - openExternalLink(url) { - return Io.openExternalLink(url) + openExternalLink(opts) { + return Io.openExternalLink(opts) }, } diff --git a/packages/hoppscotch-common/src/services/spotlight/searchers/general.searcher.ts b/packages/hoppscotch-common/src/services/spotlight/searchers/general.searcher.ts index 6369e672..38ccac13 100644 --- a/packages/hoppscotch-common/src/services/spotlight/searchers/general.searcher.ts +++ b/packages/hoppscotch-common/src/services/spotlight/searchers/general.searcher.ts @@ -118,7 +118,7 @@ export class GeneralSpotlightSearcherService extends StaticSpotlightSearcherServ } private openURL(url: string) { - platform.kernelIO.openExternalLink(url) + platform.kernelIO.openExternalLink({ url }) } public onDocSelected(id: string): void {