@scalar/api-client 2.24.0 → 2.26.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/components/DataTable/DataTableCheckbox.vue.d.ts.map +1 -1
  3. package/dist/components/DataTable/DataTableCheckbox.vue.js +8 -8
  4. package/dist/style.css +1 -1
  5. package/dist/v2/blocks/operation-block/helpers/build-request-body.d.ts.map +1 -1
  6. package/dist/v2/blocks/operation-block/helpers/build-request-body.js +28 -19
  7. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
  8. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
  9. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue2.js +1 -1
  10. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
  11. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js +18 -18
  12. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  13. package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.d.ts.map +1 -1
  14. package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.js +2 -2
  15. package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue2.js +19 -19
  16. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
  17. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js +26 -26
  18. package/dist/v2/components/callout/Callout.vue.d.ts +17 -0
  19. package/dist/v2/components/callout/Callout.vue.d.ts.map +1 -0
  20. package/dist/v2/components/callout/Callout.vue.js +7 -0
  21. package/dist/v2/components/callout/Callout.vue2.js +43 -0
  22. package/dist/v2/components/data-table/DataTableCheckbox.vue.d.ts.map +1 -1
  23. package/dist/v2/components/data-table/DataTableCheckbox.vue.js +8 -8
  24. package/dist/v2/components/sidebar/Sidebar.vue.d.ts +2 -2
  25. package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
  26. package/dist/v2/components/sidebar/Sidebar.vue.js +40 -41
  27. package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts +2 -2
  28. package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts.map +1 -1
  29. package/dist/v2/components/sidebar/SidebarMenu.vue.js +6 -6
  30. package/dist/v2/features/app/App.vue.d.ts +6 -3
  31. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  32. package/dist/v2/features/app/App.vue.js +87 -86
  33. package/dist/v2/features/app/app-events.d.ts +1 -1
  34. package/dist/v2/features/app/app-events.d.ts.map +1 -1
  35. package/dist/v2/features/app/app-events.js +10 -10
  36. package/dist/v2/features/app/app-state.d.ts +77 -96
  37. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  38. package/dist/v2/features/app/app-state.js +339 -322
  39. package/dist/v2/features/app/components/AppSidebar.vue.d.ts +2 -2
  40. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  41. package/dist/v2/features/app/components/AppSidebar.vue.js +3 -3
  42. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
  43. package/dist/v2/features/app/components/DesktopTabs.vue.js +1 -1
  44. package/dist/v2/features/app/helpers/create-api-client-app.d.ts +2 -2
  45. package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
  46. package/dist/v2/features/app/helpers/create-api-client-app.js +9 -9
  47. package/dist/v2/features/app/helpers/filter-workspaces.d.ts +49 -0
  48. package/dist/v2/features/app/helpers/filter-workspaces.d.ts.map +1 -0
  49. package/dist/v2/features/app/helpers/filter-workspaces.js +5 -0
  50. package/dist/v2/features/app/helpers/get-route-param.d.ts +7 -0
  51. package/dist/v2/features/app/helpers/get-route-param.d.ts.map +1 -0
  52. package/dist/v2/features/app/helpers/get-route-param.js +9 -0
  53. package/dist/v2/features/app/helpers/group-workspaces.d.ts +24 -0
  54. package/dist/v2/features/app/helpers/group-workspaces.d.ts.map +1 -0
  55. package/dist/v2/features/app/helpers/group-workspaces.js +23 -0
  56. package/dist/v2/features/app/index.d.ts +1 -1
  57. package/dist/v2/features/app/index.d.ts.map +1 -1
  58. package/dist/v2/features/app/index.js +12 -12
  59. package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
  60. package/dist/v2/features/collection/DocumentCollection.vue.js +72 -65
  61. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +29 -2
  62. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
  63. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +110 -106
  64. package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts +5 -1
  65. package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts.map +1 -1
  66. package/dist/v2/features/command-palette/helpers/load-document-from-source.js +41 -23
  67. package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +41 -8
  68. package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -1
  69. package/dist/v2/features/command-palette/index.d.ts +1 -2
  70. package/dist/v2/features/command-palette/index.d.ts.map +1 -1
  71. package/dist/v2/features/command-palette/index.js +4 -6
  72. package/dist/v2/features/operation/Operation.vue.js +1 -1
  73. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.d.ts.map +1 -1
  74. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.js +2 -2
  75. package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue2.js +24 -23
  76. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  77. package/package.json +10 -10
  78. package/dist/v2/features/app/components/WebTopNav.vue.d.ts +0 -41
  79. package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +0 -1
  80. package/dist/v2/features/app/components/WebTopNav.vue.js +0 -27
  81. package/dist/v2/features/app/components/WebTopNav.vue2.js +0 -4
