@scalar/api-client 2.40.0 → 2.42.0
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 +21 -0
- package/dist/hooks/useClientConfig.d.ts +3 -3
- package/dist/style.css +48 -1
- 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 +24 -10
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +18 -7
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/app/helpers/routes.d.ts +5 -0
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.js +5 -0
- package/dist/v2/features/app/helpers/routes.js.map +1 -1
- package/dist/v2/features/collection/components/DocumentScriptsEditors.vue.d.ts +12 -0
- package/dist/v2/features/collection/components/DocumentScriptsEditors.vue.d.ts.map +1 -0
- package/dist/v2/features/collection/components/DocumentScriptsEditors.vue.js +9 -0
- package/dist/v2/features/collection/components/DocumentScriptsEditors.vue.js.map +1 -0
- package/dist/v2/features/collection/components/DocumentScriptsEditors.vue.script.js +174 -0
- package/dist/v2/features/collection/components/DocumentScriptsEditors.vue.script.js.map +1 -0
- package/dist/v2/features/collection/components/Scripts.vue.d.ts +16 -0
- package/dist/v2/features/collection/components/Scripts.vue.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Scripts.vue.js +7 -0
- package/dist/v2/features/collection/components/Scripts.vue.js.map +1 -0
- package/dist/v2/features/collection/components/Scripts.vue.script.js +47 -0
- package/dist/v2/features/collection/components/Scripts.vue.script.js.map +1 -0
- package/dist/v2/features/collection/components/Tabs.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Tabs.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Tabs.vue.script.js +2 -1
- package/dist/v2/features/collection/components/Tabs.vue.script.js.map +1 -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 +2 -6
- 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 +1 -17
- package/dist/v2/features/modal/helpers/create-api-client-modal.js.map +1 -1
- package/dist/v2/features/modal/index.d.ts +1 -0
- package/dist/v2/features/modal/index.d.ts.map +1 -1
- 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 +5 -2
- package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
- package/dist/v2/workspace-events.d.ts.map +1 -1
- package/dist/v2/workspace-events.js +1 -0
- package/dist/v2/workspace-events.js.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.script.js +1 -1
- package/package.json +9 -9
- package/dist/v2/features/modal/helpers/restore-workspace-state.d.ts +0 -18
- package/dist/v2/features/modal/helpers/restore-workspace-state.d.ts.map +0 -1
- package/dist/v2/features/modal/helpers/restore-workspace-state.js +0 -51
- package/dist/v2/features/modal/helpers/restore-workspace-state.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE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A0C;IAC1C,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC7C,CAAA;AAED,oCAAoC;AACpC,MAAM,MAAM,eAAe,GAAG,UAAU,GACtC,CACI;IACE,cAAc,EAAE,UAAU,GAAG,WAAW,CAAA;IACxC,QAAQ,EAAE,iBAAiB,CAAA;CAC5B,GACD;IACE,cAAc,EAAE,WAAW,CAAA;IAC3B,QAAQ,EAAE,IAAI,CAAA;CACf,CACJ,CAAA;AAEH,MAAM,MAAM,0BAA0B,GAClC,WAAW,GACX,eAAe,GACf,cAAc,GACd,aAAa,GACb,QAAQ,GACR,aAAa,CAAA;AAEjB,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAlBK,UAAU,GAAG,WAAW;kCAC9B,iBAAiB;;wCAGX,WAAW;kCACjB,IAAI;;wCALE,UAAU,GAAG,WAAW;kCAC9B,iBAAiB;;wCAGX,WAAW;kCACjB,IAAI;;;;;;;;;;;;;;;;;;;;;oCALE,UAAU,GAAG,WAAW;8BAC9B,iBAAiB;;oCAGX,WAAW;8BACjB,IAAI;;oCALE,UAAU,GAAG,WAAW;8BAC9B,iBAAiB;;oCAGX,WAAW;8BACjB,IAAI;;;;;;;;;;;;;;;;;;;;gCALE,UAAU,GAAG,WAAW;0BAC9B,iBAAiB;;gCAGX,WAAW;0BACjB,IAAI;;gCALE,UAAU,GAAG,WAAW;0BAC9B,iBAAiB;;gCAGX,WAAW;0BACjB,IAAI;;;;;;;;;IAyKM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { mergeSearchParams } from '@scalar/helpers/url/merge-urls'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { Theme } from '@scalar/themes'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas/workspace'\nimport type { RouteRecordRaw } from 'vue-router'\n\nimport Authentication from '@/v2/features/collection/components/Authentication.vue'\nimport Cookies from '@/v2/features/collection/components/Cookies.vue'\nimport { Editor } from '@/v2/features/collection/components/Editor'\nimport Environment from '@/v2/features/collection/components/Environment.vue'\nimport Overview from '@/v2/features/collection/components/Overview.vue'\nimport Servers from '@/v2/features/collection/components/Servers.vue'\nimport Settings from '@/v2/features/collection/components/Settings.vue'\nimport DocumentCollection from '@/v2/features/collection/DocumentCollection.vue'\nimport OperationCollection from '@/v2/features/collection/OperationCollection.vue'\nimport WorkspaceCollection from '@/v2/features/collection/WorkspaceCollection.vue'\nimport { Operation } from '@/v2/features/operation'\nimport { workspaceStorage } from '@/v2/helpers/storage'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\n/** These props are provided at the route level */\nexport type RouteProps = {\n /** The slug of the currently selected document in the workspace */\n documentSlug: string\n /** The currently active document */\n document: WorkspaceDocument | null\n /** The workspace event bus */\n eventBus: WorkspaceEventBus\n /** The layout of the client */\n layout: ClientLayout\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path?: string\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method?: HttpMethod\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName?: string\n /** The currently active environment */\n environment: XScalarEnvironment\n /** The workspace store */\n workspaceStore: WorkspaceStore\n /** The currently active workspace */\n activeWorkspace: { id: string; label: string }\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Custom themes available to the team */\n customThemes?: Theme[]\n /** The currently selected theme styles string */\n currentTheme?: string\n /** Whether the current color mode is dark */\n isDarkMode?: boolean\n /**\n * Fetches the full document from registry by meta. When provided, registry meta takes priority\n * over x-scalar-original-source-url when syncing. Returns the document as a plain object.\n */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /** Whether telemetry is enabled */\n telemetry?: boolean\n /** Updates the telemetry enabled state */\n onUpdateTelemetry?: (value: boolean) => void\n}\n\n/** When in the collections pages */\nexport type CollectionProps = RouteProps &\n (\n | {\n collectionType: 'document' | 'operation'\n document: WorkspaceDocument\n }\n | {\n collectionType: 'workspace'\n document: null\n }\n )\n\nexport type ScalarClientAppRouteParams =\n | 'namespace'\n | 'workspaceSlug'\n | 'documentSlug'\n | 'pathEncoded'\n | 'method'\n | 'exampleName'\n\n/** Routes for the API client app and web, the same as modal + workspace routes */\nexport const ROUTES = [\n {\n path: '/@:namespace/:workspaceSlug',\n children: [\n {\n path: 'document/:documentSlug',\n children: [\n // Example page\n {\n path: 'path/:pathEncoded/method/:method',\n children: [\n {\n name: 'example',\n path: 'example/:exampleName',\n component: Operation,\n },\n {\n name: 'operation',\n path: '',\n component: OperationCollection,\n redirect: {\n name: 'operation.overview',\n },\n children: [\n {\n name: 'operation.overview',\n path: 'overview',\n component: Overview,\n },\n {\n name: 'operation.servers',\n path: 'servers',\n component: Servers,\n },\n {\n name: 'operation.authentication',\n path: 'authentication',\n component: Authentication,\n },\n {\n name: 'operation.editor',\n path: 'editor',\n component: Editor,\n },\n ],\n },\n ],\n },\n // Document Page\n {\n name: 'document',\n path: '',\n component: DocumentCollection,\n children: [\n // Redirect to overview\n {\n name: 'document.redirect',\n path: '',\n redirect: {\n name: 'document.overview',\n },\n },\n // Document overview\n {\n name: 'document.overview',\n path: 'overview',\n component: Overview,\n },\n // Document servers\n {\n name: 'document.servers',\n path: 'servers',\n component: Servers,\n },\n // Document environment\n {\n name: 'document.environment',\n path: 'environment',\n component: Environment,\n },\n // Document authentication\n {\n name: 'document.authentication',\n path: 'authentication',\n component: Authentication,\n },\n // Document cookies\n {\n name: 'document.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Document settings\n {\n name: 'document.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n // Workspace page\n {\n name: 'workspace',\n path: '',\n component: WorkspaceCollection,\n children: [\n // Workspace environment\n {\n name: 'workspace.environment',\n path: 'environment',\n component: Environment,\n },\n // Workspace cookies\n {\n name: 'workspace.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Workspace settings\n {\n name: 'workspace.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n {\n path: '/:pathMatch(.*)*',\n redirect: () => {\n const DEFAULT_PATH = '/@local/default/document/drafts/overview'\n const lastPath = workspaceStorage.getLastPath() ?? DEFAULT_PATH\n\n // Set the default path to the last path so we don't go to an inifite loop if the last path is invalid\n workspaceStorage.setCurrentPath(DEFAULT_PATH)\n\n const url = new URL(lastPath, 'http://example.com')\n\n const queryParameters = new URLSearchParams(window.location.search)\n\n //Merge the query parameters with the last path\n const mergedSearchParams = mergeSearchParams(url.searchParams, queryParameters)\n\n // Preserve all query paramters\n return `${url.pathname}?${mergedSearchParams.toString()}`\n },\n },\n] satisfies RouteRecordRaw[]\n"],"mappings":";;;;;;;;;;;;;;;AAwFA,IAAa,SAAS,CACpB;CACE,MAAM;CACN,UAAU,CACR;EACE,MAAM;EACN,UAAU,CAER;GACE,MAAM;GACN,UAAU,CACR;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ,EACD;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACX,UAAU,EACR,MAAM,sBACP;IACD,UAAU;KACR;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACF;IACF,CACF;GACF,EAED;GACE,MAAM;GACN,MAAM;GACN,WAAW;GACX,UAAU;IAER;KACE,MAAM;KACN,MAAM;KACN,UAAU,EACR,MAAM,qBACP;KACF;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IACF;GACF,CACF;EACF,EAED;EACE,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU;GAER;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GACF;EACF,CACF;CACF,EACD;CACE,MAAM;CACN,gBAAgB;EACd,MAAM,eAAe;EACrB,MAAM,WAAW,iBAAiB,aAAa,IAAI;AAGnD,mBAAiB,eAAe,aAAa;EAE7C,MAAM,MAAM,IAAI,IAAI,UAAU,qBAAqB;EAEnD,MAAM,kBAAkB,IAAI,gBAAgB,OAAO,SAAS,OAAO;EAGnE,MAAM,qBAAqB,kBAAkB,IAAI,cAAc,gBAAgB;AAG/E,SAAO,GAAG,IAAI,SAAS,GAAG,mBAAmB,UAAU;;CAE1D,CACF"}
|
|
1
|
+
{"version":3,"file":"routes.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { mergeSearchParams } from '@scalar/helpers/url/merge-urls'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { Theme } from '@scalar/themes'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas/workspace'\nimport type { RouteRecordRaw } from 'vue-router'\n\nimport Authentication from '@/v2/features/collection/components/Authentication.vue'\nimport Cookies from '@/v2/features/collection/components/Cookies.vue'\nimport { Editor } from '@/v2/features/collection/components/Editor'\nimport Environment from '@/v2/features/collection/components/Environment.vue'\nimport Overview from '@/v2/features/collection/components/Overview.vue'\nimport Servers from '@/v2/features/collection/components/Servers.vue'\nimport Settings from '@/v2/features/collection/components/Settings.vue'\nimport DocumentCollection from '@/v2/features/collection/DocumentCollection.vue'\nimport OperationCollection from '@/v2/features/collection/OperationCollection.vue'\nimport WorkspaceCollection from '@/v2/features/collection/WorkspaceCollection.vue'\nimport { Operation } from '@/v2/features/operation'\nimport { workspaceStorage } from '@/v2/helpers/storage'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\n/** These props are provided at the route level */\nexport type RouteProps = {\n /** The slug of the currently selected document in the workspace */\n documentSlug: string\n /** The currently active document */\n document: WorkspaceDocument | null\n /** The workspace event bus */\n eventBus: WorkspaceEventBus\n /** The layout of the client */\n layout: ClientLayout\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path?: string\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method?: HttpMethod\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName?: string\n /** The currently active environment */\n environment: XScalarEnvironment\n /** The workspace store */\n workspaceStore: WorkspaceStore\n /** The currently active workspace */\n activeWorkspace: { id: string; label: string }\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Custom themes available to the team */\n customThemes?: Theme[]\n /** The currently selected theme styles string */\n currentTheme?: string\n /** Whether the current color mode is dark */\n isDarkMode?: boolean\n /**\n * Fetches the full document from registry by meta. When provided, registry meta takes priority\n * over x-scalar-original-source-url when syncing. Returns the document as a plain object.\n */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /** Whether telemetry is enabled */\n telemetry?: boolean\n /** Updates the telemetry enabled state */\n onUpdateTelemetry?: (value: boolean) => void\n}\n\n/** When in the collections pages */\nexport type CollectionProps = RouteProps &\n (\n | {\n collectionType: 'document' | 'operation'\n document: WorkspaceDocument\n }\n | {\n collectionType: 'workspace'\n document: null\n }\n )\n\nexport type ScalarClientAppRouteParams =\n | 'namespace'\n | 'workspaceSlug'\n | 'documentSlug'\n | 'pathEncoded'\n | 'method'\n | 'exampleName'\n\n/** Routes for the API client app and web, the same as modal + workspace routes */\nexport const ROUTES = [\n {\n path: '/@:namespace/:workspaceSlug',\n children: [\n {\n path: 'document/:documentSlug',\n children: [\n // Example page\n {\n path: 'path/:pathEncoded/method/:method',\n children: [\n {\n name: 'example',\n path: 'example/:exampleName',\n component: Operation,\n },\n {\n name: 'operation',\n path: '',\n component: OperationCollection,\n redirect: {\n name: 'operation.overview',\n },\n children: [\n {\n name: 'operation.overview',\n path: 'overview',\n component: Overview,\n },\n {\n name: 'operation.servers',\n path: 'servers',\n component: Servers,\n },\n {\n name: 'operation.authentication',\n path: 'authentication',\n component: Authentication,\n },\n {\n name: 'operation.editor',\n path: 'editor',\n component: Editor,\n },\n ],\n },\n ],\n },\n // Document Page\n {\n name: 'document',\n path: '',\n component: DocumentCollection,\n children: [\n // Redirect to overview\n {\n name: 'document.redirect',\n path: '',\n redirect: {\n name: 'document.overview',\n },\n },\n // Document overview\n {\n name: 'document.overview',\n path: 'overview',\n component: Overview,\n },\n // Document servers\n {\n name: 'document.servers',\n path: 'servers',\n component: Servers,\n },\n // Document environment\n {\n name: 'document.environment',\n path: 'environment',\n component: Environment,\n },\n // Document authentication\n {\n name: 'document.authentication',\n path: 'authentication',\n component: Authentication,\n },\n // Document cookies\n {\n name: 'document.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Document settings\n {\n name: 'document.settings',\n path: 'settings',\n component: Settings,\n },\n // Document scripts (pre-request / post-response)\n {\n name: 'document.scripts',\n path: 'scripts',\n component: () => import('@/v2/features/collection/components/Scripts.vue'),\n },\n ],\n },\n ],\n },\n // Workspace page\n {\n name: 'workspace',\n path: '',\n component: WorkspaceCollection,\n children: [\n // Workspace environment\n {\n name: 'workspace.environment',\n path: 'environment',\n component: Environment,\n },\n // Workspace cookies\n {\n name: 'workspace.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Workspace settings\n {\n name: 'workspace.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n {\n path: '/:pathMatch(.*)*',\n redirect: () => {\n const DEFAULT_PATH = '/@local/default/document/drafts/overview'\n const lastPath = workspaceStorage.getLastPath() ?? DEFAULT_PATH\n\n // Set the default path to the last path so we don't go to an inifite loop if the last path is invalid\n workspaceStorage.setCurrentPath(DEFAULT_PATH)\n\n const url = new URL(lastPath, 'http://example.com')\n\n const queryParameters = new URLSearchParams(window.location.search)\n\n //Merge the query parameters with the last path\n const mergedSearchParams = mergeSearchParams(url.searchParams, queryParameters)\n\n // Preserve all query paramters\n return `${url.pathname}?${mergedSearchParams.toString()}`\n },\n },\n] satisfies RouteRecordRaw[]\n"],"mappings":";;;;;;;;;;;;;;;AAwFA,IAAa,SAAS,CACpB;CACE,MAAM;CACN,UAAU,CACR;EACE,MAAM;EACN,UAAU,CAER;GACE,MAAM;GACN,UAAU,CACR;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ,EACD;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACX,UAAU,EACR,MAAM,sBACP;IACD,UAAU;KACR;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACF;IACF,CACF;GACF,EAED;GACE,MAAM;GACN,MAAM;GACN,WAAW;GACX,UAAU;IAER;KACE,MAAM;KACN,MAAM;KACN,UAAU,EACR,MAAM,qBACP;KACF;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,iBAAiB,OAAO;KACzB;IACF;GACF,CACF;EACF,EAED;EACE,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU;GAER;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GACF;EACF,CACF;CACF,EACD;CACE,MAAM;CACN,gBAAgB;EACd,MAAM,eAAe;EACrB,MAAM,WAAW,iBAAiB,aAAa,IAAI;AAGnD,mBAAiB,eAAe,aAAa;EAE7C,MAAM,MAAM,IAAI,IAAI,UAAU,qBAAqB;EAEnD,MAAM,kBAAkB,IAAI,gBAAgB,OAAO,SAAS,OAAO;EAGnE,MAAM,qBAAqB,kBAAkB,IAAI,cAAc,gBAAgB;AAG/E,SAAO,GAAG,IAAI,SAAS,GAAG,mBAAmB,UAAU;;CAE1D,CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WorkspaceDocument } from '@scalar/workspace-store/schemas';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
document: WorkspaceDocument | null;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
|
+
"update:extension": (payload: Record<string, unknown>) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
"onUpdate:extension"?: ((payload: Record<string, unknown>) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=DocumentScriptsEditors.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentScriptsEditors.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/collection/components/DocumentScriptsEditors.vue"],"names":[],"mappings":"AAoPA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAWxE,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACnC,CAAC;AAkXF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import _plugin_vue_export_helper_default from "../../../../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import DocumentScriptsEditors_vue_vue_type_script_setup_true_lang_default from "./DocumentScriptsEditors.vue.script.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region src/v2/features/collection/components/DocumentScriptsEditors.vue
|
|
5
|
+
var DocumentScriptsEditors_default = /* @__PURE__ */ _plugin_vue_export_helper_default(DocumentScriptsEditors_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-8c8fa790"]]);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { DocumentScriptsEditors_default as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=DocumentScriptsEditors.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentScriptsEditors.vue.js","names":[],"sources":["../../../../../src/v2/features/collection/components/DocumentScriptsEditors.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCheckCircle } from '@scalar/icons'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport * as monaco from 'monaco-editor'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n watch,\n} from 'vue'\n\nconst { document } = defineProps<{\n document: WorkspaceDocument | null\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:extension', payload: Record<string, unknown>): void\n}>()\n\ntype ScriptTab = 'pre' | 'post'\n\nconst activeTab = ref<ScriptTab>('pre')\nconst editorContainerRef = ref<HTMLElement | null>(null)\n\nconst editor = shallowRef<monaco.editor.IStandaloneCodeEditor | null>(null)\nconst preModel = shallowRef<monaco.editor.ITextModel | null>(null)\nconst postModel = shallowRef<monaco.editor.ITextModel | null>(null)\n\n/** Local content state so the indicator updates immediately on type, before document prop syncs */\nconst preHasContent = ref(false)\nconst postHasContent = ref(false)\nconst preValue = (): string => (document?.['x-pre-request'] as string) ?? ''\nconst postValue = (): string => (document?.['x-post-response'] as string) ?? ''\n\n/** Content indicators: true when the script has non-whitespace content */\nconst hasPreContent = computed(\n () => preHasContent.value || preValue().trim().length > 0,\n)\n\nconst hasPostContent = computed(\n () => postHasContent.value || postValue().trim().length > 0,\n)\n\n/**\n * Creates Monaco text models for pre-request and post-response scripts.\n * Each model maintains its own content, undo history, and cursor state.\n * Change listeners emit updates to sync content with the parent component.\n */\nconst createModels = () => {\n preModel.value = monaco.editor.createModel(preValue(), 'javascript')\n postModel.value = monaco.editor.createModel(postValue(), 'javascript')\n\n preHasContent.value = preValue().trim().length > 0\n postHasContent.value = postValue().trim().length > 0\n\n preModel.value.onDidChangeContent(() => {\n const newValue = preModel.value?.getValue() ?? ''\n preHasContent.value = newValue.trim().length > 0\n emit('update:extension', { 'x-pre-request': newValue })\n })\n\n postModel.value.onDidChangeContent(() => {\n const newValue = postModel.value?.getValue() ?? ''\n postHasContent.value = newValue.trim().length > 0\n emit('update:extension', { 'x-post-response': newValue })\n })\n}\n\n/**\n * Initializes the Monaco editor instance with both models.\n * The editor is created once and reused; tab switching swaps models instead of recreating the editor.\n */\nconst createEditor = () => {\n if (!editorContainerRef.value) {\n return\n }\n\n createModels()\n\n const initialModel = activeTab.value === 'pre' ? preModel : postModel\n editor.value = monaco.editor.create(editorContainerRef.value, {\n automaticLayout: true,\n minimap: { enabled: false },\n lineNumbers: 'on',\n scrollBeyondLastLine: false,\n folding: true,\n showFoldingControls: 'always',\n fontSize: 13,\n lineHeight: 20,\n fontFamily: \"'JetBrains Mono', monospace\",\n scrollbar: {\n useShadows: false,\n verticalScrollbarSize: 8,\n horizontalScrollbarSize: 8,\n },\n padding: { top: 12, bottom: 12 },\n renderLineHighlight: 'none',\n wordWrap: 'on',\n model: initialModel.value,\n })\n}\n\n/**\n * Switches the active tab by swapping the model on the existing editor.\n * This preserves each model's undo history, cursor position, and scroll state.\n */\nconst switchTo = (tab: ScriptTab) => {\n if (activeTab.value === tab || !editor.value) {\n return\n }\n activeTab.value = tab\n const model = tab === 'pre' ? preModel : postModel\n if (model.value) {\n editor.value.setModel(model.value)\n }\n}\n\n/** Cleans up Monaco resources when the component unmounts. */\nconst disposeAll = () => {\n preModel.value?.dispose()\n postModel.value?.dispose()\n editor.value?.dispose()\n editor.value = null\n preModel.value = null\n postModel.value = null\n}\n\nonMounted(() => {\n createEditor()\n})\n\nonBeforeUnmount(() => {\n disposeAll()\n})\n\nwatch(\n () => [document?.['x-pre-request'], document?.['x-post-response']] as const,\n ([nextPre, nextPost]) => {\n const preStr = (nextPre as string) ?? ''\n const postStr = (nextPost as string) ?? ''\n preHasContent.value = preStr.trim().length > 0\n postHasContent.value = postStr.trim().length > 0\n\n if (preModel.value && preModel.value.getValue() !== preStr) {\n preModel.value.setValue(preStr)\n }\n if (postModel.value && postModel.value.getValue() !== postStr) {\n postModel.value.setValue(postStr)\n }\n },\n { flush: 'post' },\n)\n</script>\n\n<template>\n <div class=\"document-scripts-editors flex flex-col gap-5\">\n <!-- Tabs with icons and content indicators -->\n <div\n aria-label=\"Script type\"\n class=\"document-scripts-editors__tabs flex shrink-0 gap-0.5 rounded-xl border border-[var(--scalar-border-color)] bg-[var(--scalar-background-2)] p-1\"\n role=\"tablist\">\n <button\n :aria-selected=\"activeTab === 'pre'\"\n class=\"flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium transition-all duration-150\"\n :class=\"\n activeTab === 'pre'\n ? 'text-c-1 bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]'\n : 'text-c-2 hover:text-c-1 hover:bg-[var(--scalar-background-3)]'\n \"\n role=\"tab\"\n type=\"button\"\n @click=\"switchTo('pre')\">\n <ScalarIconArrowRight\n aria-hidden=\"true\"\n class=\"size-4 shrink-0 opacity-80\" />\n <span class=\"truncate\">Pre-request</span>\n <span\n v-if=\"hasPreContent\"\n aria-hidden=\"true\"\n class=\"h-2 w-2 shrink-0 rounded-full bg-[var(--scalar-color-green)]\"\n title=\"Has content\" />\n </button>\n <button\n :aria-selected=\"activeTab === 'post'\"\n class=\"flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium transition-all duration-150\"\n :class=\"\n activeTab === 'post'\n ? 'text-c-1 bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]'\n : 'text-c-2 hover:text-c-1 hover:bg-[var(--scalar-background-3)]'\n \"\n role=\"tab\"\n type=\"button\"\n @click=\"switchTo('post')\">\n <ScalarIconCheckCircle\n aria-hidden=\"true\"\n class=\"size-4 shrink-0 opacity-80\" />\n <span class=\"truncate\">Post-response</span>\n <span\n v-if=\"hasPostContent\"\n aria-hidden=\"true\"\n class=\"h-2 w-2 shrink-0 rounded-full bg-[var(--scalar-color-green)]\"\n title=\"Has content\" />\n </button>\n </div>\n\n <!-- Description and editor card -->\n <div\n class=\"document-scripts-editors__card flex flex-col overflow-hidden rounded-xl border border-[var(--scalar-border-color)] bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]\">\n <div\n class=\"document-scripts-editors__card-header flex min-h-[4rem] shrink-0 items-center justify-between border-b border-[var(--scalar-border-color)] bg-[var(--scalar-background-2)] px-4 py-3\">\n <p class=\"text-c-2 text-sm leading-snug\">\n <template v-if=\"activeTab === 'pre'\">\n Runs before each request in this document. Use it to set variables,\n headers, or modify the request.\n </template>\n <template v-else>\n Runs after each response. Use it for tests, assertions, or saving\n data from the response.\n </template>\n </p>\n <span\n aria-hidden=\"true\"\n class=\"text-c-2 rounded bg-[var(--scalar-background-3)] px-2 py-1 font-mono text-xs\">\n JavaScript\n </span>\n </div>\n <div\n ref=\"editorContainerRef\"\n class=\"document-scripts-editors__container min-h-[300px] flex-1\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.document-scripts-editors__container {\n min-height: 300px;\n}\n</style>\n"],"mappings":""}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, onBeforeUnmount, onMounted, openBlock, ref, shallowRef, unref, watch } from "vue";
|
|
2
|
+
import { ScalarIconArrowRight, ScalarIconCheckCircle } from "@scalar/icons";
|
|
3
|
+
import * as monaco from "monaco-editor";
|
|
4
|
+
//#region src/v2/features/collection/components/DocumentScriptsEditors.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _hoisted_1 = { class: "document-scripts-editors flex flex-col gap-5" };
|
|
6
|
+
var _hoisted_2 = {
|
|
7
|
+
"aria-label": "Script type",
|
|
8
|
+
class: "document-scripts-editors__tabs flex shrink-0 gap-0.5 rounded-xl border border-[var(--scalar-border-color)] bg-[var(--scalar-background-2)] p-1",
|
|
9
|
+
role: "tablist"
|
|
10
|
+
};
|
|
11
|
+
var _hoisted_3 = ["aria-selected"];
|
|
12
|
+
var _hoisted_4 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
class: "h-2 w-2 shrink-0 rounded-full bg-[var(--scalar-color-green)]",
|
|
16
|
+
title: "Has content"
|
|
17
|
+
};
|
|
18
|
+
var _hoisted_5 = ["aria-selected"];
|
|
19
|
+
var _hoisted_6 = {
|
|
20
|
+
key: 0,
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
class: "h-2 w-2 shrink-0 rounded-full bg-[var(--scalar-color-green)]",
|
|
23
|
+
title: "Has content"
|
|
24
|
+
};
|
|
25
|
+
var _hoisted_7 = { class: "document-scripts-editors__card flex flex-col overflow-hidden rounded-xl border border-[var(--scalar-border-color)] bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]" };
|
|
26
|
+
var _hoisted_8 = { class: "document-scripts-editors__card-header flex min-h-[4rem] shrink-0 items-center justify-between border-b border-[var(--scalar-border-color)] bg-[var(--scalar-background-2)] px-4 py-3" };
|
|
27
|
+
var _hoisted_9 = { class: "text-c-2 text-sm leading-snug" };
|
|
28
|
+
var DocumentScriptsEditors_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
29
|
+
__name: "DocumentScriptsEditors",
|
|
30
|
+
props: { document: {} },
|
|
31
|
+
emits: ["update:extension"],
|
|
32
|
+
setup(__props, { emit: __emit }) {
|
|
33
|
+
const emit = __emit;
|
|
34
|
+
const activeTab = ref("pre");
|
|
35
|
+
const editorContainerRef = ref(null);
|
|
36
|
+
const editor = shallowRef(null);
|
|
37
|
+
const preModel = shallowRef(null);
|
|
38
|
+
const postModel = shallowRef(null);
|
|
39
|
+
/** Local content state so the indicator updates immediately on type, before document prop syncs */
|
|
40
|
+
const preHasContent = ref(false);
|
|
41
|
+
const postHasContent = ref(false);
|
|
42
|
+
const preValue = () => __props.document?.["x-pre-request"] ?? "";
|
|
43
|
+
const postValue = () => __props.document?.["x-post-response"] ?? "";
|
|
44
|
+
/** Content indicators: true when the script has non-whitespace content */
|
|
45
|
+
const hasPreContent = computed(() => preHasContent.value || preValue().trim().length > 0);
|
|
46
|
+
const hasPostContent = computed(() => postHasContent.value || postValue().trim().length > 0);
|
|
47
|
+
/**
|
|
48
|
+
* Creates Monaco text models for pre-request and post-response scripts.
|
|
49
|
+
* Each model maintains its own content, undo history, and cursor state.
|
|
50
|
+
* Change listeners emit updates to sync content with the parent component.
|
|
51
|
+
*/
|
|
52
|
+
const createModels = () => {
|
|
53
|
+
preModel.value = monaco.editor.createModel(preValue(), "javascript");
|
|
54
|
+
postModel.value = monaco.editor.createModel(postValue(), "javascript");
|
|
55
|
+
preHasContent.value = preValue().trim().length > 0;
|
|
56
|
+
postHasContent.value = postValue().trim().length > 0;
|
|
57
|
+
preModel.value.onDidChangeContent(() => {
|
|
58
|
+
const newValue = preModel.value?.getValue() ?? "";
|
|
59
|
+
preHasContent.value = newValue.trim().length > 0;
|
|
60
|
+
emit("update:extension", { "x-pre-request": newValue });
|
|
61
|
+
});
|
|
62
|
+
postModel.value.onDidChangeContent(() => {
|
|
63
|
+
const newValue = postModel.value?.getValue() ?? "";
|
|
64
|
+
postHasContent.value = newValue.trim().length > 0;
|
|
65
|
+
emit("update:extension", { "x-post-response": newValue });
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Initializes the Monaco editor instance with both models.
|
|
70
|
+
* The editor is created once and reused; tab switching swaps models instead of recreating the editor.
|
|
71
|
+
*/
|
|
72
|
+
const createEditor = () => {
|
|
73
|
+
if (!editorContainerRef.value) return;
|
|
74
|
+
createModels();
|
|
75
|
+
const initialModel = activeTab.value === "pre" ? preModel : postModel;
|
|
76
|
+
editor.value = monaco.editor.create(editorContainerRef.value, {
|
|
77
|
+
automaticLayout: true,
|
|
78
|
+
minimap: { enabled: false },
|
|
79
|
+
lineNumbers: "on",
|
|
80
|
+
scrollBeyondLastLine: false,
|
|
81
|
+
folding: true,
|
|
82
|
+
showFoldingControls: "always",
|
|
83
|
+
fontSize: 13,
|
|
84
|
+
lineHeight: 20,
|
|
85
|
+
fontFamily: "'JetBrains Mono', monospace",
|
|
86
|
+
scrollbar: {
|
|
87
|
+
useShadows: false,
|
|
88
|
+
verticalScrollbarSize: 8,
|
|
89
|
+
horizontalScrollbarSize: 8
|
|
90
|
+
},
|
|
91
|
+
padding: {
|
|
92
|
+
top: 12,
|
|
93
|
+
bottom: 12
|
|
94
|
+
},
|
|
95
|
+
renderLineHighlight: "none",
|
|
96
|
+
wordWrap: "on",
|
|
97
|
+
model: initialModel.value
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Switches the active tab by swapping the model on the existing editor.
|
|
102
|
+
* This preserves each model's undo history, cursor position, and scroll state.
|
|
103
|
+
*/
|
|
104
|
+
const switchTo = (tab) => {
|
|
105
|
+
if (activeTab.value === tab || !editor.value) return;
|
|
106
|
+
activeTab.value = tab;
|
|
107
|
+
const model = tab === "pre" ? preModel : postModel;
|
|
108
|
+
if (model.value) editor.value.setModel(model.value);
|
|
109
|
+
};
|
|
110
|
+
/** Cleans up Monaco resources when the component unmounts. */
|
|
111
|
+
const disposeAll = () => {
|
|
112
|
+
preModel.value?.dispose();
|
|
113
|
+
postModel.value?.dispose();
|
|
114
|
+
editor.value?.dispose();
|
|
115
|
+
editor.value = null;
|
|
116
|
+
preModel.value = null;
|
|
117
|
+
postModel.value = null;
|
|
118
|
+
};
|
|
119
|
+
onMounted(() => {
|
|
120
|
+
createEditor();
|
|
121
|
+
});
|
|
122
|
+
onBeforeUnmount(() => {
|
|
123
|
+
disposeAll();
|
|
124
|
+
});
|
|
125
|
+
watch(() => [__props.document?.["x-pre-request"], __props.document?.["x-post-response"]], ([nextPre, nextPost]) => {
|
|
126
|
+
const preStr = nextPre ?? "";
|
|
127
|
+
const postStr = nextPost ?? "";
|
|
128
|
+
preHasContent.value = preStr.trim().length > 0;
|
|
129
|
+
postHasContent.value = postStr.trim().length > 0;
|
|
130
|
+
if (preModel.value && preModel.value.getValue() !== preStr) preModel.value.setValue(preStr);
|
|
131
|
+
if (postModel.value && postModel.value.getValue() !== postStr) postModel.value.setValue(postStr);
|
|
132
|
+
}, { flush: "post" });
|
|
133
|
+
return (_ctx, _cache) => {
|
|
134
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("button", {
|
|
135
|
+
"aria-selected": activeTab.value === "pre",
|
|
136
|
+
class: normalizeClass(["flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium transition-all duration-150", activeTab.value === "pre" ? "text-c-1 bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]" : "text-c-2 hover:text-c-1 hover:bg-[var(--scalar-background-3)]"]),
|
|
137
|
+
role: "tab",
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: _cache[0] || (_cache[0] = ($event) => switchTo("pre"))
|
|
140
|
+
}, [
|
|
141
|
+
createVNode(unref(ScalarIconArrowRight), {
|
|
142
|
+
"aria-hidden": "true",
|
|
143
|
+
class: "size-4 shrink-0 opacity-80"
|
|
144
|
+
}),
|
|
145
|
+
_cache[2] || (_cache[2] = createElementVNode("span", { class: "truncate" }, "Pre-request", -1)),
|
|
146
|
+
hasPreContent.value ? (openBlock(), createElementBlock("span", _hoisted_4)) : createCommentVNode("", true)
|
|
147
|
+
], 10, _hoisted_3), createElementVNode("button", {
|
|
148
|
+
"aria-selected": activeTab.value === "post",
|
|
149
|
+
class: normalizeClass(["flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium transition-all duration-150", activeTab.value === "post" ? "text-c-1 bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]" : "text-c-2 hover:text-c-1 hover:bg-[var(--scalar-background-3)]"]),
|
|
150
|
+
role: "tab",
|
|
151
|
+
type: "button",
|
|
152
|
+
onClick: _cache[1] || (_cache[1] = ($event) => switchTo("post"))
|
|
153
|
+
}, [
|
|
154
|
+
createVNode(unref(ScalarIconCheckCircle), {
|
|
155
|
+
"aria-hidden": "true",
|
|
156
|
+
class: "size-4 shrink-0 opacity-80"
|
|
157
|
+
}),
|
|
158
|
+
_cache[3] || (_cache[3] = createElementVNode("span", { class: "truncate" }, "Post-response", -1)),
|
|
159
|
+
hasPostContent.value ? (openBlock(), createElementBlock("span", _hoisted_6)) : createCommentVNode("", true)
|
|
160
|
+
], 10, _hoisted_5)]), createElementVNode("div", _hoisted_7, [createElementVNode("div", _hoisted_8, [createElementVNode("p", _hoisted_9, [activeTab.value === "pre" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" Runs before each request in this document. Use it to set variables, headers, or modify the request. ")], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" Runs after each response. Use it for tests, assertions, or saving data from the response. ")], 64))]), _cache[4] || (_cache[4] = createElementVNode("span", {
|
|
161
|
+
"aria-hidden": "true",
|
|
162
|
+
class: "text-c-2 rounded bg-[var(--scalar-background-3)] px-2 py-1 font-mono text-xs"
|
|
163
|
+
}, " JavaScript ", -1))]), createElementVNode("div", {
|
|
164
|
+
ref_key: "editorContainerRef",
|
|
165
|
+
ref: editorContainerRef,
|
|
166
|
+
class: "document-scripts-editors__container min-h-[300px] flex-1"
|
|
167
|
+
}, null, 512)])]);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
//#endregion
|
|
172
|
+
export { DocumentScriptsEditors_vue_vue_type_script_setup_true_lang_default as default };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=DocumentScriptsEditors.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentScriptsEditors.vue.script.js","names":[],"sources":["../../../../../src/v2/features/collection/components/DocumentScriptsEditors.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCheckCircle } from '@scalar/icons'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport * as monaco from 'monaco-editor'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n ref,\n shallowRef,\n watch,\n} from 'vue'\n\nconst { document } = defineProps<{\n document: WorkspaceDocument | null\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:extension', payload: Record<string, unknown>): void\n}>()\n\ntype ScriptTab = 'pre' | 'post'\n\nconst activeTab = ref<ScriptTab>('pre')\nconst editorContainerRef = ref<HTMLElement | null>(null)\n\nconst editor = shallowRef<monaco.editor.IStandaloneCodeEditor | null>(null)\nconst preModel = shallowRef<monaco.editor.ITextModel | null>(null)\nconst postModel = shallowRef<monaco.editor.ITextModel | null>(null)\n\n/** Local content state so the indicator updates immediately on type, before document prop syncs */\nconst preHasContent = ref(false)\nconst postHasContent = ref(false)\nconst preValue = (): string => (document?.['x-pre-request'] as string) ?? ''\nconst postValue = (): string => (document?.['x-post-response'] as string) ?? ''\n\n/** Content indicators: true when the script has non-whitespace content */\nconst hasPreContent = computed(\n () => preHasContent.value || preValue().trim().length > 0,\n)\n\nconst hasPostContent = computed(\n () => postHasContent.value || postValue().trim().length > 0,\n)\n\n/**\n * Creates Monaco text models for pre-request and post-response scripts.\n * Each model maintains its own content, undo history, and cursor state.\n * Change listeners emit updates to sync content with the parent component.\n */\nconst createModels = () => {\n preModel.value = monaco.editor.createModel(preValue(), 'javascript')\n postModel.value = monaco.editor.createModel(postValue(), 'javascript')\n\n preHasContent.value = preValue().trim().length > 0\n postHasContent.value = postValue().trim().length > 0\n\n preModel.value.onDidChangeContent(() => {\n const newValue = preModel.value?.getValue() ?? ''\n preHasContent.value = newValue.trim().length > 0\n emit('update:extension', { 'x-pre-request': newValue })\n })\n\n postModel.value.onDidChangeContent(() => {\n const newValue = postModel.value?.getValue() ?? ''\n postHasContent.value = newValue.trim().length > 0\n emit('update:extension', { 'x-post-response': newValue })\n })\n}\n\n/**\n * Initializes the Monaco editor instance with both models.\n * The editor is created once and reused; tab switching swaps models instead of recreating the editor.\n */\nconst createEditor = () => {\n if (!editorContainerRef.value) {\n return\n }\n\n createModels()\n\n const initialModel = activeTab.value === 'pre' ? preModel : postModel\n editor.value = monaco.editor.create(editorContainerRef.value, {\n automaticLayout: true,\n minimap: { enabled: false },\n lineNumbers: 'on',\n scrollBeyondLastLine: false,\n folding: true,\n showFoldingControls: 'always',\n fontSize: 13,\n lineHeight: 20,\n fontFamily: \"'JetBrains Mono', monospace\",\n scrollbar: {\n useShadows: false,\n verticalScrollbarSize: 8,\n horizontalScrollbarSize: 8,\n },\n padding: { top: 12, bottom: 12 },\n renderLineHighlight: 'none',\n wordWrap: 'on',\n model: initialModel.value,\n })\n}\n\n/**\n * Switches the active tab by swapping the model on the existing editor.\n * This preserves each model's undo history, cursor position, and scroll state.\n */\nconst switchTo = (tab: ScriptTab) => {\n if (activeTab.value === tab || !editor.value) {\n return\n }\n activeTab.value = tab\n const model = tab === 'pre' ? preModel : postModel\n if (model.value) {\n editor.value.setModel(model.value)\n }\n}\n\n/** Cleans up Monaco resources when the component unmounts. */\nconst disposeAll = () => {\n preModel.value?.dispose()\n postModel.value?.dispose()\n editor.value?.dispose()\n editor.value = null\n preModel.value = null\n postModel.value = null\n}\n\nonMounted(() => {\n createEditor()\n})\n\nonBeforeUnmount(() => {\n disposeAll()\n})\n\nwatch(\n () => [document?.['x-pre-request'], document?.['x-post-response']] as const,\n ([nextPre, nextPost]) => {\n const preStr = (nextPre as string) ?? ''\n const postStr = (nextPost as string) ?? ''\n preHasContent.value = preStr.trim().length > 0\n postHasContent.value = postStr.trim().length > 0\n\n if (preModel.value && preModel.value.getValue() !== preStr) {\n preModel.value.setValue(preStr)\n }\n if (postModel.value && postModel.value.getValue() !== postStr) {\n postModel.value.setValue(postStr)\n }\n },\n { flush: 'post' },\n)\n</script>\n\n<template>\n <div class=\"document-scripts-editors flex flex-col gap-5\">\n <!-- Tabs with icons and content indicators -->\n <div\n aria-label=\"Script type\"\n class=\"document-scripts-editors__tabs flex shrink-0 gap-0.5 rounded-xl border border-[var(--scalar-border-color)] bg-[var(--scalar-background-2)] p-1\"\n role=\"tablist\">\n <button\n :aria-selected=\"activeTab === 'pre'\"\n class=\"flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium transition-all duration-150\"\n :class=\"\n activeTab === 'pre'\n ? 'text-c-1 bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]'\n : 'text-c-2 hover:text-c-1 hover:bg-[var(--scalar-background-3)]'\n \"\n role=\"tab\"\n type=\"button\"\n @click=\"switchTo('pre')\">\n <ScalarIconArrowRight\n aria-hidden=\"true\"\n class=\"size-4 shrink-0 opacity-80\" />\n <span class=\"truncate\">Pre-request</span>\n <span\n v-if=\"hasPreContent\"\n aria-hidden=\"true\"\n class=\"h-2 w-2 shrink-0 rounded-full bg-[var(--scalar-color-green)]\"\n title=\"Has content\" />\n </button>\n <button\n :aria-selected=\"activeTab === 'post'\"\n class=\"flex min-w-0 flex-1 items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium transition-all duration-150\"\n :class=\"\n activeTab === 'post'\n ? 'text-c-1 bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]'\n : 'text-c-2 hover:text-c-1 hover:bg-[var(--scalar-background-3)]'\n \"\n role=\"tab\"\n type=\"button\"\n @click=\"switchTo('post')\">\n <ScalarIconCheckCircle\n aria-hidden=\"true\"\n class=\"size-4 shrink-0 opacity-80\" />\n <span class=\"truncate\">Post-response</span>\n <span\n v-if=\"hasPostContent\"\n aria-hidden=\"true\"\n class=\"h-2 w-2 shrink-0 rounded-full bg-[var(--scalar-color-green)]\"\n title=\"Has content\" />\n </button>\n </div>\n\n <!-- Description and editor card -->\n <div\n class=\"document-scripts-editors__card flex flex-col overflow-hidden rounded-xl border border-[var(--scalar-border-color)] bg-[var(--scalar-background-1)] shadow-[var(--scalar-shadow-1)]\">\n <div\n class=\"document-scripts-editors__card-header flex min-h-[4rem] shrink-0 items-center justify-between border-b border-[var(--scalar-border-color)] bg-[var(--scalar-background-2)] px-4 py-3\">\n <p class=\"text-c-2 text-sm leading-snug\">\n <template v-if=\"activeTab === 'pre'\">\n Runs before each request in this document. Use it to set variables,\n headers, or modify the request.\n </template>\n <template v-else>\n Runs after each response. Use it for tests, assertions, or saving\n data from the response.\n </template>\n </p>\n <span\n aria-hidden=\"true\"\n class=\"text-c-2 rounded bg-[var(--scalar-background-3)] px-2 py-1 font-mono text-xs\">\n JavaScript\n </span>\n </div>\n <div\n ref=\"editorContainerRef\"\n class=\"document-scripts-editors__container min-h-[300px] flex-1\" />\n </div>\n </div>\n</template>\n\n<style scoped>\n.document-scripts-editors__container {\n min-height: 300px;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBA,MAAM,OAAO;EAMb,MAAM,YAAY,IAAe,MAAK;EACtC,MAAM,qBAAqB,IAAwB,KAAI;EAEvD,MAAM,SAAS,WAAuD,KAAI;EAC1E,MAAM,WAAW,WAA4C,KAAI;EACjE,MAAM,YAAY,WAA4C,KAAI;;EAGlE,MAAM,gBAAgB,IAAI,MAAK;EAC/B,MAAM,iBAAiB,IAAI,MAAK;EAChC,MAAM,iBAA0B,QAAA,WAAW,oBAA+B;EAC1E,MAAM,kBAA2B,QAAA,WAAW,sBAAiC;;EAG7E,MAAM,gBAAgB,eACd,cAAc,SAAS,UAAU,CAAC,MAAM,CAAC,SAAS,EAC1D;EAEA,MAAM,iBAAiB,eACf,eAAe,SAAS,WAAW,CAAC,MAAM,CAAC,SAAS,EAC5D;;;;;;EAOA,MAAM,qBAAqB;AACzB,YAAS,QAAQ,OAAO,OAAO,YAAY,UAAU,EAAE,aAAY;AACnE,aAAU,QAAQ,OAAO,OAAO,YAAY,WAAW,EAAE,aAAY;AAErE,iBAAc,QAAQ,UAAU,CAAC,MAAM,CAAC,SAAS;AACjD,kBAAe,QAAQ,WAAW,CAAC,MAAM,CAAC,SAAS;AAEnD,YAAS,MAAM,yBAAyB;IACtC,MAAM,WAAW,SAAS,OAAO,UAAU,IAAI;AAC/C,kBAAc,QAAQ,SAAS,MAAM,CAAC,SAAS;AAC/C,SAAK,oBAAoB,EAAE,iBAAiB,UAAU,CAAA;KACvD;AAED,aAAU,MAAM,yBAAyB;IACvC,MAAM,WAAW,UAAU,OAAO,UAAU,IAAI;AAChD,mBAAe,QAAQ,SAAS,MAAM,CAAC,SAAS;AAChD,SAA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AAA,EAAA,CAAA,EAAA,OAAA,OAAA,OAAA,KAEF,mBAIO,QAAA;IAHL,eAAY;IACZ,OAAM;MAA+E,gBAEvF,GAAA,EAAA,CAAA,EAEF,mBAEqE,OAAA;aAD/D;IAAJ,KAAI;IACJ,OAAM"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<(import("../../../../v2/features/app/helpers/routes.js").RouteProps & {
|
|
2
|
+
collectionType: "document" | "operation";
|
|
3
|
+
document: import("@scalar/workspace-store/schemas").WorkspaceDocument;
|
|
4
|
+
}) | (import("../../../../v2/features/app/helpers/routes.js").RouteProps & {
|
|
5
|
+
collectionType: "workspace";
|
|
6
|
+
document: null;
|
|
7
|
+
}), {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<(import("../../../../v2/features/app/helpers/routes.js").RouteProps & {
|
|
8
|
+
collectionType: "document" | "operation";
|
|
9
|
+
document: import("@scalar/workspace-store/schemas").WorkspaceDocument;
|
|
10
|
+
}) | (import("../../../../v2/features/app/helpers/routes.js").RouteProps & {
|
|
11
|
+
collectionType: "workspace";
|
|
12
|
+
document: null;
|
|
13
|
+
})> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=Scripts.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scripts.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/collection/components/Scripts.vue"],"names":[],"mappings":"AA+FA,QAAA,MAAM,YAAY;;;;;;;;;;;;kGAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Scripts_vue_vue_type_script_setup_true_lang_default from "./Scripts.vue.script.js";
|
|
2
|
+
//#region src/v2/features/collection/components/Scripts.vue
|
|
3
|
+
var Scripts_default = Scripts_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Scripts_default as default };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=Scripts.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scripts.vue.js","names":[],"sources":["../../../../../src/v2/features/collection/components/Scripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { CollectionProps } from '@/v2/features/app/helpers/routes'\nimport DocumentScriptsEditors from '@/v2/features/collection/components/DocumentScriptsEditors.vue'\nimport Section from '@/v2/features/settings/components/Section.vue'\n\nconst { document, eventBus, collectionType } = defineProps<CollectionProps>()\n\nconst handleUpdateExtension = (payload: Record<string, unknown>) => {\n eventBus.emit('document:update:extension', payload)\n}\n</script>\n\n<template>\n <Section v-if=\"collectionType === 'document'\">\n <template #title>Pre-request & Post-response Scripts</template>\n <template #description>\n Scripts at the document level run for every request in this document.\n Operation-level scripts (in the request editor) run in addition to these.\n </template>\n <DocumentScriptsEditors\n :document=\"document\"\n @update:extension=\"handleUpdateExtension\" />\n </Section>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Section_default from "../../settings/components/Section.vue.js";
|
|
2
|
+
import DocumentScriptsEditors_default from "./DocumentScriptsEditors.vue.js";
|
|
3
|
+
import { createBlock, createCommentVNode, createTextVNode, createVNode, defineComponent, openBlock, withCtx } from "vue";
|
|
4
|
+
//#region src/v2/features/collection/components/Scripts.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var Scripts_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
|
+
__name: "Scripts",
|
|
7
|
+
props: {
|
|
8
|
+
documentSlug: {},
|
|
9
|
+
document: {},
|
|
10
|
+
eventBus: {},
|
|
11
|
+
layout: {},
|
|
12
|
+
path: {},
|
|
13
|
+
method: {},
|
|
14
|
+
exampleName: {},
|
|
15
|
+
environment: {},
|
|
16
|
+
workspaceStore: {},
|
|
17
|
+
activeWorkspace: {},
|
|
18
|
+
plugins: {},
|
|
19
|
+
customThemes: {},
|
|
20
|
+
currentTheme: {},
|
|
21
|
+
isDarkMode: { type: Boolean },
|
|
22
|
+
fetchRegistryDocument: { type: Function },
|
|
23
|
+
telemetry: { type: Boolean },
|
|
24
|
+
onUpdateTelemetry: { type: Function },
|
|
25
|
+
collectionType: {}
|
|
26
|
+
},
|
|
27
|
+
setup(__props) {
|
|
28
|
+
const handleUpdateExtension = (payload) => {
|
|
29
|
+
__props.eventBus.emit("document:update:extension", payload);
|
|
30
|
+
};
|
|
31
|
+
return (_ctx, _cache) => {
|
|
32
|
+
return __props.collectionType === "document" ? (openBlock(), createBlock(Section_default, { key: 0 }, {
|
|
33
|
+
title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Pre-request & Post-response Scripts", -1)])]),
|
|
34
|
+
description: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode(" Scripts at the document level run for every request in this document. Operation-level scripts (in the request editor) run in addition to these. ", -1)])]),
|
|
35
|
+
default: withCtx(() => [createVNode(DocumentScriptsEditors_default, {
|
|
36
|
+
document: __props.document,
|
|
37
|
+
"onUpdate:extension": handleUpdateExtension
|
|
38
|
+
}, null, 8, ["document"])]),
|
|
39
|
+
_: 1
|
|
40
|
+
})) : createCommentVNode("", true);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
export { Scripts_vue_vue_type_script_setup_true_lang_default as default };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=Scripts.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scripts.vue.script.js","names":[],"sources":["../../../../../src/v2/features/collection/components/Scripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { CollectionProps } from '@/v2/features/app/helpers/routes'\nimport DocumentScriptsEditors from '@/v2/features/collection/components/DocumentScriptsEditors.vue'\nimport Section from '@/v2/features/settings/components/Section.vue'\n\nconst { document, eventBus, collectionType } = defineProps<CollectionProps>()\n\nconst handleUpdateExtension = (payload: Record<string, unknown>) => {\n eventBus.emit('document:update:extension', payload)\n}\n</script>\n\n<template>\n <Section v-if=\"collectionType === 'document'\">\n <template #title>Pre-request & Post-response Scripts</template>\n <template #description>\n Scripts at the document level run for every request in this document.\n Operation-level scripts (in the request editor) run in addition to these.\n </template>\n <DocumentScriptsEditors\n :document=\"document\"\n @update:extension=\"handleUpdateExtension\" />\n </Section>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,MAAM,yBAAyB,YAAqC;AAClE,WAAA,SAAS,KAAK,6BAA6B,QAAO;;;UAKnC,QAAA,mBAAc,cAAA,WAAA,EAA7B,YASU,iBAAA,EAAA,KAAA,GAAA,EAAA;IARG,OAAK,cAAwC,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAvC,uCAAuC,GAAA,CAAA,EAAA,CAAA;IAC7C,aAAW,cAGtB,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAHuB,qJAGvB,GAAA,CAAA,EAAA,CAAA;2BAG8C,CAF9C,YAE8C,gCAAA;KAD3C,UAAU,QAAA;KACV,sBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/collection/components/Tabs.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Tabs.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/collection/components/Tabs.vue"],"names":[],"mappings":"AA+DA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAEvE,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAA;CACxC,CAAC;AAmHF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.vue.js","names":[],"sources":["../../../../../src/v2/features/collection/components/Tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { capitalize, computed } from 'vue'\nimport { RouterLink } from 'vue-router'\n\nimport type { CollectionProps } from '@/v2/features/app/helpers/routes'\n\nconst { type } = defineProps<{\n type: CollectionProps['collectionType']\n}>()\n\n/** Different routes for workspace vs document */\nconst routes = computed(() => {\n if (type === 'workspace') {\n return ['environment', 'cookies', 'settings']\n }\n\n if (type === 'operation') {\n return ['overview', 'servers', 'authentication', 'editor']\n }\n\n return [\n 'overview',\n 'servers',\n 'authentication',\n 'environment',\n 'cookies',\n 'settings',\n ]\n})\n</script>\n\n<template>\n <div class=\"flex w-full gap-2 border-b pl-1.5 md:ml-1.5 md:pl-0\">\n <RouterLink\n v-for=\"route in routes\"\n :key=\"route\"\n v-slot=\"{ isActive, href, navigate }\"\n custom\n :to=\"{ name: `${type}.${route}` }\">\n <a\n class=\"-ml-2 flex h-10 cursor-pointer items-center px-2 text-center text-sm font-medium whitespace-nowrap no-underline -outline-offset-1 has-[:focus-visible]:outline\"\n :href=\"href\"\n @click=\"navigate\">\n <span\n class=\"flex-center hover:text-c-1 h-full border-b\"\n :class=\"\n isActive\n ? 'text-c-1 border-c-1'\n : 'text-c-2 hover:text-c-1 border-transparent'\n \">\n {{ capitalize(route) }}\n </span>\n </a>\n </RouterLink>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Tabs.vue.js","names":[],"sources":["../../../../../src/v2/features/collection/components/Tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { capitalize, computed } from 'vue'\nimport { RouterLink } from 'vue-router'\n\nimport type { CollectionProps } from '@/v2/features/app/helpers/routes'\n\nconst { type } = defineProps<{\n type: CollectionProps['collectionType']\n}>()\n\n/** Different routes for workspace vs document */\nconst routes = computed(() => {\n if (type === 'workspace') {\n return ['environment', 'cookies', 'settings']\n }\n\n if (type === 'operation') {\n return ['overview', 'servers', 'authentication', 'editor']\n }\n\n return [\n 'overview',\n 'servers',\n 'authentication',\n 'environment',\n 'cookies',\n 'settings',\n 'scripts',\n ]\n})\n</script>\n\n<template>\n <div class=\"flex w-full gap-2 border-b pl-1.5 md:ml-1.5 md:pl-0\">\n <RouterLink\n v-for=\"route in routes\"\n :key=\"route\"\n v-slot=\"{ isActive, href, navigate }\"\n custom\n :to=\"{ name: `${type}.${route}` }\">\n <a\n class=\"-ml-2 flex h-10 cursor-pointer items-center px-2 text-center text-sm font-medium whitespace-nowrap no-underline -outline-offset-1 has-[:focus-visible]:outline\"\n :href=\"href\"\n @click=\"navigate\">\n <span\n class=\"flex-center hover:text-c-1 h-full border-b\"\n :class=\"\n isActive\n ? 'text-c-1 border-c-1'\n : 'text-c-2 hover:text-c-1 border-transparent'\n \">\n {{ capitalize(route) }}\n </span>\n </a>\n </RouterLink>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.vue.script.js","names":[],"sources":["../../../../../src/v2/features/collection/components/Tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { capitalize, computed } from 'vue'\nimport { RouterLink } from 'vue-router'\n\nimport type { CollectionProps } from '@/v2/features/app/helpers/routes'\n\nconst { type } = defineProps<{\n type: CollectionProps['collectionType']\n}>()\n\n/** Different routes for workspace vs document */\nconst routes = computed(() => {\n if (type === 'workspace') {\n return ['environment', 'cookies', 'settings']\n }\n\n if (type === 'operation') {\n return ['overview', 'servers', 'authentication', 'editor']\n }\n\n return [\n 'overview',\n 'servers',\n 'authentication',\n 'environment',\n 'cookies',\n 'settings',\n ]\n})\n</script>\n\n<template>\n <div class=\"flex w-full gap-2 border-b pl-1.5 md:ml-1.5 md:pl-0\">\n <RouterLink\n v-for=\"route in routes\"\n :key=\"route\"\n v-slot=\"{ isActive, href, navigate }\"\n custom\n :to=\"{ name: `${type}.${route}` }\">\n <a\n class=\"-ml-2 flex h-10 cursor-pointer items-center px-2 text-center text-sm font-medium whitespace-nowrap no-underline -outline-offset-1 has-[:focus-visible]:outline\"\n :href=\"href\"\n @click=\"navigate\">\n <span\n class=\"flex-center hover:text-c-1 h-full border-b\"\n :class=\"\n isActive\n ? 'text-c-1 border-c-1'\n : 'text-c-2 hover:text-c-1 border-transparent'\n \">\n {{ capitalize(route) }}\n </span>\n </a>\n </RouterLink>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;EAWA,MAAM,SAAS,eAAe;AAC5B,OAAI,QAAA,SAAS,YACX,QAAO;IAAC;IAAe;IAAW;IAAU;AAG9C,OAAI,QAAA,SAAS,YACX,QAAO;IAAC;IAAY;IAAW;IAAkB;IAAQ;AAG3D,UAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACF;IACD;;uBAIC,mBAsBM,OAtBN,YAsBM,EAAA,UAAA,KAAA,EArBJ,mBAoBa,UAAA,MAAA,WAnBK,OAAA,QAAT,UAAK;wBADd,YAoBa,MAAA,WAAA,EAAA;KAlBV,KAAK;KAEN,QAAA;KACC,IAAE,EAAA,MAAA,GAAa,QAAA,KAAI,GAAI,SAAK;;uBAczB,EAhBM,UAAU,MAAM,eAAQ,CAGlC,mBAaI,KAAA;MAZF,OAAM;MACC;MACN,SAAO;SACR,mBAQO,QAAA,EAPL,OAAK,eAAA,CAAC,8CACe,WAAA,wBAAA,6CAAA,CAAA,EAAA,EAAA,gBAKlB,WAAW,MAAK,CAAA,EAAA,EAAA,CAAA,EAAA,GAAA,WAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Tabs.vue.script.js","names":[],"sources":["../../../../../src/v2/features/collection/components/Tabs.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { capitalize, computed } from 'vue'\nimport { RouterLink } from 'vue-router'\n\nimport type { CollectionProps } from '@/v2/features/app/helpers/routes'\n\nconst { type } = defineProps<{\n type: CollectionProps['collectionType']\n}>()\n\n/** Different routes for workspace vs document */\nconst routes = computed(() => {\n if (type === 'workspace') {\n return ['environment', 'cookies', 'settings']\n }\n\n if (type === 'operation') {\n return ['overview', 'servers', 'authentication', 'editor']\n }\n\n return [\n 'overview',\n 'servers',\n 'authentication',\n 'environment',\n 'cookies',\n 'settings',\n 'scripts',\n ]\n})\n</script>\n\n<template>\n <div class=\"flex w-full gap-2 border-b pl-1.5 md:ml-1.5 md:pl-0\">\n <RouterLink\n v-for=\"route in routes\"\n :key=\"route\"\n v-slot=\"{ isActive, href, navigate }\"\n custom\n :to=\"{ name: `${type}.${route}` }\">\n <a\n class=\"-ml-2 flex h-10 cursor-pointer items-center px-2 text-center text-sm font-medium whitespace-nowrap no-underline -outline-offset-1 has-[:focus-visible]:outline\"\n :href=\"href\"\n @click=\"navigate\">\n <span\n class=\"flex-center hover:text-c-1 h-full border-b\"\n :class=\"\n isActive\n ? 'text-c-1 border-c-1'\n : 'text-c-2 hover:text-c-1 border-transparent'\n \">\n {{ capitalize(route) }}\n </span>\n </a>\n </RouterLink>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;EAWA,MAAM,SAAS,eAAe;AAC5B,OAAI,QAAA,SAAS,YACX,QAAO;IAAC;IAAe;IAAW;IAAU;AAG9C,OAAI,QAAA,SAAS,YACX,QAAO;IAAC;IAAY;IAAW;IAAkB;IAAQ;AAG3D,UAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACF;IACD;;uBAIC,mBAsBM,OAtBN,YAsBM,EAAA,UAAA,KAAA,EArBJ,mBAoBa,UAAA,MAAA,WAnBK,OAAA,QAAT,UAAK;wBADd,YAoBa,MAAA,WAAA,EAAA;KAlBV,KAAK;KAEN,QAAA;KACC,IAAE,EAAA,MAAA,GAAa,QAAA,KAAI,GAAI,SAAK;;uBAczB,EAhBM,UAAU,MAAM,eAAQ,CAGlC,mBAaI,KAAA;MAZF,OAAM;MACC;MACN,SAAO;SACR,mBAQO,QAAA,EAPL,OAAK,eAAA,CAAC,8CACe,WAAA,wBAAA,6CAAA,CAAA,EAAA,EAAA,gBAKlB,WAAW,MAAK,CAAA,EAAA,EAAA,CAAA,EAAA,GAAA,WAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/modal/Modal.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modal.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/modal/Modal.vue"],"names":[],"mappings":"AAqNA,OAAO,EAAE,KAAK,UAAU,EAA4B,MAAM,oBAAoB,CAAA;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACT,MAAM,KAAK,CAAA;AAIZ,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AAOxF,MAAM,MAAM,UAAU,GAAG;IACvB,4DAA4D;IAC5D,cAAc,EAAE,cAAc,CAAA;IAC9B,qDAAqD;IACrD,QAAQ,EAAE,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IAC/C,iDAAiD;IACjD,IAAI,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACrC,4CAA4C;IAC5C,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,mDAAmD;IACnD,MAAM,EAAE,WAAW,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IAC3C,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5C,sEAAsE;IACtE,+BAA+B,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC5D,2CAA2C;IAC3C,UAAU,EAAE,UAAU,CAAA;IACtB,0DAA0D;IAC1D,YAAY,EAAE,qBAAqB,CAAA;IACnC,iDAAiD;IACjD,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,wDAAwD;IACxD,OAAO,EAAE,gBAAgB,CACvB,OAAO,CACL,IAAI,CACF,4BAA4B,EAC1B,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,SAAS,CACZ,CACF,CACF,CAAA;CACF,CAAA;AAED;;;;GAIG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;mPAuQd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.vue.js","names":[],"sources":["../../../../src/v2/features/modal/Modal.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type ModalProps = {\n /** The workspace store must be initialized and passed in */\n workspaceStore: WorkspaceStore\n /** The document must be initialized and passed in */\n document: ComputedRef<WorkspaceDocument | null>\n /** The path must be initialized and passed in */\n path: ComputedRef<string | undefined>\n /** The event bus for handling all events */\n eventBus: WorkspaceEventBus\n /** The method must be initialized and passed in */\n method: ComputedRef<HttpMethod | undefined>\n /** The example name must be initialized and passed in */\n exampleName: ComputedRef<string | undefined>\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection: Ref<Record<string, number>>\n /** Controls the visibility of the modal */\n modalState: ModalState\n /** The sidebar state must be initialized and passed in */\n sidebarState: UseModalSidebarReturn\n /** Api client plugins to include in the modal */\n plugins: ClientPlugin[]\n /** Subset of the configuration options for the modal */\n options: MaybeRefOrGetter<\n Partial<\n Pick<\n ApiReferenceConfigurationRaw,\n | 'authentication'\n | 'baseServerURL'\n | 'hideClientButton'\n | 'hiddenClients'\n | 'servers'\n >\n >\n >\n}\n\n/**\n * Scalar Api Client Modal\n *\n * This component is used to render the API Client Modal\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { type ModalState, type ScalarListboxOption } from '@scalar/components'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport { ScalarToasts } from '@scalar/use-toasts'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport {
|
|
1
|
+
{"version":3,"file":"Modal.vue.js","names":[],"sources":["../../../../src/v2/features/modal/Modal.vue"],"sourcesContent":["<script lang=\"ts\">\nexport type ModalProps = {\n /** The workspace store must be initialized and passed in */\n workspaceStore: WorkspaceStore\n /** The document must be initialized and passed in */\n document: ComputedRef<WorkspaceDocument | null>\n /** The path must be initialized and passed in */\n path: ComputedRef<string | undefined>\n /** The event bus for handling all events */\n eventBus: WorkspaceEventBus\n /** The method must be initialized and passed in */\n method: ComputedRef<HttpMethod | undefined>\n /** The example name must be initialized and passed in */\n exampleName: ComputedRef<string | undefined>\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection: Ref<Record<string, number>>\n /** Controls the visibility of the modal */\n modalState: ModalState\n /** The sidebar state must be initialized and passed in */\n sidebarState: UseModalSidebarReturn\n /** Api client plugins to include in the modal */\n plugins: ClientPlugin[]\n /** Subset of the configuration options for the modal */\n options: MaybeRefOrGetter<\n Partial<\n Pick<\n ApiReferenceConfigurationRaw,\n | 'authentication'\n | 'baseServerURL'\n | 'hideClientButton'\n | 'hiddenClients'\n | 'servers'\n >\n >\n >\n}\n\n/**\n * Scalar Api Client Modal\n *\n * This component is used to render the API Client Modal\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { type ModalState, type ScalarListboxOption } from '@scalar/components'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport { ScalarToasts } from '@scalar/use-toasts'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { type WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { getActiveEnvironment } from '@scalar/workspace-store/request-example'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport {\n computed,\n onBeforeUnmount,\n ref,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n} from 'vue'\n\nimport ModalClientContainer from '@/v2/components/modals/ModalClientContainer.vue'\nimport { Sidebar, SidebarToggle } from '@/v2/components/sidebar'\nimport { type UseModalSidebarReturn } from '@/v2/features/modal/hooks/use-modal-sidebar'\nimport { initializeModalEvents } from '@/v2/features/modal/modal-events'\nimport Operation from '@/v2/features/operation/Operation.vue'\nimport { useGlobalHotKeys } from '@/v2/hooks/use-global-hot-keys'\nimport { useScrollLock } from '@/v2/hooks/use-scroll-lock'\n\nconst {\n document,\n eventBus,\n modalState,\n options,\n plugins,\n requestBodyCompositionSelection,\n sidebarState,\n workspaceStore,\n} = defineProps<ModalProps>()\n\nconst activeWorkspace: ScalarListboxOption = {\n label: 'default',\n id: 'default',\n}\n\n/** Controls the visibility of the sidebar. */\nconst isSidebarOpen = ref(false)\n\n/** Initialize modal events */\ninitializeModalEvents({\n eventBus,\n isSidebarOpen,\n requestBodyCompositionSelection,\n sidebarState,\n modalState,\n store: workspaceStore,\n})\n\n/** Register global hotkeys for the app, passing the workspace event bus and layout state */\nuseGlobalHotKeys(eventBus, 'modal', () => !modalState.open)\n\n/** Clean up on close */\nconst cleanUp = () => {\n eventBus.emit('operation:cancel:request')\n}\n\nconst isLocked = useScrollLock(() => {\n if (typeof window !== 'undefined') {\n return window.document.body\n }\n return null\n})\n\nwatch(\n () => modalState.open,\n (open) => {\n // Make sure scrolling is locked or unlocked when the modal is opened or closed\n isLocked.value = open\n\n if (!open) {\n cleanUp()\n }\n },\n)\n\n// Ensure we add our scalar wrapper class to the headless ui root\nonBeforeUnmount(() => cleanUp())\n\n/** Default sidebar width in pixels. */\nconst DEFAULT_SIDEBAR_WIDTH = 288\n\n/** Width of the sidebar, with fallback to default. */\nconst sidebarWidth = computed(\n () =>\n workspaceStore?.workspace?.['x-scalar-sidebar-width'] ??\n DEFAULT_SIDEBAR_WIDTH,\n)\n\n/** Handler for sidebar width changes. */\nconst handleSidebarWidthUpdate = (width: number) =>\n workspaceStore?.update('x-scalar-sidebar-width', width)\n\n/**\n * Merged environment variables from workspace and document levels.\n * Variables from both sources are combined, with document variables\n * taking precedence in case of naming conflicts.\n */\nconst environment = computed(\n () => getActiveEnvironment(workspaceStore, document.value).environment,\n)\n\ndefineExpose({\n sidebarWidth,\n environment,\n})\n</script>\n\n<template>\n <ModalClientContainer :modalState>\n <!-- Toasts -->\n <ScalarToasts />\n\n <!-- If we have a document, path and method, render the operation -->\n <main\n v-if=\"document.value && path?.value && method?.value\"\n class=\"relative flex h-full min-h-0 w-full flex-1\">\n <SidebarToggle\n v-model=\"isSidebarOpen\"\n class=\"absolute top-2 left-3 z-2\" />\n <Sidebar\n v-show=\"isSidebarOpen\"\n v-model:sidebarWidth=\"sidebarWidth\"\n :activeWorkspace=\"activeWorkspace\"\n class=\"h-full max-md:absolute! max-md:w-full!\"\n :documents=\"[document.value]\"\n :eventBus\n :isDroppable=\"() => false\"\n layout=\"modal\"\n :sidebarState=\"sidebarState.state\"\n :workspaces=\"[]\"\n @selectItem=\"sidebarState.handleSelectItem\"\n @update:sidebarWidth=\"handleSidebarWidthUpdate\" />\n <Operation\n :activeWorkspace=\"activeWorkspace\"\n class=\"flex-1\"\n :document=\"document.value\"\n :documentSlug=\"document.value['x-scalar-navigation']?.id ?? ''\"\n :environment\n :eventBus\n :exampleName=\"exampleName?.value\"\n layout=\"modal\"\n :method=\"method?.value\"\n :options\n :path=\"path?.value\"\n :plugins\n :requestBodyCompositionSelection=\"requestBodyCompositionSelection.value\"\n :workspaceStore />\n </main>\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\">No document selected</span>\n </div>\n </ModalClientContainer>\n</template>\n"],"mappings":""}
|
|
@@ -5,9 +5,9 @@ import { useGlobalHotKeys } from "../../hooks/use-global-hot-keys.js";
|
|
|
5
5
|
import Operation_default from "../operation/Operation.vue.js";
|
|
6
6
|
import { initializeModalEvents } from "./modal-events.js";
|
|
7
7
|
import { useScrollLock } from "../../hooks/use-scroll-lock.js";
|
|
8
|
-
import { computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, onBeforeUnmount, openBlock, ref,
|
|
8
|
+
import { computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, onBeforeUnmount, openBlock, ref, unref, vShow, watch, withCtx, withDirectives } from "vue";
|
|
9
9
|
import { ScalarToasts } from "@scalar/use-toasts";
|
|
10
|
-
import { getActiveEnvironment
|
|
10
|
+
import { getActiveEnvironment } from "@scalar/workspace-store/request-example";
|
|
11
11
|
//#region src/v2/features/modal/Modal.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var _hoisted_1 = {
|
|
13
13
|
key: 0,
|
|
@@ -75,8 +75,6 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
75
75
|
* taking precedence in case of naming conflicts.
|
|
76
76
|
*/
|
|
77
77
|
const environment = computed(() => getActiveEnvironment(__props.workspaceStore, __props.document.value).environment);
|
|
78
|
-
/** Merge authentication config with the document security schemes */
|
|
79
|
-
const securitySchemes = computed(() => mergeSecurity(__props.document.value?.components?.securitySchemes, toValue(__props.options)?.authentication?.securitySchemes, __props.workspaceStore.auth, __props.document.value?.["x-scalar-navigation"]?.name ?? ""));
|
|
80
78
|
__expose({
|
|
81
79
|
sidebarWidth,
|
|
82
80
|
environment
|
|
@@ -122,7 +120,6 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
122
120
|
path: __props.path?.value,
|
|
123
121
|
plugins: __props.plugins,
|
|
124
122
|
requestBodyCompositionSelection: __props.requestBodyCompositionSelection.value,
|
|
125
|
-
securitySchemes: securitySchemes.value,
|
|
126
123
|
workspaceStore: __props.workspaceStore
|
|
127
124
|
}, null, 8, [
|
|
128
125
|
"document",
|
|
@@ -135,7 +132,6 @@ var Modal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
|
|
|
135
132
|
"path",
|
|
136
133
|
"plugins",
|
|
137
134
|
"requestBodyCompositionSelection",
|
|
138
|
-
"securitySchemes",
|
|
139
135
|
"workspaceStore"
|
|
140
136
|
])
|
|
141
137
|
])) : (openBlock(), createElementBlock("div", _hoisted_2, [..._cache[2] || (_cache[2] = [createElementVNode("span", { class: "text-c-3" }, "No document selected", -1)])]))]),
|