From 536c8128dd562732d2fc2f81f53306e59c40e442 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Wed, 8 Feb 2023 18:50:32 +0530 Subject: [PATCH 01/13] docs: update package description [skip ci] --- packages/hoppscotch-cli/README.md | 19 ++++++++++++++++--- packages/hoppscotch-ui/README.md | 29 ++++++++++------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/hoppscotch-cli/README.md b/packages/hoppscotch-cli/README.md index 9e806c009..420af5315 100644 --- a/packages/hoppscotch-cli/README.md +++ b/packages/hoppscotch-cli/README.md @@ -1,4 +1,17 @@ -# Hoppscotch CLI ALPHA +
+ + Hoppscotch Logo + +
+
+ +# Hoppscotch CLI ALPHA + +
A CLI to run Hoppscotch test scripts in CI environments. @@ -33,7 +46,7 @@ hopp [options or commands] arguments #### Options: ##### `-e ` / `--env ` - - Accepts path to env.json with contents in below format: + - Accepts path to env.json with contents in below format: ```json { "ENV1":"value1", @@ -41,7 +54,7 @@ hopp [options or commands] arguments } ``` - You can now access those variables using `pw.env.get('')` - + Taking the above example, `pw.env.get("ENV1")` will return `"value1"` ## Install diff --git a/packages/hoppscotch-ui/README.md b/packages/hoppscotch-ui/README.md index 8f1885799..3c90ec325 100644 --- a/packages/hoppscotch-ui/README.md +++ b/packages/hoppscotch-ui/README.md @@ -1,24 +1,15 @@ -
- - - - - - - + +
-
- -# Hoppscotch UI +# Hoppscotch UI ALPHA
From d15caba4a60e5386118bc35e6bed9220cf250033 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Wed, 8 Feb 2023 18:57:52 +0530 Subject: [PATCH 02/13] chore: improve ui responsiveness --- packages/hoppscotch-ui/histoire.config.ts | 2 +- packages/hoppscotch-ui/src/components/smart/Tabs.vue | 4 ++-- packages/hoppscotch-ui/src/stories/Link.story.vue | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/hoppscotch-ui/histoire.config.ts b/packages/hoppscotch-ui/histoire.config.ts index 88fb23b11..01ca4e3c6 100644 --- a/packages/hoppscotch-ui/histoire.config.ts +++ b/packages/hoppscotch-ui/histoire.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ light: "/logo.png", dark: "/logo.png", }, - // logoHref: "https://ui.hoppscotch.io", + logoHref: "https://ui.hoppscotch.io", favicon: 'favicon.ico', }, setupFile: "histoire.setup.ts", diff --git a/packages/hoppscotch-ui/src/components/smart/Tabs.vue b/packages/hoppscotch-ui/src/components/smart/Tabs.vue index 54623cd83..5105e1a42 100644 --- a/packages/hoppscotch-ui/src/components/smart/Tabs.vue +++ b/packages/hoppscotch-ui/src/components/smart/Tabs.vue @@ -212,8 +212,8 @@ const selectTab = (id: string) => { @apply inline-flex; @apply items-center; @apply justify-center; - @apply w-5; - @apply h-4; + @apply px-1 py-0.75; + @apply min-w-4; @apply ml-2; @apply text-8px; @apply border border-divider; diff --git a/packages/hoppscotch-ui/src/stories/Link.story.vue b/packages/hoppscotch-ui/src/stories/Link.story.vue index 74f579d5a..2c6af58db 100644 --- a/packages/hoppscotch-ui/src/stories/Link.story.vue +++ b/packages/hoppscotch-ui/src/stories/Link.story.vue @@ -14,5 +14,5 @@ From cb5fff03109610e63f2dd015954366f0debe0e06 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Tue, 14 Feb 2023 10:29:43 +0530 Subject: [PATCH 03/13] fix: graphql collections not syncing on login --- packages/hoppscotch-common/src/helpers/fb/collections.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/hoppscotch-common/src/helpers/fb/collections.ts b/packages/hoppscotch-common/src/helpers/fb/collections.ts index 09db5fdf3..8f8cff180 100644 --- a/packages/hoppscotch-common/src/helpers/fb/collections.ts +++ b/packages/hoppscotch-common/src/helpers/fb/collections.ts @@ -84,6 +84,8 @@ export function initCollections() { }) const gqlCollSub = graphqlCollections$.subscribe((collections) => { + const currentUser = platform.auth.getCurrentUser() + if ( loadedGraphqlCollections && currentUser && From b27fe871c4bc1e0697fe5adeb73704581fbb0eae Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Tue, 14 Feb 2023 14:09:32 +0530 Subject: [PATCH 04/13] refactor: improve type checking for DispatchingStore dispatch payloads --- .../src/composables/settings.ts | 14 +++--- .../src/helpers/fb/settings.ts | 4 +- .../src/newstore/DispatchingStore.ts | 31 +++++++----- .../src/newstore/RESTSession.ts | 10 ++-- .../src/newstore/SocketIOSession.ts | 2 +- .../src/newstore/WebSocketSession.ts | 2 +- .../src/newstore/collections.ts | 10 +++- .../src/newstore/environments.ts | 3 +- .../hoppscotch-common/src/newstore/history.ts | 6 ++- .../src/newstore/localstate.ts | 12 +++-- .../src/newstore/settings.ts | 48 +++++++++++-------- 11 files changed, 85 insertions(+), 57 deletions(-) diff --git a/packages/hoppscotch-common/src/composables/settings.ts b/packages/hoppscotch-common/src/composables/settings.ts index d5eb3d4df..9aef1545a 100644 --- a/packages/hoppscotch-common/src/composables/settings.ts +++ b/packages/hoppscotch-common/src/composables/settings.ts @@ -1,15 +1,15 @@ import { Ref } from "vue" -import { settingsStore, SettingsType } from "~/newstore/settings" +import { settingsStore, SettingsDef } from "~/newstore/settings" import { pluck, distinctUntilChanged } from "rxjs/operators" import { useStream, useStreamStatic } from "./stream" -export function useSetting( +export function useSetting( settingKey: K -): Ref { +): Ref { return useStream( settingsStore.subject$.pipe(pluck(settingKey), distinctUntilChanged()), settingsStore.value[settingKey], - (value: SettingsType[K]) => { + (value: SettingsDef[K]) => { settingsStore.dispatch({ dispatcher: "applySetting", payload: { @@ -25,13 +25,13 @@ export function useSetting( * A static version (does not require component setup) * of `useSetting` */ -export function useSettingStatic( +export function useSettingStatic( settingKey: K -): [Ref, () => void] { +): [Ref, () => void] { return useStreamStatic( settingsStore.subject$.pipe(pluck(settingKey), distinctUntilChanged()), settingsStore.value[settingKey], - (value: SettingsType[K]) => { + (value: SettingsDef[K]) => { settingsStore.dispatch({ dispatcher: "applySetting", payload: { diff --git a/packages/hoppscotch-common/src/helpers/fb/settings.ts b/packages/hoppscotch-common/src/helpers/fb/settings.ts index a3796acc9..1afc5713d 100644 --- a/packages/hoppscotch-common/src/helpers/fb/settings.ts +++ b/packages/hoppscotch-common/src/helpers/fb/settings.ts @@ -6,7 +6,7 @@ import { setDoc, } from "firebase/firestore" import { platform } from "~/platform" -import { applySetting, settingsStore, SettingsType } from "~/newstore/settings" +import { applySetting, settingsStore, SettingsDef } from "~/newstore/settings" /** * Used locally to prevent infinite loop when settings sync update @@ -59,7 +59,7 @@ export function initSettings() { } else { writeSettings( dispatch.payload.settingKey, - settingsStore.value[dispatch.payload.settingKey as keyof SettingsType] + settingsStore.value[dispatch.payload.settingKey as keyof SettingsDef] ) } } diff --git a/packages/hoppscotch-common/src/newstore/DispatchingStore.ts b/packages/hoppscotch-common/src/newstore/DispatchingStore.ts index 81fdc1830..c6c71d788 100644 --- a/packages/hoppscotch-common/src/newstore/DispatchingStore.ts +++ b/packages/hoppscotch-common/src/newstore/DispatchingStore.ts @@ -2,9 +2,9 @@ import { Subject, BehaviorSubject } from "rxjs" import { map } from "rxjs/operators" import { assign, clone } from "lodash-es" -type dispatcherFunc = ( +type DispatcherFunc = ( currentVal: StoreType, - payload: any + payload: PayloadType ) => Partial /** @@ -13,26 +13,32 @@ type dispatcherFunc = ( * This function exists to provide better typing for dispatch function. * As you can see, its pretty much an identity function. */ -export const defineDispatchers = ( +export const defineDispatchers = < + StoreType, + T extends { [x: string]: DispatcherFunc } +>( // eslint-disable-next-line no-unused-vars - dispatchers: { [_ in keyof T]: dispatcherFunc } + dispatchers: T ) => dispatchers type Dispatch< StoreType, - DispatchersType extends Record> + DispatchersType extends { [x: string]: DispatcherFunc }, + Dispatcher extends keyof DispatchersType > = { - dispatcher: keyof DispatchersType - payload: any + dispatcher: Dispatcher + payload: Parameters[1] } export default class DispatchingStore< StoreType, - DispatchersType extends Record> + DispatchersType extends { [x: string]: DispatcherFunc } > { #state$: BehaviorSubject #dispatchers: DispatchersType - #dispatches$: Subject> = new Subject() + #dispatches$: Subject< + Dispatch + > = new Subject() constructor(initialValue: StoreType, dispatchers: DispatchersType) { this.#state$ = new BehaviorSubject(initialValue) @@ -64,9 +70,12 @@ export default class DispatchingStore< return this.#dispatches$ } - dispatch({ dispatcher, payload }: Dispatch) { + dispatch({ + dispatcher, + payload, + }: Dispatch) { if (!this.#dispatchers[dispatcher]) - throw new Error(`Undefined dispatch type '${dispatcher}'`) + throw new Error(`Undefined dispatch type '${String(dispatcher)}'`) this.#dispatches$.next({ dispatcher, payload }) } diff --git a/packages/hoppscotch-common/src/newstore/RESTSession.ts b/packages/hoppscotch-common/src/newstore/RESTSession.ts index a0b755778..f1e18cf29 100644 --- a/packages/hoppscotch-common/src/newstore/RESTSession.ts +++ b/packages/hoppscotch-common/src/newstore/RESTSession.ts @@ -114,7 +114,7 @@ const dispatchers = defineDispatchers({ }, } }, - deleteAllParams(curr: RESTSession) { + deleteAllParams(curr: RESTSession, {}) { return { request: { ...curr.request, @@ -168,7 +168,7 @@ const dispatchers = defineDispatchers({ }, } }, - deleteAllHeaders(curr: RESTSession) { + deleteAllHeaders(curr: RESTSession, {}) { return { request: { ...curr.request, @@ -257,7 +257,7 @@ const dispatchers = defineDispatchers({ }, } }, - deleteAllFormDataEntries(curr: RESTSession) { + deleteAllFormDataEntries(curr: RESTSession, {}) { // Only perform update if the current content-type is formdata if (curr.request.body.contentType !== "multipart/form-data") return {} @@ -288,7 +288,7 @@ const dispatchers = defineDispatchers({ } }, // eslint-disable-next-line @typescript-eslint/no-unused-vars - clearResponse(_curr: RESTSession) { + clearResponse(_curr: RESTSession, {}) { return { response: null, } @@ -490,7 +490,7 @@ export function setRESTTestScript(newScript: string) { }) } -export function setRESTReqBody(newBody: HoppRESTReqBody | null) { +export function setRESTReqBody(newBody: HoppRESTReqBody) { restSessionStore.dispatch({ dispatcher: "setRequestBody", payload: { diff --git a/packages/hoppscotch-common/src/newstore/SocketIOSession.ts b/packages/hoppscotch-common/src/newstore/SocketIOSession.ts index f8561bdef..43b020ed6 100644 --- a/packages/hoppscotch-common/src/newstore/SocketIOSession.ts +++ b/packages/hoppscotch-common/src/newstore/SocketIOSession.ts @@ -109,7 +109,7 @@ export function setSIOEndpoint(newEndpoint: string) { }) } -export function setSIOVersion(newVersion: string) { +export function setSIOVersion(newVersion: SIOClientVersion) { SIOSessionStore.dispatch({ dispatcher: "setVersion", payload: { diff --git a/packages/hoppscotch-common/src/newstore/WebSocketSession.ts b/packages/hoppscotch-common/src/newstore/WebSocketSession.ts index 6f5759e0a..9f9f0692d 100644 --- a/packages/hoppscotch-common/src/newstore/WebSocketSession.ts +++ b/packages/hoppscotch-common/src/newstore/WebSocketSession.ts @@ -74,7 +74,7 @@ const dispatchers = defineDispatchers({ }, } }, - deleteAllProtocols(curr: HoppWSSession) { + deleteAllProtocols(curr: HoppWSSession, {}) { return { request: { endpoint: curr.request.endpoint, diff --git a/packages/hoppscotch-common/src/newstore/collections.ts b/packages/hoppscotch-common/src/newstore/collections.ts index 3ed853234..6ccec0e66 100644 --- a/packages/hoppscotch-common/src/newstore/collections.ts +++ b/packages/hoppscotch-common/src/newstore/collections.ts @@ -127,7 +127,13 @@ const restCollectionDispatchers = defineDispatchers({ editFolder( { state }: RESTCollectionStoreType, - { path, folder }: { path: string; folder: string } + { + path, + folder, + }: { + path: string + folder: HoppCollection + } ) { const newState = state @@ -393,7 +399,7 @@ const gqlCollectionDispatchers = defineDispatchers({ editFolder( { state }: GraphqlCollectionStoreType, - { path, folder }: { path: string; folder: string } + { path, folder }: { path: string; folder: HoppCollection } ) { const newState = state diff --git a/packages/hoppscotch-common/src/newstore/environments.ts b/packages/hoppscotch-common/src/newstore/environments.ts index 54c7c63df..03dc71c9e 100644 --- a/packages/hoppscotch-common/src/newstore/environments.ts +++ b/packages/hoppscotch-common/src/newstore/environments.ts @@ -236,7 +236,8 @@ const dispatchers = defineDispatchers({ globals: entries, } }, - clearGlobalVariables() { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + clearGlobalVariables(_store, {}) { return { globals: [], } diff --git a/packages/hoppscotch-common/src/newstore/history.ts b/packages/hoppscotch-common/src/newstore/history.ts index 2b61edbc5..6943651c1 100644 --- a/packages/hoppscotch-common/src/newstore/history.ts +++ b/packages/hoppscotch-common/src/newstore/history.ts @@ -141,7 +141,8 @@ const RESTHistoryDispatchers = defineDispatchers({ state: currentVal.state.filter((e) => !isEqual(e, entry)), } }, - clearHistory() { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + clearHistory(_, {}) { return { state: [], } @@ -189,7 +190,8 @@ const GQLHistoryDispatchers = defineDispatchers({ state: currentVal.state.filter((e) => !isEqual(e, entry)), } }, - clearHistory() { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + clearHistory(_, {}) { return { state: [], } diff --git a/packages/hoppscotch-common/src/newstore/localstate.ts b/packages/hoppscotch-common/src/newstore/localstate.ts index b0ef621f7..1d78c46af 100644 --- a/packages/hoppscotch-common/src/newstore/localstate.ts +++ b/packages/hoppscotch-common/src/newstore/localstate.ts @@ -11,14 +11,18 @@ const defaultLocalState: LocalState = { REMEMBERED_TEAM_ID: undefined, } +type ApplyLocalState = { + [K in keyof LocalState]: { + key: K + value: LocalState[K] + } +}[keyof LocalState] + const dispatchers = defineDispatchers({ bulkApplyState(_currentState: LocalState, payload: Partial) { return payload }, - applyState( - _currentState: LocalState, - { key, value }: { key: K; value: LocalState[K] } - ) { + applyState(_currentState: LocalState, { key, value }: ApplyLocalState) { const result: Partial = { [key]: value, } diff --git a/packages/hoppscotch-common/src/newstore/settings.ts b/packages/hoppscotch-common/src/newstore/settings.ts index c3dfd33d4..cc4ffa43f 100644 --- a/packages/hoppscotch-common/src/newstore/settings.ts +++ b/packages/hoppscotch-common/src/newstore/settings.ts @@ -27,7 +27,7 @@ export const HoppFontSizes = ["small", "medium", "large"] as const export type HoppFontSize = (typeof HoppFontSizes)[number] -export type SettingsType = { +export type SettingsDef = { syncCollections: boolean syncHistory: boolean syncEnvironments: boolean @@ -53,7 +53,7 @@ export type SettingsType = { COLUMN_LAYOUT: boolean } -export const defaultSettings: SettingsType = { +export const defaultSettings: SettingsDef = { syncCollections: true, syncHistory: true, syncEnvironments: true, @@ -79,18 +79,22 @@ export const defaultSettings: SettingsType = { COLUMN_LAYOUT: true, } +type ApplySettingPayload = { + [K in keyof SettingsDef]: { + settingKey: K + value: SettingsDef[K] + } +}[keyof SettingsDef] + const validKeys = Object.keys(defaultSettings) const dispatchers = defineDispatchers({ - bulkApplySettings( - _currentState: SettingsType, - payload: Partial - ) { + bulkApplySettings(_currentState: SettingsDef, payload: Partial) { return payload }, toggleSetting( - currentState: SettingsType, - { settingKey }: { settingKey: KeysMatching } + currentState: SettingsDef, + { settingKey }: { settingKey: KeysMatching } ) { if (!has(currentState, settingKey)) { // console.log( @@ -99,14 +103,14 @@ const dispatchers = defineDispatchers({ return {} } - const result: Partial = {} + const result: Partial = {} result[settingKey] = !currentState[settingKey] return result }, - applySetting( - _currentState: SettingsType, - { settingKey, value }: { settingKey: K; value: SettingsType[K] } + applySetting( + _currentState: SettingsDef, + { settingKey, value }: ApplySettingPayload ) { if (!validKeys.includes(settingKey)) { // console.log( @@ -115,8 +119,9 @@ const dispatchers = defineDispatchers({ return {} } - const result: Partial = {} - result[settingKey] = value + const result: Partial = { + [settingKey]: value, + } return result }, @@ -129,20 +134,20 @@ export const settingsStore = new DispatchingStore(defaultSettings, dispatchers) */ export const settings$ = settingsStore.subject$.asObservable() -export function getSettingSubject( +export function getSettingSubject( settingKey: K -): Observable { +): Observable { return settingsStore.subject$.pipe(pluck(settingKey), distinctUntilChanged()) } -export function bulkApplySettings(settingsObj: Partial) { +export function bulkApplySettings(settingsObj: Partial) { settingsStore.dispatch({ dispatcher: "bulkApplySettings", payload: settingsObj, }) } -export function toggleSetting(settingKey: KeysMatching) { +export function toggleSetting(settingKey: KeysMatching) { settingsStore.dispatch({ dispatcher: "toggleSetting", payload: { @@ -151,12 +156,13 @@ export function toggleSetting(settingKey: KeysMatching) { }) } -export function applySetting( - settingKey: K, - value: SettingsType[K] +export function applySetting( + settingKey: K["settingKey"], + value: K["value"] ) { settingsStore.dispatch({ dispatcher: "applySetting", + // @ts-expect-error TS is not able to understand the type semantics here payload: { settingKey, value, From 2545262fc2b1452cc125c1f4f15d9f6853085298 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Fri, 17 Feb 2023 16:04:29 +0530 Subject: [PATCH 05/13] chore: improve DispatchingStore typings for dispatch streams --- .../src/newstore/DispatchingStore.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/hoppscotch-common/src/newstore/DispatchingStore.ts b/packages/hoppscotch-common/src/newstore/DispatchingStore.ts index c6c71d788..a54b692c8 100644 --- a/packages/hoppscotch-common/src/newstore/DispatchingStore.ts +++ b/packages/hoppscotch-common/src/newstore/DispatchingStore.ts @@ -23,12 +23,13 @@ export const defineDispatchers = < type Dispatch< StoreType, - DispatchersType extends { [x: string]: DispatcherFunc }, - Dispatcher extends keyof DispatchersType + DispatchersType extends { [x: string]: DispatcherFunc } > = { - dispatcher: Dispatcher - payload: Parameters[1] -} + [Dispatcher in keyof DispatchersType]: { + dispatcher: Dispatcher + payload: Parameters[1] + } +}[keyof DispatchersType] export default class DispatchingStore< StoreType, @@ -36,9 +37,7 @@ export default class DispatchingStore< > { #state$: BehaviorSubject #dispatchers: DispatchersType - #dispatches$: Subject< - Dispatch - > = new Subject() + #dispatches$: Subject> = new Subject() constructor(initialValue: StoreType, dispatchers: DispatchersType) { this.#state$ = new BehaviorSubject(initialValue) @@ -70,10 +69,7 @@ export default class DispatchingStore< return this.#dispatches$ } - dispatch({ - dispatcher, - payload, - }: Dispatch) { + dispatch({ dispatcher, payload }: Dispatch) { if (!this.#dispatchers[dispatcher]) throw new Error(`Undefined dispatch type '${String(dispatcher)}'`) From 82c6f6f6bc714b9c834540227bcc775c28135b94 Mon Sep 17 00:00:00 2001 From: Jesvin Jose Date: Fri, 17 Feb 2023 19:14:50 +0530 Subject: [PATCH 06/13] fix: response time for requests via extension has incorrect value (#2921) Co-authored-by: Andrew Bastin --- .../src/components/http/Request.vue | 7 +++++++ .../src/helpers/strategies/ExtensionStrategy.ts | 2 +- packages/hoppscotch-common/src/shims.d.ts | 12 ++---------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/hoppscotch-common/src/components/http/Request.vue b/packages/hoppscotch-common/src/components/http/Request.vue index 87637aedd..763f7db71 100644 --- a/packages/hoppscotch-common/src/components/http/Request.vue +++ b/packages/hoppscotch-common/src/components/http/Request.vue @@ -274,6 +274,10 @@ import { createShortcode } from "~/helpers/backend/mutations/Shortcode" import { runMutation } from "~/helpers/backend/GQLClient" import { UpdateRequestDocument } from "~/helpers/backend/graphql" import { getPlatformSpecialKey as getSpecialKey } from "~/helpers/platformutils" +import { + cancelRunningExtensionRequest, + hasExtensionInstalled, +} from "~/helpers/strategies/ExtensionStrategy" const t = useI18n() @@ -403,6 +407,9 @@ function isCURL(curl: string) { const cancelRequest = () => { loading.value = false + if (hasExtensionInstalled()) { + cancelRunningExtensionRequest() + } updateRESTResponse(null) } diff --git a/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts b/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts index 5d9cef4f4..5bb0b69df 100644 --- a/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts +++ b/packages/hoppscotch-common/src/helpers/strategies/ExtensionStrategy.ts @@ -16,7 +16,7 @@ export const hasFirefoxExtensionInstalled = () => hasExtensionInstalled() && browserIsFirefox() export const cancelRunningExtensionRequest = () => { - window.__POSTWOMAN_EXTENSION_HOOK__?.cancelRunningRequest() + window.__POSTWOMAN_EXTENSION_HOOK__?.cancelRequest() } export const defineSubscribableObject = (obj: T) => { diff --git a/packages/hoppscotch-common/src/shims.d.ts b/packages/hoppscotch-common/src/shims.d.ts index 84ea49fb5..3248a8527 100644 --- a/packages/hoppscotch-common/src/shims.d.ts +++ b/packages/hoppscotch-common/src/shims.d.ts @@ -8,7 +8,7 @@ interface PWExtensionHook { sendRequest: ( req: AxiosRequestConfig & { wantsBinary: boolean } ) => Promise - cancelRunningRequest: () => void + cancelRequest: () => void } type HoppExtensionStatusHook = { @@ -18,17 +18,9 @@ type HoppExtensionStatusHook = { } subscribe(prop: "status", func: (...args: any[]) => any): void } -declare global { +export declare global { interface Window { __POSTWOMAN_EXTENSION_HOOK__: PWExtensionHook | undefined __HOPP_EXTENSION_STATUS_PROXY__: HoppExtensionStatusHook | undefined } } - -// Vue builtins -declare module '*.vue' { - import type { DefineComponent } from 'vue' - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types - const component: DefineComponent<{}, {}, any> - export default component -} From cae18405062c7c32f7905c45d0437251edb5407f Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Fri, 24 Feb 2023 13:20:12 +0530 Subject: [PATCH 07/13] refactor: update hopp-ui to be independent (#2927) Co-authored-by: Anwarul Islam --- packages/hoppscotch-common/package.json | 2 +- packages/hoppscotch-common/src/App.vue | 2 +- .../hoppscotch-common/src/components.d.ts | 38 +- .../src/components/app/DeveloperOptions.vue | 6 +- .../src/components/app/Footer.vue | 42 +- .../src/components/app/Header.vue | 18 +- .../src/components/app/Interceptor.vue | 9 +- .../src/components/app/Options.vue | 28 +- .../src/components/app/PowerSearch.vue | 4 +- .../src/components/app/Share.vue | 4 +- .../src/components/app/Shortcuts.vue | 4 +- .../src/components/app/ShortcutsPrompt.vue | 2 +- .../src/components/app/Sidenav.vue | 4 +- .../src/components/app/Support.vue | 18 +- .../src/components/collections/Add.vue | 8 +- .../src/components/collections/AddFolder.vue | 8 +- .../src/components/collections/AddRequest.vue | 8 +- .../src/components/collections/Collection.vue | 16 +- .../src/components/collections/Edit.vue | 8 +- .../src/components/collections/EditFolder.vue | 8 +- .../components/collections/EditRequest.vue | 8 +- .../components/collections/ImportExport.vue | 18 +- .../components/collections/MyCollections.vue | 10 +- .../src/components/collections/Request.vue | 10 +- .../components/collections/SaveRequest.vue | 8 +- .../collections/TeamCollections.vue | 16 +- .../src/components/collections/TeamSelect.vue | 16 +- .../components/collections/graphql/Add.vue | 8 +- .../collections/graphql/AddFolder.vue | 12 +- .../collections/graphql/AddRequest.vue | 12 +- .../collections/graphql/Collection.vue | 18 +- .../components/collections/graphql/Edit.vue | 8 +- .../collections/graphql/EditFolder.vue | 8 +- .../collections/graphql/EditRequest.vue | 8 +- .../components/collections/graphql/Folder.vue | 16 +- .../collections/graphql/ImportExport.vue | 14 +- .../collections/graphql/Request.vue | 12 +- .../components/collections/graphql/index.vue | 8 +- .../src/components/collections/index.vue | 14 +- .../components/environments/ChooseType.vue | 20 +- .../components/environments/ImportExport.vue | 16 +- .../src/components/environments/index.vue | 18 +- .../components/environments/my/Details.vue | 16 +- .../environments/my/Environment.vue | 18 +- .../src/components/environments/my/index.vue | 8 +- .../components/environments/teams/Details.vue | 18 +- .../environments/teams/Environment.vue | 18 +- .../components/environments/teams/index.vue | 16 +- .../src/components/firebase/Login.vue | 24 +- .../src/components/firebase/Logout.vue | 4 +- .../src/components/graphql/Authorization.vue | 37 +- .../src/components/graphql/Request.vue | 2 +- .../src/components/graphql/RequestOptions.vue | 66 +- .../src/components/graphql/Response.vue | 8 +- .../src/components/graphql/Sidebar.vue | 54 +- .../src/components/history/graphql/Card.vue | 6 +- .../src/components/history/index.vue | 16 +- .../src/components/history/rest/Card.vue | 4 +- .../src/components/http/Authorization.vue | 37 +- .../src/components/http/Body.vue | 10 +- .../src/components/http/BodyParameters.vue | 20 +- .../src/components/http/CodegenModal.vue | 18 +- .../src/components/http/Headers.vue | 30 +- .../src/components/http/ImportCurl.vue | 18 +- .../components/http/OAuth2Authorization.vue | 2 +- .../src/components/http/Parameters.vue | 20 +- .../src/components/http/PreRequestScript.vue | 8 +- .../src/components/http/RawBody.vue | 10 +- .../components/http/ReqChangeConfirmModal.vue | 10 +- .../src/components/http/Request.vue | 22 +- .../src/components/http/RequestOptions.vue | 28 +- .../src/components/http/ResponseMeta.vue | 2 +- .../src/components/http/Sidebar.vue | 20 +- .../src/components/http/TestResult.vue | 8 +- .../src/components/http/TestResultReport.vue | 2 +- .../src/components/http/Tests.vue | 8 +- .../src/components/http/URLEncodedParams.vue | 20 +- .../src/components/lenses/HeadersRenderer.vue | 2 +- .../lenses/HeadersRendererEntry.vue | 2 +- .../lenses/ResponseBodyRenderer.vue | 16 +- .../lenses/renderers/HTMLLensRenderer.vue | 8 +- .../lenses/renderers/ImageLensRenderer.vue | 2 +- .../lenses/renderers/JSONLensRenderer.vue | 18 +- .../lenses/renderers/PDFLensRenderer.vue | 2 +- .../lenses/renderers/RawLensRenderer.vue | 6 +- .../lenses/renderers/XMLLensRenderer.vue | 6 +- .../src/components/profile/Shortcode.vue | 6 +- .../src/components/profile/Shortcodes.vue | 8 +- .../src/components/profile/UserDelete.vue | 12 +- .../src/components/realtime/Communication.vue | 20 +- .../components/realtime/ConnectionConfig.vue | 12 +- .../src/components/realtime/Log.vue | 8 +- .../src/components/realtime/LogEntry.vue | 26 +- .../src/components/realtime/Subscription.vue | 12 +- .../src/components/smart/AccentModePicker.vue | 2 +- .../src/components/smart/ChangeLanguage.vue | 8 +- .../src/components/smart/ColorModePicker.vue | 2 +- .../src/components/smart/FontSizePicker.vue | 4 +- .../src/components/smart/Tree.vue | 2 +- .../src/components/smart/TreeBranch.vue | 2 +- .../src/components/tab/Primary.vue | 4 +- .../src/components/tab/Secondary.vue | 4 +- .../src/components/teams/Add.vue | 8 +- .../src/components/teams/Edit.vue | 22 +- .../src/components/teams/Invite.vue | 39 +- .../src/components/teams/Modal.vue | 4 +- .../src/components/teams/Team.vue | 16 +- .../src/components/teams/index.vue | 6 +- packages/hoppscotch-common/src/modules/ui.ts | 5 +- packages/hoppscotch-common/src/pages/_.vue | 9 +- .../hoppscotch-common/src/pages/enter.vue | 2 +- .../hoppscotch-common/src/pages/join-team.vue | 12 +- .../hoppscotch-common/src/pages/profile.vue | 36 +- .../hoppscotch-common/src/pages/r/_id.vue | 6 +- .../hoppscotch-common/src/pages/realtime.vue | 8 +- .../src/pages/realtime/mqtt.vue | 18 +- .../src/pages/realtime/socketio.vue | 37 +- .../src/pages/realtime/sse.vue | 2 +- .../src/pages/realtime/websocket.vue | 26 +- .../hoppscotch-common/src/pages/settings.vue | 42 +- packages/hoppscotch-common/tsconfig.json | 2 +- packages/hoppscotch-ui/README.md | 2 +- packages/hoppscotch-ui/package.json | 25 +- .../hoppscotch-ui/src/assets/scss/styles.scss | 440 ------ packages/hoppscotch-ui/src/components.d.ts | 37 - .../src/components/button/Primary.vue | 47 +- .../src/components/button/Secondary.vue | 42 +- .../src/components/button/index.ts | 2 + .../hoppscotch-ui/src/components/index.ts | 49 +- .../src/components/smart/Anchor.vue | 24 +- .../src/components/smart/AutoComplete.vue | 39 +- .../src/components/smart/ConfirmModal.vue | 32 +- .../src/components/smart/Expand.vue | 28 +- .../src/components/smart/Item.vue | 59 +- .../src/components/smart/Link.vue | 27 +- .../src/components/smart/Modal.vue | 2 +- .../src/components/smart/Radio.vue | 11 +- .../src/components/smart/RadioGroup.vue | 12 +- .../src/components/smart/SlideOver.vue | 25 +- .../src/components/smart/Spinner.vue | 8 +- .../src/components/smart/Windows.vue | 110 +- .../src/components/smart/index.ts | 20 + packages/hoppscotch-ui/src/index.ts | 35 +- packages/hoppscotch-ui/src/plugin.ts | 30 + .../src/stories/Anchor.story.vue | 19 +- .../src/stories/AutoComplete.story.vue | 27 +- .../src/stories/Button.story.vue | 8 +- .../src/stories/Checkbox.story.vue | 4 +- .../src/stories/ConfirmModal.story.vue | 9 +- .../src/stories/Expand.story.vue | 20 + .../hoppscotch-ui/src/stories/Item.story.vue | 6 +- .../hoppscotch-ui/src/stories/Link.story.vue | 10 +- .../hoppscotch-ui/src/stories/Modal.story.vue | 8 +- .../src/stories/ProgressRing.story.vue | 9 +- .../hoppscotch-ui/src/stories/Radio.story.vue | 5 +- .../src/stories/SlideOver.story.vue | 7 +- .../src/stories/Spinner.story.vue | 6 +- .../hoppscotch-ui/src/stories/Tab.story.vue | 13 +- .../src/stories/Toggle.story.vue | 3 +- .../src/stories/Window.story.vue | 23 +- packages/hoppscotch-ui/tsconfig.json | 41 +- packages/hoppscotch-ui/vite.config.ts | 48 +- packages/hoppscotch-web/package.json | 1 + packages/hoppscotch-web/vite.config.ts | 10 +- pnpm-lock.yaml | 1203 +++++++++++++---- 165 files changed, 2134 insertions(+), 2069 deletions(-) delete mode 100644 packages/hoppscotch-ui/src/components.d.ts create mode 100644 packages/hoppscotch-ui/src/components/button/index.ts create mode 100644 packages/hoppscotch-ui/src/components/smart/index.ts create mode 100644 packages/hoppscotch-ui/src/plugin.ts create mode 100644 packages/hoppscotch-ui/src/stories/Expand.story.vue diff --git a/packages/hoppscotch-common/package.json b/packages/hoppscotch-common/package.json index 34c92fb88..57e35b399 100644 --- a/packages/hoppscotch-common/package.json +++ b/packages/hoppscotch-common/package.json @@ -90,7 +90,7 @@ "vue-pdf-embed": "^1.1.4", "vue-router": "^4.0.16", "vue-tippy": "6.0.0-alpha.58", - "vuedraggable": "^4.1.0", + "vuedraggable-es": "^4.1.1", "wonka": "^4.0.15", "workbox-window": "^6.5.4", "yargs-parser": "^21.1.1" diff --git a/packages/hoppscotch-common/src/App.vue b/packages/hoppscotch-common/src/App.vue index de03b4aa4..8cf3e8e26 100644 --- a/packages/hoppscotch-common/src/App.vue +++ b/packages/hoppscotch-common/src/App.vue @@ -4,7 +4,7 @@ v-if="isLoadingInitialRoute" class="flex flex-col items-center justify-center min-h-screen" > - +
diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts index 3b7ae649d..72ac2df75 100644 --- a/packages/hoppscotch-common/src/components.d.ts +++ b/packages/hoppscotch-common/src/components.d.ts @@ -26,8 +26,6 @@ declare module '@vue/runtime-core' { AppShortcutsPrompt: typeof import('./components/app/ShortcutsPrompt.vue')['default'] AppSidenav: typeof import('./components/app/Sidenav.vue')['default'] AppSupport: typeof import('./components/app/Support.vue')['default'] - ButtonPrimary: typeof import('./../../hoppscotch-ui/src/components/button/Primary.vue')['default'] - ButtonSecondary: typeof import('./../../hoppscotch-ui/src/components/button/Secondary.vue')['default'] Collections: typeof import('./components/collections/index.vue')['default'] CollectionsAdd: typeof import('./components/collections/Add.vue')['default'] CollectionsAddFolder: typeof import('./components/collections/AddFolder.vue')['default'] @@ -75,6 +73,16 @@ declare module '@vue/runtime-core' { History: typeof import('./components/history/index.vue')['default'] HistoryGraphqlCard: typeof import('./components/history/graphql/Card.vue')['default'] HistoryRestCard: typeof import('./components/history/rest/Card.vue')['default'] + HoppButtonPrimary: typeof import('@hoppscotch/ui')['HoppButtonPrimary'] + HoppButtonSecondary: typeof import('@hoppscotch/ui')['HoppButtonSecondary'] + HoppSmartAnchor: typeof import('@hoppscotch/ui')['HoppSmartAnchor'] + HoppSmartConfirmModal: typeof import('@hoppscotch/ui')['HoppSmartConfirmModal'] + HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem'] + HoppSmartLink: typeof import('@hoppscotch/ui')['HoppSmartLink'] + HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal'] + HoppSmartRadioGroup: typeof import('@hoppscotch/ui')['HoppSmartRadioGroup'] + HoppSmartSlideOver: typeof import('@hoppscotch/ui')['HoppSmartSlideOver'] + HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner'] HttpAuthorization: typeof import('./components/http/Authorization.vue')['default'] HttpBody: typeof import('./components/http/Body.vue')['default'] HttpBodyParameters: typeof import('./components/http/BodyParameters.vue')['default'] @@ -97,15 +105,9 @@ declare module '@vue/runtime-core' { HttpTestResultReport: typeof import('./components/http/TestResultReport.vue')['default'] HttpTests: typeof import('./components/http/Tests.vue')['default'] HttpURLEncodedParams: typeof import('./components/http/URLEncodedParams.vue')['default'] - IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'] - IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default'] IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default'] - IconLucideGlobe: typeof import('~icons/lucide/globe')['default'] IconLucideInbox: typeof import('~icons/lucide/inbox')['default'] IconLucideInfo: typeof import('~icons/lucide/info')['default'] - IconLucideLayers: typeof import('~icons/lucide/layers')['default'] - IconLucideLoader: typeof import('~icons/lucide/loader')['default'] - IconLucideMinus: typeof import('~icons/lucide/minus')['default'] IconLucideSearch: typeof import('~icons/lucide/search')['default'] IconLucideUser: typeof import('~icons/lucide/user')['default'] IconLucideUsers: typeof import('~icons/lucide/users')['default'] @@ -128,32 +130,12 @@ declare module '@vue/runtime-core' { RealtimeLogEntry: typeof import('./components/realtime/LogEntry.vue')['default'] RealtimeSubscription: typeof import('./components/realtime/Subscription.vue')['default'] SmartAccentModePicker: typeof import('./components/smart/AccentModePicker.vue')['default'] - SmartAnchor: typeof import('./../../hoppscotch-ui/src/components/smart/Anchor.vue')['default'] - SmartAutoComplete: typeof import('./../../hoppscotch-ui/src/components/smart/AutoComplete.vue')['default'] SmartChangeLanguage: typeof import('./components/smart/ChangeLanguage.vue')['default'] - SmartCheckbox: typeof import('./../../hoppscotch-ui/src/components/smart/Checkbox.vue')['default'] SmartColorModePicker: typeof import('./components/smart/ColorModePicker.vue')['default'] - SmartConfirmModal: typeof import('./../../hoppscotch-ui/src/components/smart/ConfirmModal.vue')['default'] SmartEnvInput: typeof import('./components/smart/EnvInput.vue')['default'] - SmartExpand: typeof import('./../../hoppscotch-ui/src/components/smart/Expand.vue')['default'] - SmartFileChip: typeof import('./../../hoppscotch-ui/src/components/smart/FileChip.vue')['default'] SmartFontSizePicker: typeof import('./components/smart/FontSizePicker.vue')['default'] - SmartIntersection: typeof import('./../../hoppscotch-ui/src/components/smart/Intersection.vue')['default'] - SmartItem: typeof import('./../../hoppscotch-ui/src/components/smart/Item.vue')['default'] - SmartLink: typeof import('./../../hoppscotch-ui/src/components/smart/Link.vue')['default'] - SmartModal: typeof import('./../../hoppscotch-ui/src/components/smart/Modal.vue')['default'] - SmartProgressRing: typeof import('./../../hoppscotch-ui/src/components/smart/ProgressRing.vue')['default'] - SmartRadio: typeof import('./../../hoppscotch-ui/src/components/smart/Radio.vue')['default'] - SmartRadioGroup: typeof import('./../../hoppscotch-ui/src/components/smart/RadioGroup.vue')['default'] - SmartSlideOver: typeof import('./../../hoppscotch-ui/src/components/smart/SlideOver.vue')['default'] - SmartSpinner: typeof import('./../../hoppscotch-ui/src/components/smart/Spinner.vue')['default'] - SmartTab: typeof import('./../../hoppscotch-ui/src/components/smart/Tab.vue')['default'] - SmartTabs: typeof import('./../../hoppscotch-ui/src/components/smart/Tabs.vue')['default'] - SmartToggle: typeof import('./../../hoppscotch-ui/src/components/smart/Toggle.vue')['default'] SmartTree: typeof import('./components/smart/Tree.vue')['default'] SmartTreeBranch: typeof import('./components/smart/TreeBranch.vue')['default'] - SmartWindow: typeof import('./../../hoppscotch-ui/src/components/smart/Window.vue')['default'] - SmartWindows: typeof import('./../../hoppscotch-ui/src/components/smart/Windows.vue')['default'] TabPrimary: typeof import('./components/tab/Primary.vue')['default'] TabSecondary: typeof import('./components/tab/Secondary.vue')['default'] Teams: typeof import('./components/teams/index.vue')['default'] diff --git a/packages/hoppscotch-common/src/components/app/DeveloperOptions.vue b/packages/hoppscotch-common/src/components/app/DeveloperOptions.vue index f2f63346f..a94977acf 100644 --- a/packages/hoppscotch-common/src/components/app/DeveloperOptions.vue +++ b/packages/hoppscotch-common/src/components/app/DeveloperOptions.vue @@ -1,5 +1,5 @@ - + diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vue index f20e619cc..539d994c3 100644 --- a/packages/hoppscotch-common/src/components/app/Header.vue +++ b/packages/hoppscotch-common/src/components/app/Header.vue @@ -10,7 +10,7 @@ paddingLeft: platform.ui?.appHeader?.paddingLeft?.value, }" > -
- - - -
- +
- - - {{ t("layout.name") }} - - {{ t("support.title") }} - - - - {{ t("settings.follow") }} - - - - - - - + diff --git a/packages/hoppscotch-ui/src/components/smart/Windows.vue b/packages/hoppscotch-ui/src/components/smart/Windows.vue index 9b142a554..5f7746219 100644 --- a/packages/hoppscotch-ui/src/components/smart/Windows.vue +++ b/packages/hoppscotch-ui/src/components/smart/Windows.vue @@ -1,71 +1,37 @@ + diff --git a/packages/hoppscotch-ui/src/stories/AutoComplete.story.vue b/packages/hoppscotch-ui/src/stories/AutoComplete.story.vue index 61be821fa..e4ee06227 100644 --- a/packages/hoppscotch-ui/src/stories/AutoComplete.story.vue +++ b/packages/hoppscotch-ui/src/stories/AutoComplete.story.vue @@ -1,28 +1,21 @@ diff --git a/packages/hoppscotch-ui/src/stories/Checkbox.story.vue b/packages/hoppscotch-ui/src/stories/Checkbox.story.vue index bfc1c37fa..77c7a898d 100644 --- a/packages/hoppscotch-ui/src/stories/Checkbox.story.vue +++ b/packages/hoppscotch-ui/src/stories/Checkbox.story.vue @@ -1,12 +1,14 @@ diff --git a/packages/hoppscotch-ui/src/stories/Item.story.vue b/packages/hoppscotch-ui/src/stories/Item.story.vue index 875f460ef..1af65a19c 100644 --- a/packages/hoppscotch-ui/src/stories/Item.story.vue +++ b/packages/hoppscotch-ui/src/stories/Item.story.vue @@ -1,7 +1,11 @@ + + diff --git a/packages/hoppscotch-ui/src/stories/Link.story.vue b/packages/hoppscotch-ui/src/stories/Link.story.vue index 2c6af58db..e83d6feec 100644 --- a/packages/hoppscotch-ui/src/stories/Link.story.vue +++ b/packages/hoppscotch-ui/src/stories/Link.story.vue @@ -1,17 +1,19 @@ diff --git a/packages/hoppscotch-ui/src/stories/Radio.story.vue b/packages/hoppscotch-ui/src/stories/Radio.story.vue index 778065843..1d9af6978 100644 --- a/packages/hoppscotch-ui/src/stories/Radio.story.vue +++ b/packages/hoppscotch-ui/src/stories/Radio.story.vue @@ -1,16 +1,17 @@ diff --git a/packages/hoppscotch-ui/src/stories/Tab.story.vue b/packages/hoppscotch-ui/src/stories/Tab.story.vue index 28415baec..dd0484073 100644 --- a/packages/hoppscotch-ui/src/stories/Tab.story.vue +++ b/packages/hoppscotch-ui/src/stories/Tab.story.vue @@ -1,19 +1,20 @@ diff --git a/packages/hoppscotch-common/src/components/collections/MyCollections.vue b/packages/hoppscotch-common/src/components/collections/MyCollections.vue index 9d71a7c36..7c6fdcbce 100644 --- a/packages/hoppscotch-common/src/components/collections/MyCollections.vue +++ b/packages/hoppscotch-common/src/components/collections/MyCollections.vue @@ -1,5 +1,5 @@