@@ -1,355 +1,372 @@
1
- import { isDefined as B } from "@scalar/helpers/array/is-defined";
2
- import { sortByOrder as Y } from "@scalar/helpers/array/sort-by-order";
3
- import { isHttpMethod as j } from "@scalar/helpers/http/is-http-method";
4
- import { createSidebarState as z, generateReverseIndex as J } from "@scalar/sidebar";
5
- import { createWorkspaceStore as O } from "@scalar/workspace-store/client";
6
- import { createWorkspaceEventBus as M } from "@scalar/workspace-store/events";
7
- import { generateUniqueValue as G } from "@scalar/workspace-store/helpers/generate-unique-value";
1
+ import { isDefined as Y } from "@scalar/helpers/array/is-defined";
2
+ import { sortByOrder as pe } from "@scalar/helpers/array/sort-by-order";
3
+ import { createSidebarState as ue, generateReverseIndex as me } from "@scalar/sidebar";
4
+ import { createWorkspaceStore as j } from "@scalar/workspace-store/client";
5
+ import { createWorkspaceEventBus as de } from "@scalar/workspace-store/events";
6
+ import { generateUniqueValue as ve } from "@scalar/workspace-store/helpers/generate-unique-value";
8
7
  import { getParentEntry as v } from "@scalar/workspace-store/navigation";
