@scalar/api-client 2.39.0 → 2.39.2
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.
- package/CHANGELOG.md +15 -0
- package/dist/hooks/useClientConfig.d.ts +18 -0
- package/dist/hooks/useClientConfig.d.ts.map +1 -1
- package/dist/style.css +23 -28
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +2 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +6 -2
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts +3 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js +2 -2
- package/dist/v2/blocks/operation-block/helpers/build-request-body.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts +3 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +2 -2
- package/dist/v2/blocks/operation-block/helpers/build-request.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +5 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +6 -3
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +3 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +3 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts +5 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +51 -25
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +6 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +3 -2
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts +2 -2
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +5 -3
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +1 -0
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +4 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts +2 -0
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +3 -2
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +2 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.js +1 -3
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.script.js +2 -3
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +6 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js +6 -2
- package/dist/v2/blocks/request-block/helpers/get-request-body-example.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/app/helpers/routes.d.ts +2 -0
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.script.js +71 -48
- package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts +3 -1
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js +4 -0
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.js +3 -0
- package/dist/v2/features/modal/helpers/create-api-client-modal.js.map +1 -1
- package/dist/v2/features/modal/modal-events.d.ts +2 -1
- package/dist/v2/features/modal/modal-events.d.ts.map +1 -1
- package/dist/v2/features/modal/modal-events.js +3 -1
- package/dist/v2/features/modal/modal-events.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.d.ts +4 -0
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.script.js +4 -1
- package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
- package/dist/v2/helpers/download-document.d.ts +2 -0
- package/dist/v2/helpers/download-document.d.ts.map +1 -0
- package/dist/v2/helpers/download-document.js +42 -0
- package/dist/v2/helpers/download-document.js.map +1 -0
- package/dist/v2/posthog.d.ts.map +1 -1
- package/dist/v2/posthog.js +1 -0
- package/dist/v2/posthog.js.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.script.js +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-api-client-modal.js","names":[],"sources":["../../../../../src/v2/features/modal/helpers/create-api-client-modal.ts"],"sourcesContent":["import { type ModalState, useModal } from '@scalar/components'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { type WorkspaceEventBus, createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { InMemoryWorkspace } from '@scalar/workspace-store/schemas/inmemory-workspace'\nimport { type App, computed, createApp, reactive, ref, watch } from 'vue'\n\nimport {\n type DefaultEntities,\n type RoutePayload,\n resolveRouteParameters,\n} from '@/v2/features/modal/helpers/resolve-route-parameters'\nimport { restoreWorkspaceState } from '@/v2/features/modal/helpers/restore-workspace-state'\nimport { useModalSidebar } from '@/v2/features/modal/hooks/use-modal-sidebar'\nimport Modal, { type ModalProps } from '@/v2/features/modal/Modal.vue'\n\ntype CreateApiClientModalOptions = {\n /** Element to mount the client modal to. */\n el: HTMLElement | null\n /**\n * Will attempt to mount the references immediately.\n * For SSR this may need to be disabled and handled manually on the client side.\n */\n mountOnInitialize?: boolean\n /** You can pass in an event bus if you have one already, or we will create one */\n eventBus?: WorkspaceEventBus\n /** The workspace store must be initialized and passed in. */\n workspaceStore: WorkspaceStore\n /** Api client plugins to include in the modal */\n plugins?: ClientPlugin[]\n /** Subset of the configuration options for the modal, if you want it to be reactive ensure its a ref */\n options?: ModalProps['options']\n}\n\nexport type ApiClientModal = {\n app: App\n open: (payload?: RoutePayload) => void\n mount: (mountingEl: HTMLElement | null) => void\n route: (payload: RoutePayload) => void\n modalState: ModalState\n}\n\n/**\n * Creates the API Client Modal.\n *\n * The modal does not require a router. Instead, navigation is handled by setting\n * active entities directly through the returned `route` function.\n */\nexport const createApiClientModal = ({\n el,\n eventBus = createWorkspaceEventBus({\n debug: import.meta.env.DEV,\n }),\n mountOnInitialize = true,\n plugins = [],\n workspaceStore,\n options = {},\n}: CreateApiClientModalOptions): ApiClientModal => {\n const defaultEntities: DefaultEntities = {\n path: 'default',\n method: 'default',\n example: 'default',\n documentSlug: workspaceStore.workspace['x-scalar-active-document'] || 'default',\n }\n\n const workspaceStoreSnapshot = ref<InMemoryWorkspace | null>(null)\n\n const parameters = reactive<DefaultEntities>({ ...defaultEntities })\n\n /** Navigate to the specified path, method, and example. */\n const route = (payload: RoutePayload): void => {\n Object.assign(parameters, defaultEntities, payload)\n }\n\n /** Resolved parameters from the workspace store. */\n const resolvedParameters = computed(() => resolveRouteParameters(workspaceStore, parameters))\n const documentSlug = computed(() => resolvedParameters.value.documentSlug)\n const path = computed(() => resolvedParameters.value.path)\n const method = computed(() => resolvedParameters.value.method)\n const exampleName = computed(() => resolvedParameters.value.example)\n /** The document from the workspace store. */\n const document = computed(() => workspaceStore.workspace.documents[documentSlug.value ?? ''] ?? null)\n\n /** Sidebar state and selection handling. */\n const sidebarState = useModalSidebar({\n workspaceStore,\n documentSlug: documentSlug,\n path: path,\n method: method,\n exampleName: exampleName,\n route,\n })\n\n const modalState = useModal()\n\n const app = createApp(Modal, {\n document,\n eventBus,\n exampleName,\n method,\n modalState,\n path,\n plugins,\n sidebarState,\n workspaceStore,\n options,\n } satisfies ModalProps)\n\n /** Snapshot the workspace store when the modal is opened. */\n const handleModalOpen = () => {\n workspaceStoreSnapshot.value = window.structuredClone(workspaceStore.exportWorkspace())\n }\n\n /** Restore the workspace store when the modal is closed. */\n const handleModalClose = () => {\n if (!workspaceStoreSnapshot.value) {\n console.warn('No workspace store snapshot to restore')\n return\n }\n\n const result = restoreWorkspaceState({\n workspaceStore,\n workspaceState: workspaceStoreSnapshot.value,\n name: documentSlug.value ?? '',\n })\n\n if (!result.ok) {\n console.error('Failed to restore workspace state', result.error)\n }\n return\n }\n\n watch(\n () => modalState.open,\n (open) => (open ? handleModalOpen() : handleModalClose()),\n )\n\n // Use a unique id prefix to prevent collisions with other Vue apps on the page\n app.config.idPrefix = 'scalar-client'\n\n /** Mount the modal to a given element. */\n const mount = (mountingEl: HTMLElement | null = el): void => {\n if (!mountingEl) {\n console.error(\n '[@scalar/api-client] Could not create the API client Modal.',\n 'Invalid HTML element provided.',\n 'Read more: https://github.com/scalar/scalar/tree/main/packages/api-client',\n )\n return\n }\n app.mount(mountingEl)\n }\n\n if (mountOnInitialize) {\n mount()\n }\n\n return {\n /** The Vue app instance for the modal. Use with caution. */\n app,\n /** Open the modal and optionally navigate to a specific route. */\n open: (payload?: RoutePayload): void => {\n modalState.open = true\n if (payload) {\n route(payload)\n }\n },\n /** Mount the modal to a given element. */\n mount,\n /** Navigate to the specified path, method, and example. */\n route,\n /** Controls the visibility of the modal. */\n modalState,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgDA,IAAa,wBAAwB,EACnC,IACA,WAAW,wBAAwB,EACjC,OAAA,OACD,CAAC,EACF,oBAAoB,MACpB,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,OAAa;AAC3D,MAAI,CAAC,YAAY;AACf,WAAQ,MACN,+DACA,kCACA,4EACD;AACD;;AAEF,MAAI,MAAM,WAAW;;AAGvB,KAAI,kBACF,QAAO;AAGT,QAAO;EAEL;EAEA,OAAO,YAAiC;AACtC,cAAW,OAAO;AAClB,OAAI,QACF,OAAM,QAAQ;;EAIlB;EAEA;EAEA;EACD"}
|
|
1
|
+
{"version":3,"file":"create-api-client-modal.js","names":[],"sources":["../../../../../src/v2/features/modal/helpers/create-api-client-modal.ts"],"sourcesContent":["import { type ModalState, useModal } from '@scalar/components'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { type WorkspaceEventBus, createWorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { InMemoryWorkspace } from '@scalar/workspace-store/schemas/inmemory-workspace'\nimport { type App, computed, createApp, reactive, ref, watch } from 'vue'\n\nimport {\n type DefaultEntities,\n type RoutePayload,\n resolveRouteParameters,\n} from '@/v2/features/modal/helpers/resolve-route-parameters'\nimport { restoreWorkspaceState } from '@/v2/features/modal/helpers/restore-workspace-state'\nimport { useModalSidebar } from '@/v2/features/modal/hooks/use-modal-sidebar'\nimport Modal, { type ModalProps } from '@/v2/features/modal/Modal.vue'\n\ntype CreateApiClientModalOptions = {\n /** Element to mount the client modal to. */\n el: HTMLElement | null\n /**\n * Will attempt to mount the references immediately.\n * For SSR this may need to be disabled and handled manually on the client side.\n */\n mountOnInitialize?: boolean\n /** You can pass in an event bus if you have one already, or we will create one */\n eventBus?: WorkspaceEventBus\n /** The workspace store must be initialized and passed in. */\n workspaceStore: WorkspaceStore\n /** Api client plugins to include in the modal */\n plugins?: ClientPlugin[]\n /** Subset of the configuration options for the modal, if you want it to be reactive ensure its a ref */\n options?: ModalProps['options']\n}\n\nexport type ApiClientModal = {\n app: App\n open: (payload?: RoutePayload) => void\n mount: (mountingEl: HTMLElement | null) => void\n route: (payload: RoutePayload) => void\n modalState: ModalState\n}\n\n/**\n * Creates the API Client Modal.\n *\n * The modal does not require a router. Instead, navigation is handled by setting\n * active entities directly through the returned `route` function.\n */\nexport const createApiClientModal = ({\n el,\n eventBus = createWorkspaceEventBus({\n debug: import.meta.env.DEV,\n }),\n mountOnInitialize = true,\n plugins = [],\n workspaceStore,\n options = {},\n}: CreateApiClientModalOptions): ApiClientModal => {\n const requestBodyCompositionSelection = ref<Record<string, number>>({})\n\n const defaultEntities: DefaultEntities = {\n path: 'default',\n method: 'default',\n example: 'default',\n documentSlug: workspaceStore.workspace['x-scalar-active-document'] || 'default',\n }\n\n const workspaceStoreSnapshot = ref<InMemoryWorkspace | null>(null)\n\n const parameters = reactive<DefaultEntities>({ ...defaultEntities })\n\n /** Navigate to the specified path, method, and example. */\n const route = (payload: RoutePayload): void => {\n Object.assign(parameters, defaultEntities, payload)\n }\n\n /** Resolved parameters from the workspace store. */\n const resolvedParameters = computed(() => resolveRouteParameters(workspaceStore, parameters))\n const documentSlug = computed(() => resolvedParameters.value.documentSlug)\n const path = computed(() => resolvedParameters.value.path)\n const method = computed(() => resolvedParameters.value.method)\n const exampleName = computed(() => resolvedParameters.value.example)\n /** The document from the workspace store. */\n const document = computed(() => workspaceStore.workspace.documents[documentSlug.value ?? ''] ?? null)\n\n /** Sidebar state and selection handling. */\n const sidebarState = useModalSidebar({\n workspaceStore,\n documentSlug: documentSlug,\n path: path,\n method: method,\n exampleName: exampleName,\n route,\n })\n\n const modalState = useModal()\n\n const app = createApp(Modal, {\n document,\n eventBus,\n exampleName,\n method,\n modalState,\n path,\n plugins,\n requestBodyCompositionSelection,\n sidebarState,\n workspaceStore,\n options,\n } satisfies ModalProps)\n\n /** Snapshot the workspace store when the modal is opened. */\n const handleModalOpen = () => {\n workspaceStoreSnapshot.value = window.structuredClone(workspaceStore.exportWorkspace())\n }\n\n /** Restore the workspace store when the modal is closed. */\n const handleModalClose = () => {\n requestBodyCompositionSelection.value = {}\n\n if (!workspaceStoreSnapshot.value) {\n console.warn('No workspace store snapshot to restore')\n return\n }\n\n const result = restoreWorkspaceState({\n workspaceStore,\n workspaceState: workspaceStoreSnapshot.value,\n name: documentSlug.value ?? '',\n })\n\n if (!result.ok) {\n console.error('Failed to restore workspace state', result.error)\n }\n return\n }\n\n watch(\n () => modalState.open,\n (open) => (open ? handleModalOpen() : handleModalClose()),\n )\n\n // Use a unique id prefix to prevent collisions with other Vue apps on the page\n app.config.idPrefix = 'scalar-client'\n\n /** Mount the modal to a given element. */\n const mount = (mountingEl: HTMLElement | null = el): void => {\n if (!mountingEl) {\n console.error(\n '[@scalar/api-client] Could not create the API client Modal.',\n 'Invalid HTML element provided.',\n 'Read more: https://github.com/scalar/scalar/tree/main/packages/api-client',\n )\n return\n }\n app.mount(mountingEl)\n }\n\n if (mountOnInitialize) {\n mount()\n }\n\n return {\n /** The Vue app instance for the modal. Use with caution. */\n app,\n /** Open the modal and optionally navigate to a specific route. */\n open: (payload?: RoutePayload): void => {\n modalState.open = true\n if (payload) {\n route(payload)\n }\n },\n /** Mount the modal to a given element. */\n mount,\n /** Navigate to the specified path, method, and example. */\n route,\n /** Controls the visibility of the modal. */\n modalState,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgDA,IAAa,wBAAwB,EACnC,IACA,WAAW,wBAAwB,EACjC,OAAA,OACD,CAAC,EACF,oBAAoB,MACpB,UAAU,EAAE,EACZ,gBACA,UAAU,EAAE,OACqC;CACjD,MAAM,kCAAkC,IAA4B,EAAE,CAAC;CAEvE,MAAM,kBAAmC;EACvC,MAAM;EACN,QAAQ;EACR,SAAS;EACT,cAAc,eAAe,UAAU,+BAA+B;EACvE;CAED,MAAM,yBAAyB,IAA8B,KAAK;CAElE,MAAM,aAAa,SAA0B,EAAE,GAAG,iBAAiB,CAAC;;CAGpE,MAAM,SAAS,YAAgC;AAC7C,SAAO,OAAO,YAAY,iBAAiB,QAAQ;;;CAIrD,MAAM,qBAAqB,eAAe,uBAAuB,gBAAgB,WAAW,CAAC;CAC7F,M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ventBus } from '@scalar/workspace-store/events';
|
|
4
4
|
import { type Ref } from 'vue';
|
|
5
5
|
import type { UseModalSidebarReturn } from '../../../v2/features/modal/hooks/use-modal-sidebar.js';
|
|
6
|
-
export declare function initializeModalEvents({ eventBus, isSidebarOpen, sidebarState, modalState, store, }: {
|
|
6
|
+
export declare function initializeModalEvents({ eventBus, isSidebarOpen, requestBodyCompositionSelection, sidebarState, modalState, store, }: {
|
|
7
7
|
eventBus: WorkspaceEventBus;
|
|
8
8
|
isSidebarOpen: Ref<boolean>;
|
|
9
|
+
requestBodyCompositionSelection: Ref<Record<string, number>>;
|
|
9
10
|
sidebarState: UseModalSidebarReturn;
|
|
10
11
|
modalState: ModalState;
|
|
11
12
|
store: WorkspaceStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-events.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/modal/modal-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,KAAK,CAAA;AAEnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;
|
|
1
|
+
{"version":3,"file":"modal-events.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/modal/modal-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,KAAK,CAAA;AAEnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AAKxF,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,aAAa,EACb,+BAA+B,EAC/B,YAAY,EACZ,UAAU,EACV,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAC3B,+BAA+B,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC5D,YAAY,EAAE,qBAAqB,CAAA;IACnC,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,EAAE,cAAc,CAAA;CACtB,QAoEA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { initializeWorkspaceEventHandlers } from "../../workspace-events.js";
|
|
2
2
|
import { ref } from "vue";
|
|
3
3
|
//#region src/v2/features/modal/modal-events.ts
|
|
4
|
-
|
|
4
|
+
var EMPTY_REQUEST_BODY_COMPOSITION_SELECTION = {};
|
|
5
|
+
function initializeModalEvents({ eventBus, isSidebarOpen, requestBodyCompositionSelection, sidebarState, modalState, store }) {
|
|
5
6
|
/** Initialize workspace event handlers */
|
|
6
7
|
initializeWorkspaceEventHandlers({
|
|
7
8
|
eventBus,
|
|
@@ -12,6 +13,7 @@ function initializeModalEvents({ eventBus, isSidebarOpen, sidebarState, modalSta
|
|
|
12
13
|
eventBus.on("ui:toggle:sidebar", () => isSidebarOpen.value = !isSidebarOpen.value);
|
|
13
14
|
eventBus.on("ui:close:client-modal", () => modalState.hide());
|
|
14
15
|
eventBus.on("ui:open:client-modal", (payload) => {
|
|
16
|
+
requestBodyCompositionSelection.value = payload && "requestBodyCompositionSelection" in payload && payload.requestBodyCompositionSelection ? payload.requestBodyCompositionSelection : EMPTY_REQUEST_BODY_COMPOSITION_SELECTION;
|
|
15
17
|
if (!payload) {
|
|
16
18
|
modalState.show();
|
|
17
19
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-events.js","names":[],"sources":["../../../../src/v2/features/modal/modal-events.ts"],"sourcesContent":["import type { ModalState } from '@scalar/components'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport { type Ref, ref } from 'vue'\n\nimport type { UseModalSidebarReturn } from '@/v2/features/modal/hooks/use-modal-sidebar'\nimport { initializeWorkspaceEventHandlers } from '@/v2/workspace-events'\n\nexport function initializeModalEvents({\n eventBus,\n isSidebarOpen,\n sidebarState,\n modalState,\n store,\n}: {\n eventBus: WorkspaceEventBus\n isSidebarOpen: Ref<boolean>\n sidebarState: UseModalSidebarReturn\n modalState: ModalState\n store: WorkspaceStore\n}) {\n /** Initialize workspace event handlers */\n initializeWorkspaceEventHandlers({\n eventBus,\n store: ref(store),\n hooks: {},\n })\n\n //------------------------------------------------------------------------------------\n // Navigation Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('scroll-to:nav-item', ({ id }) => sidebarState.handleSelectItem(id))\n\n //------------------------------------------------------------------------------------\n // UI Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('ui:toggle:sidebar', () => (isSidebarOpen.value = !isSidebarOpen.value))\n eventBus.on('ui:close:client-modal', () => modalState.hide())\n eventBus.on('ui:open:client-modal', (payload) => {\n // Just open the modal\n if (!payload) {\n modalState.show()\n return\n }\n\n // We route to the exact ID\n if ('id' in payload && payload.id) {\n let targetId = payload.id\n\n // If exampleName is provided, try to find the specific example entry\n if ('exampleName' in payload && payload.exampleName) {\n const operationEntry = sidebarState.state.getEntryById(payload.id)\n\n // Try to find the specific example in the operation's children\n if (operationEntry && 'children' in operationEntry && operationEntry.children) {\n const exampleEntry = operationEntry.children.find(\n (child: TraversedEntry) => child.type === 'example' && child.name === payload.exampleName,\n )\n if (exampleEntry) {\n targetId = exampleEntry.id\n }\n }\n }\n\n sidebarState.handleSelectItem(targetId)\n }\n // We must find the ID first from the entries\n else if ('method' in payload && 'path' in payload) {\n sidebarState.handleSelectItem(\n sidebarState.getEntryByLocation({\n document: store.workspace.activeDocument?.['x-scalar-navigation']?.id ?? '',\n path: payload.path,\n method: payload.method,\n example: payload.exampleName,\n })?.id ?? '',\n )\n }\n\n modalState.show()\n })\n}\n"],"mappings":";;;AASA,SAAgB,sBAAsB,EACpC,UACA,eACA,cACA,YACA,
|
|
1
|
+
{"version":3,"file":"modal-events.js","names":[],"sources":["../../../../src/v2/features/modal/modal-events.ts"],"sourcesContent":["import type { ModalState } from '@scalar/components'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport { type Ref, ref } from 'vue'\n\nimport type { UseModalSidebarReturn } from '@/v2/features/modal/hooks/use-modal-sidebar'\nimport { initializeWorkspaceEventHandlers } from '@/v2/workspace-events'\n\nconst EMPTY_REQUEST_BODY_COMPOSITION_SELECTION = {} as Record<string, number>\n\nexport function initializeModalEvents({\n eventBus,\n isSidebarOpen,\n requestBodyCompositionSelection,\n sidebarState,\n modalState,\n store,\n}: {\n eventBus: WorkspaceEventBus\n isSidebarOpen: Ref<boolean>\n requestBodyCompositionSelection: Ref<Record<string, number>>\n sidebarState: UseModalSidebarReturn\n modalState: ModalState\n store: WorkspaceStore\n}) {\n /** Initialize workspace event handlers */\n initializeWorkspaceEventHandlers({\n eventBus,\n store: ref(store),\n hooks: {},\n })\n\n //------------------------------------------------------------------------------------\n // Navigation Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('scroll-to:nav-item', ({ id }) => sidebarState.handleSelectItem(id))\n\n //------------------------------------------------------------------------------------\n // UI Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('ui:toggle:sidebar', () => (isSidebarOpen.value = !isSidebarOpen.value))\n eventBus.on('ui:close:client-modal', () => modalState.hide())\n eventBus.on('ui:open:client-modal', (payload) => {\n const nextRequestBodyCompositionSelection = (\n payload && 'requestBodyCompositionSelection' in payload && payload.requestBodyCompositionSelection\n ? payload.requestBodyCompositionSelection\n : EMPTY_REQUEST_BODY_COMPOSITION_SELECTION\n ) as Record<string, number>\n\n requestBodyCompositionSelection.value = nextRequestBodyCompositionSelection\n\n // Just open the modal\n if (!payload) {\n modalState.show()\n return\n }\n\n // We route to the exact ID\n if ('id' in payload && payload.id) {\n let targetId = payload.id\n\n // If exampleName is provided, try to find the specific example entry\n if ('exampleName' in payload && payload.exampleName) {\n const operationEntry = sidebarState.state.getEntryById(payload.id)\n\n // Try to find the specific example in the operation's children\n if (operationEntry && 'children' in operationEntry && operationEntry.children) {\n const exampleEntry = operationEntry.children.find(\n (child: TraversedEntry) => child.type === 'example' && child.name === payload.exampleName,\n )\n if (exampleEntry) {\n targetId = exampleEntry.id\n }\n }\n }\n\n sidebarState.handleSelectItem(targetId)\n }\n // We must find the ID first from the entries\n else if ('method' in payload && 'path' in payload) {\n sidebarState.handleSelectItem(\n sidebarState.getEntryByLocation({\n document: store.workspace.activeDocument?.['x-scalar-navigation']?.id ?? '',\n path: payload.path,\n method: payload.method,\n example: payload.exampleName,\n })?.id ?? '',\n )\n }\n\n modalState.show()\n })\n}\n"],"mappings":";;;AASA,IAAM,2CAA2C,EAAE;AAEnD,SAAgB,sBAAsB,EACpC,UACA,eACA,iCACA,cACA,YACA,SAQC;;AAED,kCAAiC;EAC/B;EACA,OAAO,IAAI,MAAM;EACjB,OAAO,EAAE;EACV,CAAC;AAKF,UAAS,GAAG,uBAAuB,EAAE,SAAS,aAAa,iBAAiB,GAAG,CAAC;AAKhF,UAAS,GAAG,2BAA4B,cAAc,QAAQ,CAAC,cAAc,MAAO;AACpF,UAAS,GAAG,+BAA+B,WAAW,MAAM,CAAC;AAC7D,UAAS,GAAG,yBAAyB,YAAY;AAO/C,kCAAgC,QAL9B,WAAW,qCAAqC,WAAW,QAAQ,kCAC/D,QAAQ,kCACR;AAMN,MAAI,CAAC,SAAS;AACZ,cAAW,MAAM;AACjB;;AAIF,MAAI,QAAQ,WAAW,QAAQ,IAAI;GACjC,IAAI,WAAW,QAAQ;AAGvB,OAAI,iBAAiB,WAAW,QAAQ,aAAa;IACnD,MAAM,iBAAiB,aAAa,MAAM,aAAa,QAAQ,GAAG;AAGlE,QAAI,kBAAkB,cAAc,kBAAkB,eAAe,UAAU;KAC7E,MAAM,eAAe,eAAe,SAAS,MAC1C,UAA0B,MAAM,SAAS,aAAa,MAAM,SAAS,QAAQ,YAC/E;AACD,SAAI,aACF,YAAW,aAAa;;;AAK9B,gBAAa,iBAAiB,SAAS;aAGhC,YAAY,WAAW,UAAU,QACxC,cAAa,iBACX,aAAa,mBAAmB;GAC9B,UAAU,MAAM,UAAU,iBAAiB,wBAAwB,MAAM;GACzE,MAAM,QAAQ;GACd,QAAQ,QAAQ;GAChB,SAAS,QAAQ;GAClB,CAAC,EAAE,MAAM,GACX;AAGH,aAAW,MAAM;GACjB"}
|
|
@@ -13,8 +13,12 @@ export default _default;
|
|
|
13
13
|
declare const __VLS_export: import("vue").DefineComponent<RouteProps & {
|
|
14
14
|
/** Subset of config options for the modal */
|
|
15
15
|
options?: ModalProps["options"];
|
|
16
|
+
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
17
|
+
requestBodyCompositionSelection?: Record<string, number>;
|
|
16
18
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<RouteProps & {
|
|
17
19
|
/** Subset of config options for the modal */
|
|
18
20
|
options?: ModalProps["options"];
|
|
21
|
+
/** Selected anyOf/oneOf request-body variants keyed by schema path */
|
|
22
|
+
requestBodyCompositionSelection?: Record<string, number>;
|
|
19
23
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
24
|
//# sourceMappingURL=Operation.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operation.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/operation/Operation.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Operation.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/operation/Operation.vue"],"names":[],"mappings":"AA+OA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAO/D;;;;;;;GAOG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEd,6CAA6C;cACnC,UAAU,CAAC,SAAS,CAAC;IAC/B,sEAAsE;sCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;IAHxD,6CAA6C;cACnC,UAAU,CAAC,SAAS,CAAC;IAC/B,sEAAsE;sCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;iGAyRxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operation.vue.js","names":[],"sources":["../../../../src/v2/features/operation/Operation.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Operation example page\n *\n * Displays an operation with a specific example selected\n * - View example request data\n * - Modify example request data\n * - Send example request\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { AuthMeta, ServerMeta } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { computed, toValue } from 'vue'\n\nimport { OperationBlock } from '@/v2/blocks/operation-block'\nimport type { ExtendedScalarCookie } from '@/v2/blocks/request-block/RequestBlock.vue'\nimport { APP_VERSION } from '@/v2/constants'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { mapHiddenClientsConfig } from '@/v2/features/modal/helpers/map-hidden-clients-config'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport { combineParams } from '@/v2/features/operation/helpers/combine-params'\nimport { getSelectedServer } from '@/v2/features/operation/helpers/get-selected-server'\nimport { getActiveProxyUrl } from '@/v2/helpers/get-active-proxy-url'\nimport { getServers } from '@/v2/helpers/get-servers'\n\nconst {\n document,\n layout,\n eventBus,\n path,\n method,\n environment,\n exampleName,\n options,\n securitySchemes,\n workspaceStore,\n plugins,\n documentSlug,\n} = defineProps<\n RouteProps & {\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n }\n>()\n\n/** Grab the path item object from the document */\nconst pathItem = computed(() => {\n if (!path) {\n return null\n }\n return getResolvedRef(document?.paths?.[path])\n})\n\n/** Find the operation and augment with any path parameters */\nconst operation = computed(() => {\n if (!path || !method) {\n return null\n }\n\n const operation = getResolvedRef(document?.paths?.[path]?.[method])\n if (!operation) {\n return null\n }\n\n if (!pathItem.value) {\n return operation\n }\n\n // We combine any path parameters with the operation parameters\n const parameters = combineParams(\n pathItem.value.parameters,\n operation.parameters,\n )\n return { ...operation, parameters }\n})\n\n/** Combine the workspace and document cookies */\nconst globalCookies = computed(() => [\n ...((workspaceStore.workspace?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'workspace',\n })) satisfies ExtendedScalarCookie[]),\n ...((document?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'document',\n })) satisfies ExtendedScalarCookie[]),\n])\n\n/** Compute the servers for the operation */\nconst servers = computed(() => {\n /**\n * Gather all the servers from the config, operation, pathItem, and document\n */\n const _servers =\n toValue(options)?.servers ??\n operation.value?.servers ??\n // pathItem.value?.servers ?? TODO: add support for pathItem servers\n document?.servers\n\n return getServers(_servers, {\n baseServerUrl: toValue(options)?.baseServerURL,\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n})\n\n/** Selected server URL from the same source as servers: operation, then document (config has no stored selection so use document selection) */\nconst selectedServerUrl = computed(() => {\n if (toValue(options)?.servers != null) {\n return document?.['x-scalar-selected-server']\n }\n if (operation.value?.servers != null) {\n return operation.value['x-scalar-selected-server']\n }\n return document?.['x-scalar-selected-server']\n})\n\n/** Selected server for the operation (document-level or operation-level servers) */\nconst selectedServer = computed(() =>\n getSelectedServer(servers.value, selectedServerUrl.value),\n)\n\nconst serverMeta = computed<ServerMeta>(() => {\n if (operation.value?.servers != null) {\n return { type: 'operation', path: path ?? '', method: method ?? 'get' }\n }\n return { type: 'document' }\n})\n\nconst documentSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'document',\n documentName: documentSlug,\n })\n})\n\nconst operationSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName: documentSlug,\n path: path ?? '',\n method: method ?? 'get',\n })\n})\n\n/** Select document vs operation meta based on the extension */\nconst authMeta = computed<AuthMeta>(() => {\n if (operationSelectedSecurity.value !== undefined) {\n return {\n type: 'operation',\n path: path ?? '',\n method: method ?? 'get',\n }\n }\n\n return { type: 'document' }\n})\n\n/** Combine environments from document and workspace into a unique array of environment names */\nconst environments = computed(() => {\n return Array.from(\n new Set(\n Object.keys({\n ...document?.['x-scalar-environments'],\n ...workspaceStore.workspace['x-scalar-environments'],\n }),\n ),\n )\n})\n\n/** Temporarily use the old config.hiddenClients until we migrate to the new httpClients config */\nconst httpClients = computed(() =>\n mapHiddenClientsConfig(toValue(options)?.hiddenClients),\n)\n</script>\n\n<template>\n <!-- Operation exists -->\n <template v-if=\"path && method && exampleName && operation\">\n <OperationBlock\n :activeEnvironment=\"\n workspaceStore.workspace['x-scalar-active-environment']\n \"\n :appVersion=\"APP_VERSION\"\n :authMeta\n :documentSecurity=\"document?.security ?? []\"\n :documentSelectedSecurity=\"documentSelectedSecurity\"\n :documentUrl=\"document?.['x-scalar-original-source-url']\"\n :environment\n :environments\n :eventBus\n :exampleKey=\"exampleName\"\n :globalCookies\n :hideClientButton=\"toValue(options)?.hideClientButton ?? false\"\n :history=\"workspaceStore.history.getHistory(documentSlug, path, method)\"\n :httpClients\n :layout\n :method\n :operation\n :operationSelectedSecurity=\"operationSelectedSecurity\"\n :path\n :plugins=\"plugins\"\n :proxyUrl=\"\n getActiveProxyUrl(\n workspaceStore.workspace['x-scalar-active-proxy'],\n layout,\n ) ?? ''\n \"\n :securitySchemes\n :selectedClient=\"workspaceStore.workspace['x-scalar-default-client']\"\n :server=\"selectedServer\"\n :serverMeta\n :servers />\n </template>\n\n <!-- Empty state -->\n <div\n v-else\n class=\"flex h-full w-full items-center justify-center\">\n <span class=\"text-c-3\">Select an operation to view details</span>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Operation.vue.js","names":[],"sources":["../../../../src/v2/features/operation/Operation.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Operation example page\n *\n * Displays an operation with a specific example selected\n * - View example request data\n * - Modify example request data\n * - Send example request\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { AuthMeta, ServerMeta } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { computed, toValue } from 'vue'\n\nimport { OperationBlock } from '@/v2/blocks/operation-block'\nimport type { ExtendedScalarCookie } from '@/v2/blocks/request-block/RequestBlock.vue'\nimport { APP_VERSION } from '@/v2/constants'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { mapHiddenClientsConfig } from '@/v2/features/modal/helpers/map-hidden-clients-config'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport { combineParams } from '@/v2/features/operation/helpers/combine-params'\nimport { getSelectedServer } from '@/v2/features/operation/helpers/get-selected-server'\nimport { getActiveProxyUrl } from '@/v2/helpers/get-active-proxy-url'\nimport { getServers } from '@/v2/helpers/get-servers'\n\nconst {\n document,\n layout,\n eventBus,\n path,\n method,\n environment,\n exampleName,\n options,\n securitySchemes,\n workspaceStore,\n plugins,\n documentSlug,\n} = defineProps<\n RouteProps & {\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>\n }\n>()\n\n/** Grab the path item object from the document */\nconst pathItem = computed(() => {\n if (!path) {\n return null\n }\n return getResolvedRef(document?.paths?.[path])\n})\n\n/** Find the operation and augment with any path parameters */\nconst operation = computed(() => {\n if (!path || !method) {\n return null\n }\n\n const operation = getResolvedRef(document?.paths?.[path]?.[method])\n if (!operation) {\n return null\n }\n\n if (!pathItem.value) {\n return operation\n }\n\n // We combine any path parameters with the operation parameters\n const parameters = combineParams(\n pathItem.value.parameters,\n operation.parameters,\n )\n return { ...operation, parameters }\n})\n\n/** Combine the workspace and document cookies */\nconst globalCookies = computed(() => [\n ...((workspaceStore.workspace?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'workspace',\n })) satisfies ExtendedScalarCookie[]),\n ...((document?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'document',\n })) satisfies ExtendedScalarCookie[]),\n])\n\n/** Compute the servers for the operation */\nconst servers = computed(() => {\n /**\n * Gather all the servers from the config, operation, pathItem, and document\n */\n const _servers =\n toValue(options)?.servers ??\n operation.value?.servers ??\n // pathItem.value?.servers ?? TODO: add support for pathItem servers\n document?.servers\n\n return getServers(_servers, {\n baseServerUrl: toValue(options)?.baseServerURL,\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n})\n\n/** Selected server URL from the same source as servers: operation, then document (config has no stored selection so use document selection) */\nconst selectedServerUrl = computed(() => {\n if (toValue(options)?.servers != null) {\n return document?.['x-scalar-selected-server']\n }\n if (operation.value?.servers != null) {\n return operation.value['x-scalar-selected-server']\n }\n return document?.['x-scalar-selected-server']\n})\n\n/** Selected server for the operation (document-level or operation-level servers) */\nconst selectedServer = computed(() =>\n getSelectedServer(servers.value, selectedServerUrl.value),\n)\n\nconst serverMeta = computed<ServerMeta>(() => {\n if (operation.value?.servers != null) {\n return { type: 'operation', path: path ?? '', method: method ?? 'get' }\n }\n return { type: 'document' }\n})\n\nconst documentSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'document',\n documentName: documentSlug,\n })\n})\n\nconst operationSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName: documentSlug,\n path: path ?? '',\n method: method ?? 'get',\n })\n})\n\n/** Select document vs operation meta based on the extension */\nconst authMeta = computed<AuthMeta>(() => {\n if (operationSelectedSecurity.value !== undefined) {\n return {\n type: 'operation',\n path: path ?? '',\n method: method ?? 'get',\n }\n }\n\n return { type: 'document' }\n})\n\n/** Combine environments from document and workspace into a unique array of environment names */\nconst environments = computed(() => {\n return Array.from(\n new Set(\n Object.keys({\n ...document?.['x-scalar-environments'],\n ...workspaceStore.workspace['x-scalar-environments'],\n }),\n ),\n )\n})\n\n/** Temporarily use the old config.hiddenClients until we migrate to the new httpClients config */\nconst httpClients = computed(() =>\n mapHiddenClientsConfig(toValue(options)?.hiddenClients),\n)\n</script>\n\n<template>\n <!-- Operation exists -->\n <template v-if=\"path && method && exampleName && operation\">\n <OperationBlock\n :activeEnvironment=\"\n workspaceStore.workspace['x-scalar-active-environment']\n \"\n :appVersion=\"APP_VERSION\"\n :authMeta\n :documentSecurity=\"document?.security ?? []\"\n :documentSelectedSecurity=\"documentSelectedSecurity\"\n :documentUrl=\"document?.['x-scalar-original-source-url']\"\n :environment\n :environments\n :eventBus\n :exampleKey=\"exampleName\"\n :globalCookies\n :hideClientButton=\"toValue(options)?.hideClientButton ?? false\"\n :history=\"workspaceStore.history.getHistory(documentSlug, path, method)\"\n :httpClients\n :layout\n :method\n :operation\n :operationSelectedSecurity=\"operationSelectedSecurity\"\n :path\n :plugins=\"plugins\"\n :proxyUrl=\"\n getActiveProxyUrl(\n workspaceStore.workspace['x-scalar-active-proxy'],\n layout,\n ) ?? ''\n \"\n :requestBodyCompositionSelection\n :securitySchemes\n :selectedClient=\"workspaceStore.workspace['x-scalar-default-client']\"\n :server=\"selectedServer\"\n :serverMeta\n :servers />\n </template>\n\n <!-- Empty state -->\n <div\n v-else\n class=\"flex h-full w-full items-center justify-center\">\n <span class=\"text-c-3\">Select an operation to view details</span>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -33,7 +33,8 @@ var Operation_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
33
33
|
fetchRegistryDocument: { type: Function },
|
|
34
34
|
telemetry: { type: Boolean },
|
|
35
35
|
onUpdateTelemetry: { type: Function },
|
|
36
|
-
options: {}
|
|
36
|
+
options: {},
|
|
37
|
+
requestBodyCompositionSelection: {}
|
|
37
38
|
},
|
|
38
39
|
setup(__props) {
|
|
39
40
|
/** Grab the path item object from the document */
|
|
@@ -140,6 +141,7 @@ var Operation_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
140
141
|
path: __props.path,
|
|
141
142
|
plugins: __props.plugins,
|
|
142
143
|
proxyUrl: unref(getActiveProxyUrl)(__props.workspaceStore.workspace["x-scalar-active-proxy"], __props.layout) ?? "",
|
|
144
|
+
requestBodyCompositionSelection: __props.requestBodyCompositionSelection,
|
|
143
145
|
securitySchemes: __props.securitySchemes,
|
|
144
146
|
selectedClient: __props.workspaceStore.workspace["x-scalar-default-client"],
|
|
145
147
|
server: selectedServer.value,
|
|
@@ -167,6 +169,7 @@ var Operation_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
167
169
|
"path",
|
|
168
170
|
"plugins",
|
|
169
171
|
"proxyUrl",
|
|
172
|
+
"requestBodyCompositionSelection",
|
|
170
173
|
"securitySchemes",
|
|
171
174
|
"selectedClient",
|
|
172
175
|
"server",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operation.vue.script.js","names":[],"sources":["../../../../src/v2/features/operation/Operation.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Operation example page\n *\n * Displays an operation with a specific example selected\n * - View example request data\n * - Modify example request data\n * - Send example request\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { AuthMeta, ServerMeta } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { computed, toValue } from 'vue'\n\nimport { OperationBlock } from '@/v2/blocks/operation-block'\nimport type { ExtendedScalarCookie } from '@/v2/blocks/request-block/RequestBlock.vue'\nimport { APP_VERSION } from '@/v2/constants'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { mapHiddenClientsConfig } from '@/v2/features/modal/helpers/map-hidden-clients-config'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport { combineParams } from '@/v2/features/operation/helpers/combine-params'\nimport { getSelectedServer } from '@/v2/features/operation/helpers/get-selected-server'\nimport { getActiveProxyUrl } from '@/v2/helpers/get-active-proxy-url'\nimport { getServers } from '@/v2/helpers/get-servers'\n\nconst {\n document,\n layout,\n eventBus,\n path,\n method,\n environment,\n exampleName,\n options,\n securitySchemes,\n workspaceStore,\n plugins,\n documentSlug,\n} = defineProps<\n RouteProps & {\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n }\n>()\n\n/** Grab the path item object from the document */\nconst pathItem = computed(() => {\n if (!path) {\n return null\n }\n return getResolvedRef(document?.paths?.[path])\n})\n\n/** Find the operation and augment with any path parameters */\nconst operation = computed(() => {\n if (!path || !method) {\n return null\n }\n\n const operation = getResolvedRef(document?.paths?.[path]?.[method])\n if (!operation) {\n return null\n }\n\n if (!pathItem.value) {\n return operation\n }\n\n // We combine any path parameters with the operation parameters\n const parameters = combineParams(\n pathItem.value.parameters,\n operation.parameters,\n )\n return { ...operation, parameters }\n})\n\n/** Combine the workspace and document cookies */\nconst globalCookies = computed(() => [\n ...((workspaceStore.workspace?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'workspace',\n })) satisfies ExtendedScalarCookie[]),\n ...((document?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'document',\n })) satisfies ExtendedScalarCookie[]),\n])\n\n/** Compute the servers for the operation */\nconst servers = computed(() => {\n /**\n * Gather all the servers from the config, operation, pathItem, and document\n */\n const _servers =\n toValue(options)?.servers ??\n operation.value?.servers ??\n // pathItem.value?.servers ?? TODO: add support for pathItem servers\n document?.servers\n\n return getServers(_servers, {\n baseServerUrl: toValue(options)?.baseServerURL,\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n})\n\n/** Selected server URL from the same source as servers: operation, then document (config has no stored selection so use document selection) */\nconst selectedServerUrl = computed(() => {\n if (toValue(options)?.servers != null) {\n return document?.['x-scalar-selected-server']\n }\n if (operation.value?.servers != null) {\n return operation.value['x-scalar-selected-server']\n }\n return document?.['x-scalar-selected-server']\n})\n\n/** Selected server for the operation (document-level or operation-level servers) */\nconst selectedServer = computed(() =>\n getSelectedServer(servers.value, selectedServerUrl.value),\n)\n\nconst serverMeta = computed<ServerMeta>(() => {\n if (operation.value?.servers != null) {\n return { type: 'operation', path: path ?? '', method: method ?? 'get' }\n }\n return { type: 'document' }\n})\n\nconst documentSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'document',\n documentName: documentSlug,\n })\n})\n\nconst operationSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName: documentSlug,\n path: path ?? '',\n method: method ?? 'get',\n })\n})\n\n/** Select document vs operation meta based on the extension */\nconst authMeta = computed<AuthMeta>(() => {\n if (operationSelectedSecurity.value !== undefined) {\n return {\n type: 'operation',\n path: path ?? '',\n method: method ?? 'get',\n }\n }\n\n return { type: 'document' }\n})\n\n/** Combine environments from document and workspace into a unique array of environment names */\nconst environments = computed(() => {\n return Array.from(\n new Set(\n Object.keys({\n ...document?.['x-scalar-environments'],\n ...workspaceStore.workspace['x-scalar-environments'],\n }),\n ),\n )\n})\n\n/** Temporarily use the old config.hiddenClients until we migrate to the new httpClients config */\nconst httpClients = computed(() =>\n mapHiddenClientsConfig(toValue(options)?.hiddenClients),\n)\n</script>\n\n<template>\n <!-- Operation exists -->\n <template v-if=\"path && method && exampleName && operation\">\n <OperationBlock\n :activeEnvironment=\"\n workspaceStore.workspace['x-scalar-active-environment']\n \"\n :appVersion=\"APP_VERSION\"\n :authMeta\n :documentSecurity=\"document?.security ?? []\"\n :documentSelectedSecurity=\"documentSelectedSecurity\"\n :documentUrl=\"document?.['x-scalar-original-source-url']\"\n :environment\n :environments\n :eventBus\n :exampleKey=\"exampleName\"\n :globalCookies\n :hideClientButton=\"toValue(options)?.hideClientButton ?? false\"\n :history=\"workspaceStore.history.getHistory(documentSlug, path, method)\"\n :httpClients\n :layout\n :method\n :operation\n :operationSelectedSecurity=\"operationSelectedSecurity\"\n :path\n :plugins=\"plugins\"\n :proxyUrl=\"\n getActiveProxyUrl(\n workspaceStore.workspace['x-scalar-active-proxy'],\n layout,\n ) ?? ''\n \"\n :securitySchemes\n :selectedClient=\"workspaceStore.workspace['x-scalar-default-client']\"\n :server=\"selectedServer\"\n :serverMeta\n :servers />\n </template>\n\n <!-- Empty state -->\n <div\n v-else\n class=\"flex h-full w-full items-center justify-center\">\n <span class=\"text-c-3\">Select an operation to view details</span>\n </div>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Operation.vue.script.js","names":[],"sources":["../../../../src/v2/features/operation/Operation.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Operation example page\n *\n * Displays an operation with a specific example selected\n * - View example request data\n * - Modify example request data\n * - Send example request\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { AuthMeta, ServerMeta } from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { computed, toValue } from 'vue'\n\nimport { OperationBlock } from '@/v2/blocks/operation-block'\nimport type { ExtendedScalarCookie } from '@/v2/blocks/request-block/RequestBlock.vue'\nimport { APP_VERSION } from '@/v2/constants'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { mapHiddenClientsConfig } from '@/v2/features/modal/helpers/map-hidden-clients-config'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport { combineParams } from '@/v2/features/operation/helpers/combine-params'\nimport { getSelectedServer } from '@/v2/features/operation/helpers/get-selected-server'\nimport { getActiveProxyUrl } from '@/v2/helpers/get-active-proxy-url'\nimport { getServers } from '@/v2/helpers/get-servers'\n\nconst {\n document,\n layout,\n eventBus,\n path,\n method,\n environment,\n exampleName,\n options,\n securitySchemes,\n workspaceStore,\n plugins,\n documentSlug,\n} = defineProps<\n RouteProps & {\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>\n }\n>()\n\n/** Grab the path item object from the document */\nconst pathItem = computed(() => {\n if (!path) {\n return null\n }\n return getResolvedRef(document?.paths?.[path])\n})\n\n/** Find the operation and augment with any path parameters */\nconst operation = computed(() => {\n if (!path || !method) {\n return null\n }\n\n const operation = getResolvedRef(document?.paths?.[path]?.[method])\n if (!operation) {\n return null\n }\n\n if (!pathItem.value) {\n return operation\n }\n\n // We combine any path parameters with the operation parameters\n const parameters = combineParams(\n pathItem.value.parameters,\n operation.parameters,\n )\n return { ...operation, parameters }\n})\n\n/** Combine the workspace and document cookies */\nconst globalCookies = computed(() => [\n ...((workspaceStore.workspace?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'workspace',\n })) satisfies ExtendedScalarCookie[]),\n ...((document?.['x-scalar-cookies'] ?? []).map((it) => ({\n ...it,\n location: 'document',\n })) satisfies ExtendedScalarCookie[]),\n])\n\n/** Compute the servers for the operation */\nconst servers = computed(() => {\n /**\n * Gather all the servers from the config, operation, pathItem, and document\n */\n const _servers =\n toValue(options)?.servers ??\n operation.value?.servers ??\n // pathItem.value?.servers ?? TODO: add support for pathItem servers\n document?.servers\n\n return getServers(_servers, {\n baseServerUrl: toValue(options)?.baseServerURL,\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n})\n\n/** Selected server URL from the same source as servers: operation, then document (config has no stored selection so use document selection) */\nconst selectedServerUrl = computed(() => {\n if (toValue(options)?.servers != null) {\n return document?.['x-scalar-selected-server']\n }\n if (operation.value?.servers != null) {\n return operation.value['x-scalar-selected-server']\n }\n return document?.['x-scalar-selected-server']\n})\n\n/** Selected server for the operation (document-level or operation-level servers) */\nconst selectedServer = computed(() =>\n getSelectedServer(servers.value, selectedServerUrl.value),\n)\n\nconst serverMeta = computed<ServerMeta>(() => {\n if (operation.value?.servers != null) {\n return { type: 'operation', path: path ?? '', method: method ?? 'get' }\n }\n return { type: 'document' }\n})\n\nconst documentSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'document',\n documentName: documentSlug,\n })\n})\n\nconst operationSelectedSecurity = computed<SelectedSecurity | undefined>(() => {\n return workspaceStore.auth.getAuthSelectedSchemas({\n type: 'operation',\n documentName: documentSlug,\n path: path ?? '',\n method: method ?? 'get',\n })\n})\n\n/** Select document vs operation meta based on the extension */\nconst authMeta = computed<AuthMeta>(() => {\n if (operationSelectedSecurity.value !== undefined) {\n return {\n type: 'operation',\n path: path ?? '',\n method: method ?? 'get',\n }\n }\n\n return { type: 'document' }\n})\n\n/** Combine environments from document and workspace into a unique array of environment names */\nconst environments = computed(() => {\n return Array.from(\n new Set(\n Object.keys({\n ...document?.['x-scalar-environments'],\n ...workspaceStore.workspace['x-scalar-environments'],\n }),\n ),\n )\n})\n\n/** Temporarily use the old config.hiddenClients until we migrate to the new httpClients config */\nconst httpClients = computed(() =>\n mapHiddenClientsConfig(toValue(options)?.hiddenClients),\n)\n</script>\n\n<template>\n <!-- Operation exists -->\n <template v-if=\"path && method && exampleName && operation\">\n <OperationBlock\n :activeEnvironment=\"\n workspaceStore.workspace['x-scalar-active-environment']\n \"\n :appVersion=\"APP_VERSION\"\n :authMeta\n :documentSecurity=\"document?.security ?? []\"\n :documentSelectedSecurity=\"documentSelectedSecurity\"\n :documentUrl=\"document?.['x-scalar-original-source-url']\"\n :environment\n :environments\n :eventBus\n :exampleKey=\"exampleName\"\n :globalCookies\n :hideClientButton=\"toValue(options)?.hideClientButton ?? false\"\n :history=\"workspaceStore.history.getHistory(documentSlug, path, method)\"\n :httpClients\n :layout\n :method\n :operation\n :operationSelectedSecurity=\"operationSelectedSecurity\"\n :path\n :plugins=\"plugins\"\n :proxyUrl=\"\n getActiveProxyUrl(\n workspaceStore.workspace['x-scalar-active-proxy'],\n layout,\n ) ?? ''\n \"\n :requestBodyCompositionSelection\n :securitySchemes\n :selectedClient=\"workspaceStore.workspace['x-scalar-default-client']\"\n :server=\"selectedServer\"\n :serverMeta\n :servers />\n </template>\n\n <!-- Empty state -->\n <div\n v-else\n class=\"flex h-full w-full items-center justify-center\">\n <span class=\"text-c-3\">Select an operation to view details</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDA,MAAM,WAAW,eAAe;AAC9B,OAAI,CAAC,QAAA,KACH,QAAO;AAET,UAAO,eAAe,QAAA,UAAU,QAAQ,QAAA,MAAK;IAC9C;;EAGD,MAAM,YAAY,eAAe;AAC/B,OAAI,CAAC,QAAA,QAAQ,CAAC,QAAA,OACZ,QAAO;GAGT,MAAM,YAAY,eAAe,QAAA,UAAU,QAAQ,QAAA,QAAQ,QAAA,QAAO;AAClE,OAAI,CAAC,UACH,QAAO;AAGT,OAAI,CAAC,SAAS,MACZ,QAAO;GAIT,MAAM,aAAa,cACjB,SAAS,MAAM,YACf,UAAU,WACZ;AACA,UAAO;IAAE,GAAG;IAAW;IAAW;IACnC;;EAGD,MAAM,gBAAgB,eAAe,CACnC,IAAK,QAAA,eAAe,YAA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
1
|
+
{"version":3,"file":"download-document.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/download-document.ts"],"names":[],"mappings":"AAiBA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,SAAqB,GAAG,IAAI,CAkBrG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/v2/helpers/download-document.ts
|
|
2
|
+
/**
|
|
3
|
+
* Triggers a file download in the browser for the given content.
|
|
4
|
+
* Creates a blob, programmatically clicks a temporary link, then revokes the object URL.
|
|
5
|
+
*
|
|
6
|
+
* @param content - The string content to download (e.g. JSON or YAML).
|
|
7
|
+
* @param filename - The name of the file to save (e.g. "my-api.json").
|
|
8
|
+
* @param mimeType - Optional MIME type for the blob. Defaults to "application/json".
|
|
9
|
+
*/
|
|
10
|
+
function createClickEvent() {
|
|
11
|
+
try {
|
|
12
|
+
return new MouseEvent("click", {
|
|
13
|
+
bubbles: true,
|
|
14
|
+
cancelable: true,
|
|
15
|
+
view: window
|
|
16
|
+
});
|
|
17
|
+
} catch {
|
|
18
|
+
return new MouseEvent("click", {
|
|
19
|
+
bubbles: true,
|
|
20
|
+
cancelable: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function downloadAsFile(content, filename, mimeType = "application/json") {
|
|
25
|
+
const blob = new Blob([content], { type: mimeType });
|
|
26
|
+
const url = URL.createObjectURL(blob);
|
|
27
|
+
const link = document.createElement("a");
|
|
28
|
+
link.href = url;
|
|
29
|
+
link.download = filename;
|
|
30
|
+
link.style.display = "none";
|
|
31
|
+
link.setAttribute("aria-hidden", "true");
|
|
32
|
+
document.body.appendChild(link);
|
|
33
|
+
link.dispatchEvent(createClickEvent());
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
URL.revokeObjectURL(url);
|
|
36
|
+
document.body.removeChild(link);
|
|
37
|
+
}, 100);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { downloadAsFile };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=download-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-document.js","names":[],"sources":["../../../src/v2/helpers/download-document.ts"],"sourcesContent":["/**\n * Triggers a file download in the browser for the given content.\n * Creates a blob, programmatically clicks a temporary link, then revokes the object URL.\n *\n * @param content - The string content to download (e.g. JSON or YAML).\n * @param filename - The name of the file to save (e.g. \"my-api.json\").\n * @param mimeType - Optional MIME type for the blob. Defaults to \"application/json\".\n */\nfunction createClickEvent(): MouseEvent {\n try {\n return new MouseEvent('click', { bubbles: true, cancelable: true, view: window })\n } catch {\n // Fallback for test environments where `view` is not a valid Window.\n return new MouseEvent('click', { bubbles: true, cancelable: true })\n }\n}\n\nexport function downloadAsFile(content: string, filename: string, mimeType = 'application/json'): void {\n const blob = new Blob([content], { type: mimeType })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = filename\n link.style.display = 'none'\n link.setAttribute('aria-hidden', 'true')\n document.body.appendChild(link)\n\n // This is necessary as link.click() does not work on the latest Firefox.\n link.dispatchEvent(createClickEvent())\n\n // For Firefox it is necessary to delay revoking the ObjectURL.\n setTimeout(() => {\n URL.revokeObjectURL(url)\n document.body.removeChild(link)\n }, 100)\n}\n"],"mappings":";;;;;;;;;AAQA,SAAS,mBAA+B;AACtC,KAAI;AACF,SAAO,IAAI,WAAW,SAAS;GAAE,SAAS;GAAM,YAAY;GAAM,MAAM;GAAQ,CAAC;SAC3E;AAEN,SAAO,IAAI,WAAW,SAAS;GAAE,SAAS;GAAM,YAAY;GAAM,CAAC;;;AAIvE,SAAgB,eAAe,SAAiB,UAAkB,WAAW,oBAA0B;CACrG,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,UAAU,CAAC;CACpD,MAAM,MAAM,IAAI,gBAAgB,KAAK;CACrC,MAAM,OAAO,SAAS,cAAc,IAAI;AACxC,MAAK,OAAO;AACZ,MAAK,WAAW;AAChB,MAAK,MAAM,UAAU;AACrB,MAAK,aAAa,eAAe,OAAO;AACxC,UAAS,KAAK,YAAY,KAAK;AAG/B,MAAK,cAAc,kBAAkB,CAAC;AAGtC,kBAAiB;AACf,MAAI,gBAAgB,IAAI;AACxB,WAAS,KAAK,YAAY,KAAK;IAC9B,IAAI"}
|
package/dist/v2/posthog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog.d.ts","sourceRoot":"","sources":["../../src/v2/posthog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"posthog.d.ts","sourceRoot":"","sources":["../../src/v2/posthog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,KAAK,CAAA;AAarC,eAAO,MAAM,UAAU,GAAI,SAAS,GAAG,CAAC,OAAO,CAAC,SAY/C,CAAA"}
|
package/dist/v2/posthog.js
CHANGED
|
@@ -7,6 +7,7 @@ var posthog = ph.init("phc_3elIjSOvGOo5aEwg6krzIY9IcQiRubsBtglOXsQ4Uu4", {
|
|
|
7
7
|
defaults: "2025-11-30",
|
|
8
8
|
opt_out_capturing_by_default: true
|
|
9
9
|
});
|
|
10
|
+
posthog.register({ product: "api-client" });
|
|
10
11
|
var usePosthog = (enabled) => {
|
|
11
12
|
watch(enabled, (value) => {
|
|
12
13
|
if (value) posthog.opt_in_capturing();
|
package/dist/v2/posthog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog.js","names":[],"sources":["../../src/v2/posthog.ts"],"sourcesContent":["import ph from 'posthog-js'\nimport { type Ref, watch } from 'vue'\n\nconst posthog = ph.init('phc_3elIjSOvGOo5aEwg6krzIY9IcQiRubsBtglOXsQ4Uu4', {\n api_host: 'https://magic.scalar.com',\n ui_host: 'https://us.posthog.com',\n defaults: '2025-11-30',\n opt_out_capturing_by_default: true,\n})\n\nexport const usePosthog = (enabled: Ref<boolean>) => {\n watch(\n enabled,\n (value) => {\n if (value) {\n posthog.opt_in_capturing()\n } else {\n posthog.opt_out_capturing()\n }\n },\n { immediate: true },\n )\n}\n"],"mappings":";;;AAGA,IAAM,UAAU,GAAG,KAAK,mDAAmD;CACzE,UAAU;CACV,SAAS;CACT,UAAU;CACV,8BAA8B;CAC/B,CAAC;AAEF,IAAa,cAAc,YAA0B;AACnD,OACE,UACC,UAAU;AACT,MAAI,MACF,SAAQ,kBAAkB;MAE1B,SAAQ,mBAAmB;IAG/B,EAAE,WAAW,MAAM,CACpB"}
|
|
1
|
+
{"version":3,"file":"posthog.js","names":[],"sources":["../../src/v2/posthog.ts"],"sourcesContent":["import ph from 'posthog-js'\nimport { type Ref, watch } from 'vue'\n\nconst posthog = ph.init('phc_3elIjSOvGOo5aEwg6krzIY9IcQiRubsBtglOXsQ4Uu4', {\n api_host: 'https://magic.scalar.com',\n ui_host: 'https://us.posthog.com',\n defaults: '2025-11-30',\n opt_out_capturing_by_default: true,\n})\n\nposthog.register({\n product: 'api-client',\n})\n\nexport const usePosthog = (enabled: Ref<boolean>) => {\n watch(\n enabled,\n (value) => {\n if (value) {\n posthog.opt_in_capturing()\n } else {\n posthog.opt_out_capturing()\n }\n },\n { immediate: true },\n )\n}\n"],"mappings":";;;AAGA,IAAM,UAAU,GAAG,KAAK,mDAAmD;CACzE,UAAU;CACV,SAAS;CACT,UAAU;CACV,8BAA8B;CAC/B,CAAC;AAEF,QAAQ,SAAS,EACf,SAAS,cACV,CAAC;AAEF,IAAa,cAAc,YAA0B;AACnD,OACE,UACC,UAAU;AACT,MAAI,MACF,SAAQ,kBAAkB;MAE1B,SAAQ,mBAAmB;IAG/B,EAAE,WAAW,MAAM,CACpB"}
|
|
@@ -45,7 +45,7 @@ var ResponseEmpty_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
45
45
|
const handleHotKey = (event) => {
|
|
46
46
|
if (event?.createNew && route.name === "request") addRequest();
|
|
47
47
|
};
|
|
48
|
-
const packageVersion = "2.39.
|
|
48
|
+
const packageVersion = "2.39.2";
|
|
49
49
|
onMounted(() => events.hotKeys.on(handleHotKey));
|
|
50
50
|
onBeforeUnmount(() => events.hotKeys.off(handleHotKey));
|
|
51
51
|
return (_ctx, _cache) => {
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "2.39.
|
|
21
|
+
"version": "2.39.2",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=22"
|
|
24
24
|
},
|
|
@@ -347,24 +347,24 @@
|
|
|
347
347
|
"whatwg-mimetype": "4.0.0",
|
|
348
348
|
"yaml": "^2.8.0",
|
|
349
349
|
"zod": "^4.3.5",
|
|
350
|
-
"@scalar/components": "0.21.
|
|
351
|
-
"@scalar/helpers": "0.4.2",
|
|
350
|
+
"@scalar/components": "0.21.1",
|
|
352
351
|
"@scalar/draggable": "0.4.1",
|
|
353
|
-
"@scalar/icons": "0.
|
|
354
|
-
"@scalar/
|
|
352
|
+
"@scalar/icons": "0.7.0",
|
|
353
|
+
"@scalar/helpers": "0.4.2",
|
|
355
354
|
"@scalar/json-magic": "0.12.4",
|
|
356
|
-
"@scalar/oas-utils": "0.10.
|
|
355
|
+
"@scalar/oas-utils": "0.10.13",
|
|
356
|
+
"@scalar/import": "0.5.3",
|
|
357
357
|
"@scalar/object-utils": "1.3.3",
|
|
358
|
+
"@scalar/sidebar": "0.8.15",
|
|
358
359
|
"@scalar/openapi-types": "0.6.1",
|
|
359
360
|
"@scalar/postman-to-openapi": "0.6.0",
|
|
360
|
-
"@scalar/
|
|
361
|
-
"@scalar/snippetz": "0.7.6",
|
|
362
|
-
"@scalar/themes": "0.15.1",
|
|
361
|
+
"@scalar/snippetz": "0.7.7",
|
|
363
362
|
"@scalar/use-codemirror": "0.14.10",
|
|
364
|
-
"@scalar/types": "0.7.
|
|
365
|
-
"@scalar/use-toasts": "0.10.1",
|
|
363
|
+
"@scalar/types": "0.7.5",
|
|
366
364
|
"@scalar/use-hooks": "0.4.1",
|
|
367
|
-
"@scalar/
|
|
365
|
+
"@scalar/use-toasts": "0.10.1",
|
|
366
|
+
"@scalar/themes": "0.15.1",
|
|
367
|
+
"@scalar/workspace-store": "0.41.2"
|
|
368
368
|
},
|
|
369
369
|
"devDependencies": {
|
|
370
370
|
"@tailwindcss/vite": "^4.2.0",
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
"vite-svg-loader": "5.1.1",
|
|
381
381
|
"vitest": "4.1.0",
|
|
382
382
|
"@scalar/galaxy": "0.6.1",
|
|
383
|
-
"@scalar/pre-post-request-scripts": "0.3.
|
|
383
|
+
"@scalar/pre-post-request-scripts": "0.3.15"
|
|
384
384
|
},
|
|
385
385
|
"scripts": {
|
|
386
386
|
"build": "vite build && vue-tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|