9
- import { createWorkspaceStorePersistence as Q } from "@scalar/workspace-store/persistence";
10
- import { persistencePlugin as X } from "@scalar/workspace-store/plugins/client";
11
- import { extensions as Z } from "@scalar/workspace-store/schemas/extensions";
12
- import { shallowRef as T, computed as i, ref as p, watch as ee } from "vue";
13
- import { getActiveEnvironment as te } from "../../helpers/get-active-environment.js";
14
- import { getTabDetails as ae } from "../../helpers/get-tab-details.js";
15
- import { slugify as ne } from "../../helpers/slugify.js";
16
- import { workspaceStorage as re } from "../../helpers/storage.js";
17
- import { initializeAppEventHandlers as oe } from "./app-events.js";
18
- const se = 1e3, b = M({
19
- debug: !1
20
- }), f = p(void 0), E = p(void 0), k = p(void 0), L = p(void 0), N = p(void 0), P = p(void 0), x = p(!1), u = T(null);
21
- ee(u, (e) => {
22
- e && e.afterEach((t) => be(t));
23
- });
24
- const d = i(() => u.value?.currentRoute.value ?? null);
25
- function s(e, t) {
26
- const a = t?.params[e];
27
- if (typeof a == "string")
28
- return e === "method" ? a && j(a) ? a : void 0 : decodeURIComponent(a);
29
- }
30
- const D = T(null), h = p([]), o = T(null), R = i(() => o.value?.workspace.documents[k.value ?? ""] || null), ce = i(() => te(o.value, R.value)), { workspace: y } = await Q(), w = (e, t) => `${e}/${t}`;
31
- h.value = await y.getAll().then(
32
- (e) => e.map(({ teamUid: t, namespace: a, slug: n, name: l }) => ({
33
- id: w(a, n),
34
- teamUid: t,
35
- namespace: a,
36
- slug: n,
37
- label: l
38
- }))
39
- );
40
- const ue = async ({ namespace: e, slug: t }) => O({
41
- plugins: [
42
- await X({ workspaceId: w(e, t), debounceDelay: se })
43
- ]
44
- }), le = async (e, t) => {
45
- const a = await y.getItem({ namespace: e, slug: t });
46
- if (!a)
47
- return {
48
- success: !1
49
- };
50
- const n = await ue({ namespace: e, slug: t });
51
- return n.loadWorkspace(a.workspace), D.value = { id: w(a.namespace, a.slug), label: a.name }, o.value = n, {
52
- success: !0,
53
- workspace: n.workspace
54
- };
55
- }, ie = async ({
56
- name: e,
57
- teamUid: t,
58
- namespace: a,
59
- slug: n
8
+ import { createWorkspaceStorePersistence as fe } from "@scalar/workspace-store/persistence";
9
+ import { persistencePlugin as he } from "@scalar/workspace-store/plugins/client";
10
+ import { extensions as we } from "@scalar/workspace-store/schemas/extensions";
11
+ import { ref as u, computed as p, shallowRef as H } from "vue";
12
+ import { getRouteParam as l } from "./helpers/get-route-param.js";
13
+ import { groupWorkspacesByTeam as ke } from "./helpers/group-workspaces.js";
14
+ import { getActiveEnvironment as ge } from "../../helpers/get-active-environment.js";
15
+ import { getTabDetails as xe } from "../../helpers/get-tab-details.js";
16
+ import { slugify as be } from "../../helpers/slugify.js";
17
+ import { workspaceStorage as ye } from "../../helpers/storage.js";
18
+ import { initializeAppEventHandlers as Se } from "./app-events.js";
19
+ import { filterWorkspacesByTeam as Ee, canLoadWorkspace as We } from "./helpers/filter-workspaces.js";
20
+ const Ue = 1e3, Te = 288, h = (i, T) => `${i}/${T}`, He = async ({
21
+ router: i,
22
+ fileLoader: T
60
23
  }) => {
61
- const l = O();
62
- await l.addDocument({
63
- name: "drafts",
64
- document: {
65
- openapi: "3.1.0",
66
- info: {
67
- title: "Drafts",
68
- version: "1.0.0"
69
- },
70
- paths: {
71
- "/": {
72
- get: {}
73
- }
74
- },
75
- "x-scalar-original-document-hash": "drafts",
76
- "x-scalar-icon": "interface-edit-tool-pencil"
77
- }
78
- });
79
- const c = await y.setItem(
80
- { namespace: a, slug: n },
81
- {
82
- name: e,
83
- teamUid: t,
84
- workspace: l.exportWorkspace()
85
- }
24
+ const w = de({
25
+ debug: !1
26
+ }), { workspace: k } = await fe(), g = u("local"), x = u(void 0), I = u(void 0), b = u(void 0), L = u(void 0), O = u(void 0), N = u(void 0), y = u(!1);
27
+ i.afterEach((e) => ce(e));
28
+ const d = p(() => i.currentRoute.value ?? null), D = H(null), f = u([]), S = p(() => Ee(f.value, g.value)), z = p(() => ke(S.value, g.value)), s = H(null), A = p(() => s.value?.workspace.documents[b.value ?? ""] || null), G = p(() => ge(s.value, A.value));
29
+ f.value = await k.getAll().then(
30
+ (e) => e.map(({ teamUid: a, namespace: t, slug: n, name: c }) => ({
31
+ id: h(t, n),
32
+ teamUid: a,
33
+ namespace: t,
34
+ slug: n,
35
+ label: c
36
+ }))
86
37
  );
87
- return h.value.push({
88
- id: w(c.namespace, c.slug),
89
- teamUid: c.teamUid,
90
- namespace: c.namespace,
91
- slug: c.slug,
92
- label: c.name
93
- }), c;
94
- }, A = async (e, t) => {
95
- await u.value?.push({
96
- name: "workspace.environment",
97
- params: { namespace: e, workspaceSlug: t }
98
- });
99
- }, _ = async ({
100
- teamUid: e,
101
- namespace: t,
102
- slug: a,
103
- name: n
104
- }) => {
105
- o.value = null;
106
- const l = await G({
107
- defaultValue: a ?? n,
108
- // Use the provided id if it exists, otherwise use the name
109
- validation: async (g) => !await y.has({ namespace: t ?? "local", slug: g }),
110
- maxRetries: 100,
111
- transformation: ne
112
- });
113
- if (!l)
114
- return;
115
- const m = await ie({
116
- teamUid: e,
38
+ const J = async ({
39
+ namespace: e,
40
+ slug: a
41
+ }) => j({
42
+ plugins: [
43
+ await he({
44
+ workspaceId: h(e, a),
45
+ debounceDelay: Ue
46
+ })
47
+ ],
48
+ fileLoader: T
49
+ }), Q = async (e, a) => {
50
+ const t = await k.getItem({ namespace: e, slug: a });
51
+ if (!t)
52
+ return {
53
+ success: !1
54
+ };
55
+ const n = await J({ namespace: e, slug: a });
56
+ return n.loadWorkspace(t.workspace), D.value = { id: h(t.namespace, t.slug), label: t.name }, s.value = n, {
57
+ success: !0,
58
+ workspace: n.workspace
59
+ };
60
+ }, X = async ({
61
+ name: e,
62
+ teamUid: a,
117
63
  namespace: t,
118
- slug: l,
64
+ slug: n
65
+ }) => {
66
+ const c = j();
67
+ await c.addDocument({
68
+ name: "drafts",
69
+ document: {
70
+ openapi: "3.1.0",
71
+ info: {
72
+ title: "Drafts",
73
+ version: "1.0.0"
74
+ },
75
+ paths: {
76
+ "/": {
77
+ get: {}
78
+ }
79
+ },
80
+ "x-scalar-original-document-hash": "drafts",
81
+ "x-scalar-icon": "interface-edit-tool-pencil"
82
+ }
83
+ });
84
+ const r = await k.setItem(
85
+ { namespace: t, slug: n },
86
+ {
87
+ name: e,
88
+ teamUid: a,
89
+ workspace: c.exportWorkspace()
90
+ }
91
+ );
92
+ return f.value.push({
93
+ id: h(r.namespace, r.slug),
94
+ teamUid: r.teamUid,
95
+ namespace: r.namespace,
96
+ slug: r.slug,
97
+ label: r.name
98
+ }), r;
99
+ }, E = async (e, a) => {
100
+ await i.push({
101
+ name: "workspace.environment",
102
+ params: { namespace: e, workspaceSlug: a }
103
+ });
104
+ }, _ = async ({
105
+ teamUid: e,
106
+ namespace: a,
107
+ slug: t,
119
108
  name: n
120
- });
121
- return await A(m.namespace, m.slug), m;
122
- }, pe = async (e, t) => {
123
- o.value = null, x.value = !0;
124
- const a = await le(e, t);
125
- if (a.success) {
126
- const c = a.workspace["x-scalar-active-tab"] ?? 0, m = a.workspace["x-scalar-tabs"], g = m?.[c];
127
- g && await u.value?.replace({
128
- path: g.path,
129
- query: d.value?.query ?? {}
130
- }), m && c >= m.length && b.emit("tabs:update:tabs", {
131
- "x-scalar-active-tab": 0
132
- }), m || b.emit("tabs:update:tabs", {
133
- "x-scalar-tabs": [C(d.value)],
134
- "x-scalar-active-tab": 0
135
- }), x.value = !1;
136
- return;
137
- }
138
- const n = h.value.find((c) => c.slug === "default") ?? h.value[0];
139
- if (n)
140
- return A(n.namespace, n.slug);
141
- const l = await _({
142
- name: "Default Workspace",
143
- slug: "default"
144
- });
145
- if (x.value = !1, !l)
146
- return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
147
- r.reset();
148
- }, $ = i(() => {
149
- const e = o.value;
150
- if (!e)
151
- return [];
152
- const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
153
- return Y(Object.keys(e.workspace.documents), t, (a) => a).map((a) => e.workspace.documents[a]?.["x-scalar-navigation"]).filter(B);
154
- }), r = z($), W = ({
155
- document: e,
156
- path: t,
157
- method: a,
158
- example: n
159
- }) => JSON.stringify([e, t, a, n].filter(B)), U = i(
160
- () => J({
161
- items: $.value,
162
- nestedKey: "children",
163
- filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
164
- getId: (e) => {
165
- const t = v("document", e), a = v("operation", e);
166
- return W({
167
- document: t?.name ?? "",
168
- path: a?.path,
169
- method: a?.method,
170
- example: e.type === "example" ? e.name : void 0
171
- });
172
- }
173
- })
174
- ), S = (e) => {
175
- const t = U.value.get(W(e));
176
- return t || U.value.get(
177
- W({
178
- document: e.document,
179
- path: e.path,
180
- method: e.method
181
- })
182
- );
183
- }, F = (e) => {
184
- const t = r.getEntryById(e);
185
- if (!t) {
186
- console.warn(`Could not find sidebar entry with id ${e} to select`);
187
- return;
188
- }
189
- if (t.type === "document") {
190
- if (r.selectedItem.value === e) {
191
- r.setExpanded(e, !r.isExpanded(e));
109
+ }) => {
110
+ s.value = null;
111
+ const c = await ve({
112
+ defaultValue: t ?? n,
113
+ // Use the provided id if it exists, otherwise use the name
114
+ validation: async (U) => !await k.has({ namespace: a ?? "local", slug: U }),
115
+ maxRetries: 100,
116
+ transformation: be
117
+ });
118
+ if (!c)
119
+ return;
120
+ const m = await X({
121
+ teamUid: e,
122
+ namespace: a,
123
+ slug: c,
124
+ name: n
125
+ });
126
+ return await E(m.namespace, m.slug), m;
127
+ }, Z = async (e, a) => {
128
+ s.value = null, y.value = !0;
129
+ const t = await Q(e, a);
130
+ if (t.success) {
131
+ const r = t.workspace["x-scalar-active-tab"] ?? 0, m = t.workspace["x-scalar-tabs"], U = m?.[r];
132
+ U && await i.replace({
133
+ path: U.path,
134
+ query: d.value?.query ?? {}
135
+ }), m && r >= m.length && w.emit("tabs:update:tabs", {
136
+ "x-scalar-active-tab": 0
137
+ }), m || w.emit("tabs:update:tabs", {
138
+ "x-scalar-tabs": [B(d.value)],
139
+ "x-scalar-active-tab": 0
140
+ }), y.value = !1;
192
141
  return;
193
142
  }
194
- return r.setSelected(e), r.setExpanded(e, !0), u.value?.push({
195
- name: "document.overview",
196
- params: { documentSlug: t.name }
143
+ const n = S.value.find((r) => r.teamUid === "local" && r.slug === "default") ?? S.value[0];
144
+ if (n)
145
+ return E(n.namespace, n.slug);
146
+ const c = await _({
147
+ name: "Default Workspace",
148
+ slug: "default"
197
149
  });
198
- }
199
- if (t.type === "operation") {
200
- if (r.isSelected(e)) {
201
- r.setExpanded(e, !r.isExpanded(e));
150
+ if (y.value = !1, !c)
151
+ return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
152
+ o.reset();
153
+ }, P = p(() => {
154
+ const e = s.value;
155
+ if (!e)
156
+ return [];
157
+ const a = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
158
+ return pe(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(Y);
159
+ }), o = ue(P), R = ({
160
+ document: e,
161
+ path: a,
162
+ method: t,
163
+ example: n
164
+ }) => JSON.stringify([e, a, t, n].filter(Y)), $ = p(
165
+ () => me({
166
+ items: P.value,
167
+ nestedKey: "children",
168
+ filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
169
+ getId: (e) => {
170
+ const a = v("document", e), t = v("operation", e);
171
+ return R({
172
+ document: a?.name ?? "",
173
+ path: t?.path,
174
+ method: t?.method,
175
+ example: e.type === "example" ? e.name : void 0
176
+ });
177
+ }
178
+ })
179
+ ), W = (e) => {
180
+ const a = $.value.get(R(e));
181
+ return a || $.value.get(
182
+ R({
183
+ document: e.document,
184
+ path: e.path,
185
+ method: e.method
186
+ })
187
+ );
188
+ }, F = (e) => {
189
+ const a = o.getEntryById(e);
190
+ if (!a) {
191
+ console.warn(`Could not find sidebar entry with id ${e} to select`);
202
192
  return;
203
193
  }
204
- const a = t.children?.find((n) => n.type === "example");
205
- return a ? (r.setSelected(a.id), r.setExpanded(a.id, !0)) : r.setSelected(e), u.value?.push({
206
- name: "example",
207
- params: {
208
- documentSlug: v("document", t)?.name,
209
- pathEncoded: encodeURIComponent(t.path),
210
- method: t.method,
211
- exampleName: a?.name ?? "default"
194
+ if (a.type === "document") {
195
+ if (o.selectedItem.value === e) {
196
+ o.setExpanded(e, !o.isExpanded(e));
197
+ return;
212
198
  }
213
- });
214
- }
215
- if (t.type === "example") {
216
- r.setSelected(e);
217
- const a = v("operation", t);
218
- return u.value?.push({
219
- name: "example",
220
- params: {
221
- documentSlug: v("document", t)?.name,
222
- pathEncoded: encodeURIComponent(a?.path ?? ""),
223
- method: a?.method,
224
- exampleName: t.name
199
+ return o.setSelected(e), o.setExpanded(e, !0), i.push({
200
+ name: "document.overview",
201
+ params: { documentSlug: a.name }
202
+ });
203
+ }
204
+ if (a.type === "operation") {
205
+ if (o.isSelected(e)) {
206
+ o.setExpanded(e, !o.isExpanded(e));
207
+ return;
225
208
  }
209
+ const t = a.children?.find((n) => n.type === "example");
210
+ return t ? (o.setSelected(t.id), o.setExpanded(t.id, !0)) : o.setSelected(e), i.push({
211
+ name: "example",
212
+ params: {
213
+ documentSlug: v("document", a)?.name,
214
+ pathEncoded: encodeURIComponent(a.path),
215
+ method: a.method,
216
+ exampleName: t?.name ?? "default"
217
+ }
218
+ });
219
+ }
220
+ if (a.type === "example") {
221
+ o.setSelected(e);
222
+ const t = v("operation", a);
223
+ return i.push({
224
+ name: "example",
225
+ params: {
226
+ documentSlug: v("document", a)?.name,
227
+ pathEncoded: encodeURIComponent(t?.path ?? ""),
228
+ method: t?.method,
229
+ exampleName: a.name
230
+ }
231
+ });
232
+ }
233
+ if (a.type === "text")
234
+ return i.push({
235
+ name: "document.overview",
236
+ params: {
237
+ documentSlug: v("document", a)?.name
238
+ }
239
+ });
240
+ o.setExpanded(e, !o.isExpanded(e));
241
+ }, ee = async () => {
242
+ if (!s.value)
243
+ return;
244
+ const e = s.value.workspace["x-scalar-active-tab"] ?? 0, a = s.value.workspace["x-scalar-tabs"]?.[e];
245
+ a && await i.replace(a.path);
246
+ }, K = (e) => {
247
+ e && s.value?.buildSidebar(e);
248
+ }, ae = (e) => {
249
+ const a = A.value?.["x-scalar-navigation"]?.name;
250
+ if (!a)
251
+ return;
252
+ const t = W({
253
+ document: a,
254
+ path: e.path,
255
+ method: e.method,
256
+ example: e.exampleKey
226
257
  });
227
- }
228
- if (t.type === "text")
229
- return u.value?.push({
230
- name: "document.overview",
231
- params: {
232
- documentSlug: v("document", t)?.name
233
- }
258
+ (!t || t.type !== "example") && (K(a), d.value && M(d.value));
259
+ }, te = p(() => s.value?.workspace?.["x-scalar-sidebar-width"] ?? Te), ne = (e) => s.value?.update("x-scalar-sidebar-width", e), C = u(!0), se = "x-scalar-tabs", oe = "x-scalar-active-tab", B = (e) => {
260
+ const a = l("method", e), t = l("pathEncoded", e), n = l("documentSlug", e), c = l("workspaceSlug", e);
261
+ return {
262
+ ...xe({
263
+ workspace: c,
264
+ document: n,
265
+ path: t,
266
+ method: a,
267
+ getEntryByLocation: W
268
+ }),
269
+ path: d.value?.path ?? ""
270
+ };
271
+ }, V = p(() => s.value?.workspace[se] ?? [B(d.value)]), re = p(() => s.value?.workspace[oe] ?? 0), q = async (e) => {
272
+ const a = V.value[e];
273
+ if (!a) {
274
+ console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
275
+ return;
276
+ }
277
+ const t = `${window.location.origin}${a.path}`;
278
+ try {
279
+ await navigator.clipboard.writeText(t);
280
+ } catch (n) {
281
+ console.error("Failed to copy URL to clipboard:", n);
282
+ }
283
+ }, ce = (e) => {
284
+ const a = l("workspaceSlug", e), t = l("documentSlug", e), n = l("namespace", e);
285
+ if (!n || !a)
286
+ return;
287
+ const c = f.value.find(
288
+ (r) => r.slug === a && r.namespace === n
289
+ );
290
+ if (c && !We(c.teamUid, g.value))
291
+ return E("local", "default");
292
+ if (x.value = n, I.value = a, b.value = t, L.value = l("method", e), O.value = l("pathEncoded", e), N.value = l("exampleName", e), e.path !== "" && ye.setCurrentPath(e.path), h(x.value, a) !== D.value?.id)
293
+ return Z(x.value, a);
294
+ t && t !== s.value?.workspace[we.workspace.activeDocument] && s?.value?.update("x-scalar-active-document", t), le(e), M(e);
295
+ }, le = (e) => {
296
+ const a = s.value?.workspace["x-scalar-tabs"] ?? [], t = s.value?.workspace["x-scalar-active-tab"] ?? 0, n = a[t];
297
+ !n || n.path === e.path || (a[t] = B(e));
298
+ }, M = (e) => {
299
+ const a = l("documentSlug", e);
300
+ if (!a) {
301
+ o.setSelected(null);
302
+ return;
303
+ }
304
+ const t = W({
305
+ document: a,
306
+ path: l("pathEncoded", e),
307
+ method: l("method", e),
308
+ example: l("exampleName", e)
234
309
  });
235
- r.setExpanded(e, !r.isExpanded(e));
236
- }, me = async () => {
237
- if (!o.value)
238
- return;
239
- const e = o.value.workspace["x-scalar-active-tab"] ?? 0, t = o.value.workspace["x-scalar-tabs"]?.[e];
240
- t && await u.value?.replace(t.path);
241
- }, K = (e) => {
242
- e && o.value?.buildSidebar(e);
243
- }, de = (e) => {
244
- const t = R.value?.["x-scalar-navigation"]?.name;
245
- if (!t)
246
- return;
247
- const a = S({
248
- document: t,
249
- path: e.path,
250
- method: e.method,
251
- example: e.exampleKey
252
- });
253
- (!a || a.type !== "example") && (K(t), d.value && V(d.value));
254
- }, ve = 288, fe = i(() => o.value?.workspace?.["x-scalar-sidebar-width"] ?? ve), he = (e) => o.value?.update("x-scalar-sidebar-width", e), I = p(!0), we = "x-scalar-tabs", ge = "x-scalar-active-tab", C = (e) => {
255
- const t = s("method", e), a = s("pathEncoded", e), n = s("documentSlug", e), l = s("workspaceSlug", e);
256
- return {
257
- ...ae({
258
- workspace: l,
259
- document: n,
260
- path: a,
261
- method: t,
262
- getEntryByLocation: S
263
- }),
264
- path: d.value?.path ?? ""
310
+ t && (o.setSelected(t.id), o.setExpanded(t.id, !0));
265
311
  };
266
- }, q = i(() => o.value?.workspace[we] ?? [C(d.value)]), xe = i(() => o.value?.workspace[ge] ?? 0), H = async (e) => {
267
- const t = q.value[e];
268
- if (!t) {
269
- console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
270
- return;
271
- }
272
- const a = `${window.location.origin}${t.path}`;
273
- try {
274
- await navigator.clipboard.writeText(a);
275
- } catch (n) {
276
- console.error("Failed to copy URL to clipboard:", n);
277
- }
278
- }, be = (e) => {
279
- const t = s("workspaceSlug", e), a = s("documentSlug", e);
280
- if (f.value = s("namespace", e), E.value = t, k.value = a, L.value = s("method", e), N.value = s("pathEncoded", e), P.value = s("exampleName", e), !(!f.value || !t)) {
281
- if (e.path !== "" && re.setCurrentPath(e.path), w(f.value, t) !== D.value?.id)
282
- return pe(f.value, t);
283
- a && a !== o.value?.workspace[Z.workspace.activeDocument] && o?.value?.update("x-scalar-active-document", a), ke(e), V(e);
284
- }
285
- }, ke = (e) => {
286
- const t = o.value?.workspace["x-scalar-tabs"] ?? [], a = o.value?.workspace["x-scalar-active-tab"] ?? 0, n = t[a];
287
- !n || n.path === e.path || (t[a] = C(e));
288
- }, V = (e) => {
289
- const t = s("documentSlug", e);
290
- if (!t) {
291
- r.setSelected(null);
292
- return;
293
- }
294
- const a = S({
295
- document: t,
296
- path: s("pathEncoded", e),
297
- method: s("method", e),
298
- example: s("exampleName", e)
312
+ Se({
313
+ eventBus: w,
314
+ router: i,
315
+ store: s,
316
+ navigateToCurrentTab: ee,
317
+ rebuildSidebar: K,
318
+ onAfterExampleCreation: ae,
319
+ onSelectSidebarItem: F,
320
+ onCopyTabUrl: (e) => q(e),
321
+ onToggleSidebar: () => C.value = !C.value
299
322
  });
300
- a && (r.setSelected(a.id), r.setExpanded(a.id, !0));
301
- };
302
- oe({
303
- eventBus: b,
304
- router: u,
305
- store: o,
306
- navigateToCurrentTab: me,
307
- rebuildSidebar: K,
308
- onAfterExampleCreation: de,
309
- onSelectSidebarItem: F,
310
- onCopyTabUrl: (e) => H(e),
311
- onToggleSidebar: () => I.value = !I.value
312
- });
313
- function $e(e) {
314
- return e && (u.value = e), {
323
+ const ie = p(() => {
324
+ const e = s.value?.workspace["x-scalar-color-mode"] ?? "system";
325
+ return e === "system" ? window.matchMedia?.("(prefers-color-scheme: dark)")?.matches ?? !1 : e === "dark";
326
+ });
327
+ return {
315
328
  /** Active workspace store */
316
- store: o,
329
+ store: s,
317
330
  sidebar: {
318
- state: r,
319
- width: fe,
320
- isOpen: I,
331
+ state: o,
332
+ width: te,
333
+ isOpen: C,
321
334
  handleSelectItem: F,
322
- handleSidebarWidthUpdate: he,
323
- getEntryByLocation: S
335
+ handleSidebarWidthUpdate: ne,
336
+ getEntryByLocation: W
324
337
  },
325
338
  tabs: {
326
- state: q,
327
- activeTabIndex: xe,
328
- copyTabUrl: H
339
+ state: V,
340
+ activeTabIndex: re,
341
+ copyTabUrl: q
329
342
  },
330
343
  workspace: {
331
344
  create: _,
332
- workspaceList: h,
345
+ workspaceList: f,
346
+ filteredWorkspaceList: S,
347
+ workspaceGroups: z,
333
348
  activeWorkspace: D,
334
- navigateToWorkspace: A,
335
- isOpen: i(() => !!(E.value && !k.value))
349
+ navigateToWorkspace: E,
350
+ isOpen: p(() => !!(I.value && !b.value))
336
351
  },
337
- eventBus: b,
338
- router: u,
352
+ eventBus: w,
353
+ router: i,
339
354
  currentRoute: d,
340
- loading: x,
355
+ loading: y,
341
356
  activeEntities: {
342
- namespace: f,
343
- workspaceSlug: E,
344
- documentSlug: k,
345
- path: N,
357
+ namespace: x,
358
+ workspaceSlug: I,
359
+ documentSlug: b,
360
+ path: O,
346
361
  method: L,
347
- exampleName: P
362
+ exampleName: N,
363
+ teamUid: g
348
364
  },
349
- environment: ce,
350
- document: R
365
+ environment: G,
366
+ document: A,
367
+ isDarkMode: ie
351
368
  };
352
- }
369
+ };
353
370
  export {
354
- $e as useAppState
371
+ He as createAppState
355
372
  };