@scalar/api-client 2.31.3 → 2.33.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 +94 -0
- package/dist/assets/yaml.worker-CcQnAKCg.js +490 -0
- package/dist/style.css +1 -1
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/features/app/App.vue.d.ts +0 -5
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +57 -60
- package/dist/v2/features/app/app-state.d.ts +17 -2
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +117 -105
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.js +1 -3
- package/dist/v2/features/app/helpers/routes.d.ts +17 -0
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.js +8 -2
- package/dist/v2/features/app/hooks/use-theme.d.ts +14 -0
- package/dist/v2/features/app/hooks/use-theme.d.ts.map +1 -1
- package/dist/v2/features/app/hooks/use-theme.js +42 -28
- package/dist/v2/features/collection/DocumentCollection.vue.js +8 -6
- package/dist/v2/features/collection/OperationCollection.vue.js +14 -12
- package/dist/v2/features/collection/WorkspaceCollection.vue.js +9 -7
- package/dist/v2/features/collection/components/Authentication.vue2.js +19 -17
- package/dist/v2/features/collection/components/Cookies.vue.js +10 -8
- package/dist/v2/features/collection/components/Editor/Editor.vue.d.ts +16 -0
- package/dist/v2/features/collection/components/Editor/Editor.vue.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/Editor.vue.js +7 -0
- package/dist/v2/features/collection/components/Editor/Editor.vue2.js +333 -0
- package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.d.ts +19 -0
- package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.js +78 -0
- package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue2.js +4 -0
- package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.d.ts +16 -0
- package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.js +83 -0
- package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue2.js +4 -0
- package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.d.ts +16 -0
- package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.js +56 -0
- package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.d.ts +7 -0
- package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.js +40 -0
- package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.d.ts +6 -0
- package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.js +23 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.d.ts +12 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.js +10 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.d.ts +14 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.js +9 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.d.ts +11 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.js +5 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.d.ts +7 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.js +5 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.d.ts +19 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.js +50 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-ast.d.ts +12 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-ast.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-ast.js +24 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.d.ts +15 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.js +72 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.d.ts +7 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.js +20 -0
- package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.d.ts +14 -0
- package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.js +21 -0
- package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.d.ts +10 -0
- package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.js +21 -0
- package/dist/v2/features/collection/components/Editor/helpers/stringify-document.d.ts +10 -0
- package/dist/v2/features/collection/components/Editor/helpers/stringify-document.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/stringify-document.js +5 -0
- package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.d.ts +2 -0
- package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.js +11 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.d.ts +152 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.js +34 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.d.ts +14 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.js +25 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor.d.ts +39 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/hooks/use-editor.js +153 -0
- package/dist/v2/features/collection/components/Editor/index.d.ts +2 -0
- package/dist/v2/features/collection/components/Editor/index.d.ts.map +1 -0
- package/dist/v2/features/collection/components/Editor/index.js +4 -0
- package/dist/v2/features/collection/components/Editor/schemas/openapi-3.1-schema.json.js +25 -0
- package/dist/v2/features/collection/components/Environment.vue.js +8 -6
- package/dist/v2/features/collection/components/Overview.vue2.js +16 -14
- package/dist/v2/features/collection/components/Servers.vue.js +18 -16
- package/dist/v2/features/collection/components/Settings.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.js +6 -4
- package/dist/v2/features/collection/components/Tabs.vue.js +4 -4
- package/dist/v2/features/operation/Operation.vue.js +9 -7
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +32 -25
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import { isDefined as
|
|
2
|
-
import { sortByOrder as
|
|
3
|
-
import { migrateLocalStorageToIndexDb as
|
|
4
|
-
import { createSidebarState as
|
|
5
|
-
import { createWorkspaceStore as
|
|
6
|
-
import { createWorkspaceEventBus as
|
|
7
|
-
import { generateUniqueValue as
|
|
1
|
+
import { isDefined as j } from "@scalar/helpers/array/is-defined";
|
|
2
|
+
import { sortByOrder as he } from "@scalar/helpers/array/sort-by-order";
|
|
3
|
+
import { migrateLocalStorageToIndexDb as we } from "@scalar/oas-utils/migrations";
|
|
4
|
+
import { createSidebarState as ge, generateReverseIndex as ke } from "@scalar/sidebar";
|
|
5
|
+
import { createWorkspaceStore as H } from "@scalar/workspace-store/client";
|
|
6
|
+
import { createWorkspaceEventBus as xe } from "@scalar/workspace-store/events";
|
|
7
|
+
import { generateUniqueValue as be } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
8
8
|
import { getParentEntry as h } from "@scalar/workspace-store/navigation";
|
|
9
|
-
import { createWorkspaceStorePersistence as
|
|
10
|
-
import { persistencePlugin as
|
|
11
|
-
import { extensions as
|
|
12
|
-
import { ref as p, computed as i, shallowRef as
|
|
9
|
+
import { createWorkspaceStorePersistence as ye, getWorkspaceId as w } from "@scalar/workspace-store/persistence";
|
|
10
|
+
import { persistencePlugin as Se } from "@scalar/workspace-store/plugins/client";
|
|
11
|
+
import { extensions as Ee } from "@scalar/workspace-store/schemas/extensions";
|
|
12
|
+
import { ref as p, computed as i, shallowRef as z, readonly as We } from "vue";
|
|
13
13
|
import { getRouteParam as l } from "./helpers/get-route-param.js";
|
|
14
|
-
import { groupWorkspacesByTeam as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
14
|
+
import { groupWorkspacesByTeam as Te } from "./helpers/group-workspaces.js";
|
|
15
|
+
import { useTheme as Ue } from "./hooks/use-theme.js";
|
|
16
|
+
import { getActiveEnvironment as Ie } from "../../helpers/get-active-environment.js";
|
|
17
|
+
import { getTabDetails as De } from "../../helpers/get-tab-details.js";
|
|
18
|
+
import { slugify as Re } from "../../helpers/slugify.js";
|
|
19
|
+
import { workspaceStorage as Ae } from "../../helpers/storage.js";
|
|
20
|
+
import { initializeAppEventHandlers as Ce } from "./app-events.js";
|
|
21
|
+
import { filterWorkspacesByTeam as Be, canLoadWorkspace as G } from "./helpers/filter-workspaces.js";
|
|
22
|
+
const Le = 1e3, Ne = 288, na = async ({
|
|
22
23
|
router: u,
|
|
23
|
-
fileLoader:
|
|
24
|
+
fileLoader: J,
|
|
25
|
+
fallbackThemeSlug: Q = "default",
|
|
26
|
+
customThemes: B = () => []
|
|
24
27
|
}) => {
|
|
25
|
-
const S =
|
|
28
|
+
const S = xe({
|
|
26
29
|
debug: !1
|
|
27
|
-
}), { workspace: g } = await
|
|
28
|
-
await
|
|
29
|
-
const k = p("local"), f = p(void 0), x = p(void 0), E = p(void 0),
|
|
30
|
-
u.afterEach((e) =>
|
|
31
|
-
const d = i(() => u.currentRoute.value ?? null),
|
|
30
|
+
}), { workspace: g } = await ye();
|
|
31
|
+
await we();
|
|
32
|
+
const k = p("local"), f = p(void 0), x = p(void 0), E = p(void 0), L = p(void 0), N = p(void 0), O = p(void 0), W = p(!1);
|
|
33
|
+
u.afterEach((e) => de(e));
|
|
34
|
+
const d = i(() => u.currentRoute.value ?? null), T = z(null), v = p([]), b = i(() => Be(v.value, k.value)), X = i(() => Te(b.value, k.value)), s = z(null), D = i(() => s.value?.workspace.documents[E.value ?? ""] || null), Z = i(() => Ie(s.value, D.value));
|
|
32
35
|
v.value = await g.getAll().then(
|
|
33
36
|
(e) => e.map(({ teamUid: a, namespace: t, slug: n, name: c }) => ({
|
|
34
37
|
id: w(t, n),
|
|
@@ -38,41 +41,41 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
38
41
|
label: c
|
|
39
42
|
}))
|
|
40
43
|
);
|
|
41
|
-
const
|
|
44
|
+
const ee = async (e) => {
|
|
42
45
|
const a = f.value, t = x.value;
|
|
43
46
|
if (!a || !t)
|
|
44
47
|
return;
|
|
45
48
|
const n = w(a, t);
|
|
46
|
-
await g.updateName({ namespace: a, slug: t }, e) !== void 0 && (v.value = v.value.map((r) => r.id === n ? { ...r, label: e } : r),
|
|
47
|
-
},
|
|
49
|
+
await g.updateName({ namespace: a, slug: t }, e) !== void 0 && (v.value = v.value.map((r) => r.id === n ? { ...r, label: e } : r), T.value = { id: n, label: e });
|
|
50
|
+
}, ae = async ({
|
|
48
51
|
namespace: e,
|
|
49
52
|
slug: a
|
|
50
|
-
}) =>
|
|
53
|
+
}) => H({
|
|
51
54
|
plugins: [
|
|
52
|
-
await
|
|
55
|
+
await Se({
|
|
53
56
|
workspaceId: w(e, a),
|
|
54
|
-
debounceDelay:
|
|
57
|
+
debounceDelay: Le
|
|
55
58
|
})
|
|
56
59
|
],
|
|
57
|
-
fileLoader:
|
|
58
|
-
}),
|
|
60
|
+
fileLoader: J
|
|
61
|
+
}), te = async (e, a) => {
|
|
59
62
|
const t = await g.getItem({ namespace: e, slug: a });
|
|
60
63
|
if (!t)
|
|
61
64
|
return {
|
|
62
65
|
success: !1
|
|
63
66
|
};
|
|
64
|
-
const n = await
|
|
65
|
-
return n.loadWorkspace(t.workspace),
|
|
67
|
+
const n = await ae({ namespace: e, slug: a });
|
|
68
|
+
return n.loadWorkspace(t.workspace), T.value = { id: w(t.namespace, t.slug), label: t.name }, s.value = n, {
|
|
66
69
|
success: !0,
|
|
67
70
|
workspace: n.workspace
|
|
68
71
|
};
|
|
69
|
-
},
|
|
72
|
+
}, ne = async ({
|
|
70
73
|
name: e,
|
|
71
74
|
teamUid: a,
|
|
72
75
|
namespace: t,
|
|
73
76
|
slug: n
|
|
74
77
|
}) => {
|
|
75
|
-
const c =
|
|
78
|
+
const c = H();
|
|
76
79
|
await c.addDocument({
|
|
77
80
|
name: "drafts",
|
|
78
81
|
document: {
|
|
@@ -121,36 +124,36 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
121
124
|
exampleName: "default"
|
|
122
125
|
}
|
|
123
126
|
});
|
|
124
|
-
},
|
|
127
|
+
}, _ = async ({
|
|
125
128
|
teamUid: e,
|
|
126
129
|
namespace: a,
|
|
127
130
|
slug: t,
|
|
128
131
|
name: n
|
|
129
132
|
}) => {
|
|
130
133
|
s.value = null;
|
|
131
|
-
const c = await
|
|
134
|
+
const c = await be({
|
|
132
135
|
defaultValue: t ?? n,
|
|
133
136
|
// Use the provided id if it exists, otherwise use the name
|
|
134
|
-
validation: async (
|
|
137
|
+
validation: async (I) => !await g.has({ namespace: a ?? "local", slug: I }),
|
|
135
138
|
maxRetries: 100,
|
|
136
|
-
transformation:
|
|
139
|
+
transformation: Re
|
|
137
140
|
});
|
|
138
141
|
if (!c)
|
|
139
142
|
return;
|
|
140
|
-
const m = await
|
|
143
|
+
const m = await ne({
|
|
141
144
|
teamUid: e,
|
|
142
145
|
namespace: a,
|
|
143
146
|
slug: c,
|
|
144
147
|
name: n
|
|
145
148
|
});
|
|
146
149
|
return await y(m.namespace, m.slug), m;
|
|
147
|
-
},
|
|
150
|
+
}, se = async (e, a) => {
|
|
148
151
|
s.value = null, W.value = !0;
|
|
149
|
-
const t = await
|
|
152
|
+
const t = await te(e, a);
|
|
150
153
|
if (t.success) {
|
|
151
|
-
const r = t.workspace["x-scalar-active-tab"] ?? 0, m = t.workspace["x-scalar-tabs"],
|
|
152
|
-
|
|
153
|
-
path:
|
|
154
|
+
const r = t.workspace["x-scalar-active-tab"] ?? 0, m = t.workspace["x-scalar-tabs"], I = m?.[r];
|
|
155
|
+
I && await u.replace({
|
|
156
|
+
path: I.path,
|
|
154
157
|
query: d.value?.query ?? {}
|
|
155
158
|
}), m && r >= m.length && S.emit("tabs:update:tabs", {
|
|
156
159
|
"x-scalar-active-tab": 0
|
|
@@ -163,34 +166,34 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
163
166
|
const n = b.value.find((r) => r.teamUid === "local" && r.slug === "default") ?? b.value[0];
|
|
164
167
|
if (n)
|
|
165
168
|
return y(n.namespace, n.slug);
|
|
166
|
-
const c = await
|
|
169
|
+
const c = await _({
|
|
167
170
|
name: "Default Workspace",
|
|
168
171
|
slug: "default"
|
|
169
172
|
});
|
|
170
173
|
if (W.value = !1, !c)
|
|
171
174
|
return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
|
|
172
175
|
o.reset();
|
|
173
|
-
},
|
|
176
|
+
}, oe = (e) => {
|
|
174
177
|
k.value = e;
|
|
175
178
|
const a = b.value.find(
|
|
176
179
|
(t) => t.namespace === f.value && t.slug === x.value
|
|
177
180
|
);
|
|
178
|
-
if (!(a &&
|
|
181
|
+
if (!(a && G(a.teamUid, e)))
|
|
179
182
|
return y("local", "default");
|
|
180
|
-
},
|
|
183
|
+
}, P = i(() => {
|
|
181
184
|
const e = s.value;
|
|
182
185
|
if (!e)
|
|
183
186
|
return [];
|
|
184
187
|
const a = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
185
|
-
return
|
|
186
|
-
}), o =
|
|
188
|
+
return he(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(j);
|
|
189
|
+
}), o = ge(P), R = ({
|
|
187
190
|
document: e,
|
|
188
191
|
path: a,
|
|
189
192
|
method: t,
|
|
190
193
|
example: n
|
|
191
|
-
}) => JSON.stringify([e, a, t, n].filter(
|
|
192
|
-
() =>
|
|
193
|
-
items:
|
|
194
|
+
}) => JSON.stringify([e, a, t, n].filter(j)), V = i(
|
|
195
|
+
() => ke({
|
|
196
|
+
items: P.value,
|
|
194
197
|
nestedKey: "children",
|
|
195
198
|
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
196
199
|
getId: (e) => {
|
|
@@ -203,16 +206,16 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
203
206
|
});
|
|
204
207
|
}
|
|
205
208
|
})
|
|
206
|
-
),
|
|
207
|
-
const a =
|
|
208
|
-
return a ||
|
|
209
|
+
), U = (e) => {
|
|
210
|
+
const a = V.value.get(R(e));
|
|
211
|
+
return a || V.value.get(
|
|
209
212
|
R({
|
|
210
213
|
document: e.document,
|
|
211
214
|
path: e.path,
|
|
212
215
|
method: e.method
|
|
213
216
|
})
|
|
214
217
|
);
|
|
215
|
-
},
|
|
218
|
+
}, F = (e) => {
|
|
216
219
|
const a = o.getEntryById(e);
|
|
217
220
|
if (!a) {
|
|
218
221
|
console.warn(`Could not find sidebar entry with id ${e} to select`);
|
|
@@ -265,38 +268,38 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
265
268
|
}
|
|
266
269
|
});
|
|
267
270
|
o.setExpanded(e, !o.isExpanded(e));
|
|
268
|
-
},
|
|
271
|
+
}, re = async () => {
|
|
269
272
|
if (!s.value)
|
|
270
273
|
return;
|
|
271
274
|
const e = s.value.workspace["x-scalar-active-tab"] ?? 0, a = s.value.workspace["x-scalar-tabs"]?.[e];
|
|
272
275
|
a && await u.replace(a.path);
|
|
273
|
-
},
|
|
276
|
+
}, K = (e) => {
|
|
274
277
|
e && s.value?.buildSidebar(e);
|
|
275
|
-
},
|
|
278
|
+
}, ce = (e) => {
|
|
276
279
|
const a = D.value?.["x-scalar-navigation"]?.name;
|
|
277
280
|
if (!a)
|
|
278
281
|
return;
|
|
279
|
-
const t =
|
|
282
|
+
const t = U({
|
|
280
283
|
document: a,
|
|
281
284
|
path: e.path,
|
|
282
285
|
method: e.method,
|
|
283
286
|
example: e.exampleKey
|
|
284
287
|
});
|
|
285
|
-
(!t || t.type !== "example") && (
|
|
286
|
-
},
|
|
288
|
+
(!t || t.type !== "example") && (K(a), d.value && M(d.value));
|
|
289
|
+
}, le = i(() => s.value?.workspace?.["x-scalar-sidebar-width"] ?? Ne), ue = (e) => s.value?.update("x-scalar-sidebar-width", e), A = p(!0), ie = "x-scalar-tabs", pe = "x-scalar-active-tab", C = (e) => {
|
|
287
290
|
const a = l("method", e), t = l("pathEncoded", e), n = l("documentSlug", e), c = l("workspaceSlug", e);
|
|
288
291
|
return {
|
|
289
|
-
...
|
|
292
|
+
...De({
|
|
290
293
|
workspace: c,
|
|
291
294
|
document: n,
|
|
292
295
|
path: t,
|
|
293
296
|
method: a,
|
|
294
|
-
getEntryByLocation:
|
|
297
|
+
getEntryByLocation: U
|
|
295
298
|
}),
|
|
296
299
|
path: d.value?.path ?? ""
|
|
297
300
|
};
|
|
298
|
-
},
|
|
299
|
-
const a =
|
|
301
|
+
}, $ = i(() => s.value?.workspace[ie] ?? [C(d.value)]), me = i(() => s.value?.workspace[pe] ?? 0), q = async (e) => {
|
|
302
|
+
const a = $.value[e];
|
|
300
303
|
if (!a) {
|
|
301
304
|
console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
|
|
302
305
|
return;
|
|
@@ -307,28 +310,28 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
307
310
|
} catch (n) {
|
|
308
311
|
console.error("Failed to copy URL to clipboard:", n);
|
|
309
312
|
}
|
|
310
|
-
},
|
|
313
|
+
}, de = (e) => {
|
|
311
314
|
const a = l("workspaceSlug", e), t = l("documentSlug", e), n = l("namespace", e);
|
|
312
315
|
if (!n || !a)
|
|
313
316
|
return;
|
|
314
317
|
const c = v.value.find(
|
|
315
318
|
(r) => r.slug === a && r.namespace === n
|
|
316
319
|
);
|
|
317
|
-
if (c && !
|
|
320
|
+
if (c && !G(c.teamUid, k.value))
|
|
318
321
|
return y("local", "default");
|
|
319
|
-
if (f.value = n, x.value = a, E.value = t,
|
|
320
|
-
return
|
|
321
|
-
t && t !== s.value?.workspace[
|
|
322
|
-
},
|
|
322
|
+
if (f.value = n, x.value = a, E.value = t, L.value = l("method", e), N.value = l("pathEncoded", e), O.value = l("exampleName", e), e.path !== "" && Ae.setCurrentPath(e.path), w(f.value, a) !== T.value?.id)
|
|
323
|
+
return se(f.value, a);
|
|
324
|
+
t && t !== s.value?.workspace[Ee.workspace.activeDocument] && s?.value?.update("x-scalar-active-document", t), ve(e), M(e);
|
|
325
|
+
}, ve = (e) => {
|
|
323
326
|
const a = s.value?.workspace["x-scalar-tabs"] ?? [], t = s.value?.workspace["x-scalar-active-tab"] ?? 0, n = a[t];
|
|
324
327
|
!n || n.path === e.path || (a[t] = C(e));
|
|
325
|
-
},
|
|
328
|
+
}, M = (e) => {
|
|
326
329
|
const a = l("documentSlug", e);
|
|
327
330
|
if (!a) {
|
|
328
331
|
o.setSelected(null);
|
|
329
332
|
return;
|
|
330
333
|
}
|
|
331
|
-
const t =
|
|
334
|
+
const t = U({
|
|
332
335
|
document: a,
|
|
333
336
|
path: l("pathEncoded", e),
|
|
334
337
|
method: l("method", e),
|
|
@@ -336,19 +339,23 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
336
339
|
});
|
|
337
340
|
t && (o.setSelected(t.id), o.setExpanded(t.id, !0));
|
|
338
341
|
};
|
|
339
|
-
|
|
342
|
+
Ce({
|
|
340
343
|
eventBus: S,
|
|
341
344
|
router: u,
|
|
342
345
|
store: s,
|
|
343
|
-
navigateToCurrentTab:
|
|
344
|
-
rebuildSidebar:
|
|
345
|
-
onAfterExampleCreation:
|
|
346
|
-
onSelectSidebarItem:
|
|
347
|
-
onCopyTabUrl: (e) =>
|
|
346
|
+
navigateToCurrentTab: re,
|
|
347
|
+
rebuildSidebar: K,
|
|
348
|
+
onAfterExampleCreation: ce,
|
|
349
|
+
onSelectSidebarItem: F,
|
|
350
|
+
onCopyTabUrl: (e) => q(e),
|
|
348
351
|
onToggleSidebar: () => A.value = !A.value,
|
|
349
|
-
renameWorkspace:
|
|
352
|
+
renameWorkspace: ee
|
|
350
353
|
});
|
|
351
|
-
const
|
|
354
|
+
const Y = Ue({
|
|
355
|
+
fallbackThemeSlug: () => Q,
|
|
356
|
+
customThemes: B,
|
|
357
|
+
store: s
|
|
358
|
+
}), fe = i(() => {
|
|
352
359
|
const e = s.value?.workspace["x-scalar-color-mode"] ?? "system";
|
|
353
360
|
return e === "system" ? window.matchMedia?.("(prefers-color-scheme: dark)")?.matches ?? !1 : e === "dark";
|
|
354
361
|
});
|
|
@@ -357,23 +364,23 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
357
364
|
store: s,
|
|
358
365
|
sidebar: {
|
|
359
366
|
state: o,
|
|
360
|
-
width:
|
|
367
|
+
width: le,
|
|
361
368
|
isOpen: A,
|
|
362
|
-
handleSelectItem:
|
|
363
|
-
handleSidebarWidthUpdate:
|
|
364
|
-
getEntryByLocation:
|
|
369
|
+
handleSelectItem: F,
|
|
370
|
+
handleSidebarWidthUpdate: ue,
|
|
371
|
+
getEntryByLocation: U
|
|
365
372
|
},
|
|
366
373
|
tabs: {
|
|
367
|
-
state:
|
|
368
|
-
activeTabIndex:
|
|
369
|
-
copyTabUrl:
|
|
374
|
+
state: $,
|
|
375
|
+
activeTabIndex: me,
|
|
376
|
+
copyTabUrl: q
|
|
370
377
|
},
|
|
371
378
|
workspace: {
|
|
372
|
-
create:
|
|
379
|
+
create: _,
|
|
373
380
|
workspaceList: v,
|
|
374
381
|
filteredWorkspaceList: b,
|
|
375
|
-
workspaceGroups:
|
|
376
|
-
activeWorkspace:
|
|
382
|
+
workspaceGroups: X,
|
|
383
|
+
activeWorkspace: T,
|
|
377
384
|
navigateToWorkspace: y,
|
|
378
385
|
isOpen: i(() => !!(x.value && !E.value))
|
|
379
386
|
},
|
|
@@ -385,17 +392,22 @@ const Re = 1e3, Ae = 288, Xe = async ({
|
|
|
385
392
|
namespace: f,
|
|
386
393
|
workspaceSlug: x,
|
|
387
394
|
documentSlug: E,
|
|
388
|
-
path:
|
|
389
|
-
method:
|
|
390
|
-
exampleName:
|
|
391
|
-
teamUid:
|
|
392
|
-
setTeamUid:
|
|
395
|
+
path: N,
|
|
396
|
+
method: L,
|
|
397
|
+
exampleName: O,
|
|
398
|
+
teamUid: We(k),
|
|
399
|
+
setTeamUid: oe
|
|
393
400
|
},
|
|
394
|
-
environment:
|
|
401
|
+
environment: Z,
|
|
395
402
|
document: D,
|
|
396
|
-
isDarkMode:
|
|
403
|
+
isDarkMode: fe,
|
|
404
|
+
theme: {
|
|
405
|
+
styles: Y.themeStyles,
|
|
406
|
+
themeStyleTag: Y.themeStyleTag,
|
|
407
|
+
customThemes: B
|
|
408
|
+
}
|
|
397
409
|
};
|
|
398
410
|
};
|
|
399
411
|
export {
|
|
400
|
-
|
|
412
|
+
na as createAppState
|
|
401
413
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-api-client-app.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAO3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,sBAAsB,CAAC,QAAQ,CAAC,gCAQvE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,WAAW,GAAG,IAAI,EACtB,sDAA8E,sBAAsB;;;
|
|
1
|
+
{"version":3,"file":"create-api-client-app.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAO3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,sBAAsB,CAAC,QAAQ,CAAC,gCAQvE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,WAAW,GAAG,IAAI,EACtB,sDAA8E,sBAAsB;;;cAgCrG,CAAA"}
|
|
@@ -6,11 +6,9 @@ import { createAppState as A } from "../app-state.js";
|
|
|
6
6
|
import { ROUTES as c } from "./routes.js";
|
|
7
7
|
import { useCommandPaletteState as h } from "../../command-palette/hooks/use-command-palette-state.js";
|
|
8
8
|
const S = (t) => t === "web" ? p({ history: u(), routes: c }) : p({ history: d(), routes: c }), k = async (t, { layout: r = "desktop", plugins: i, customThemes: m, fallbackThemeSlug: n = "default" }) => {
|
|
9
|
-
const o = S(r), a = await A({ router: o }), s = h(), e = l(f, {
|
|
9
|
+
const o = S(r), a = await A({ router: o, customThemes: m, fallbackThemeSlug: n }), s = h(), e = l(f, {
|
|
10
10
|
layout: r,
|
|
11
11
|
plugins: i,
|
|
12
|
-
customThemes: m,
|
|
13
|
-
fallbackThemeSlug: n,
|
|
14
12
|
getAppState: () => a,
|
|
15
13
|
getCommandPaletteState: () => s
|
|
16
14
|
});
|
|
@@ -9,22 +9,39 @@ import type { MergedSecuritySchemes } from '../../../../v2/blocks/scalar-auth-se
|
|
|
9
9
|
import type { ClientLayout } from '../../../../v2/types/layout';
|
|
10
10
|
/** These props are provided at the route level */
|
|
11
11
|
export type RouteProps = {
|
|
12
|
+
/** The slug of the currently selected document in the workspace */
|
|
12
13
|
documentSlug: string;
|
|
14
|
+
/** The currently active document */
|
|
13
15
|
document: WorkspaceDocument | null;
|
|
16
|
+
/** The workspace event bus */
|
|
14
17
|
eventBus: WorkspaceEventBus;
|
|
18
|
+
/** The layout of the client */
|
|
15
19
|
layout: ClientLayout;
|
|
20
|
+
/** The API path currently selected (e.g. "/users/{id}") */
|
|
16
21
|
path?: string;
|
|
22
|
+
/** The HTTP method for the currently selected API path (e.g. GET, POST) */
|
|
17
23
|
method?: HttpMethod;
|
|
24
|
+
/** The name of the currently selected example (for examples within an endpoint) */
|
|
18
25
|
exampleName?: string;
|
|
26
|
+
/** The currently active environment */
|
|
19
27
|
environment: XScalarEnvironment;
|
|
28
|
+
/** The merged security schemes */
|
|
20
29
|
securitySchemes: MergedSecuritySchemes;
|
|
30
|
+
/** The workspace store */
|
|
21
31
|
workspaceStore: WorkspaceStore;
|
|
32
|
+
/** The currently active workspace */
|
|
22
33
|
activeWorkspace: {
|
|
23
34
|
id: string;
|
|
24
35
|
label: string;
|
|
25
36
|
};
|
|
37
|
+
/** Client plugins */
|
|
26
38
|
plugins: ClientPlugin[];
|
|
39
|
+
/** Custom themes available to the team */
|
|
27
40
|
customThemes?: Theme[];
|
|
41
|
+
/** The currently selected theme styles string */
|
|
42
|
+
currentTheme?: string;
|
|
43
|
+
/** Whether the current color mode is dark */
|
|
44
|
+
isDarkMode?: boolean;
|
|
28
45
|
};
|
|
29
46
|
/** When in the collections pages */
|
|
30
47
|
export type CollectionProps = RouteProps & ({
|
|
@@ -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,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAGlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAA;
|
|
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,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAGlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAA;AAa1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,kDAAkD;AAClD,MAAM,MAAM,UAAU,GAAG;IACvB,mEAAmE;IACnE,YAAY,EAAE,MAAM,CAAA;IACpB,oCAAoC;IACpC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,8BAA8B;IAC9B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,+BAA+B;IAC/B,MAAM,EAAE,YAAY,CAAA;IACpB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2EAA2E;IAC3E,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,WAAW,EAAE,kBAAkB,CAAA;IAC/B,kCAAkC;IAClC,eAAe,EAAE,qBAAqB,CAAA;IACtC,0BAA0B;IAC1B,cAAc,EAAE,cAAc,CAAA;IAC9B,qCAAqC;IACrC,eAAe,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C,qBAAqB;IACrB,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,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;;;;;;;;;IAmKM,CAAA"}
|
|
@@ -10,7 +10,8 @@ import v from "../../collection/OperationCollection.vue.js";
|
|
|
10
10
|
import f from "../../collection/WorkspaceCollection.vue.js";
|
|
11
11
|
import { workspaceStorage as p } from "../../../helpers/storage.js";
|
|
12
12
|
import l from "../../operation/Operation.vue.js";
|
|
13
|
-
|
|
13
|
+
import w from "../../collection/components/Editor/Editor.vue.js";
|
|
14
|
+
const O = [
|
|
14
15
|
{
|
|
15
16
|
path: "/@:namespace/:workspaceSlug",
|
|
16
17
|
children: [
|
|
@@ -48,6 +49,11 @@ const R = [
|
|
|
48
49
|
name: "operation.authentication",
|
|
49
50
|
path: "authentication",
|
|
50
51
|
component: o
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "operation.editor",
|
|
55
|
+
path: "editor",
|
|
56
|
+
component: w
|
|
51
57
|
}
|
|
52
58
|
]
|
|
53
59
|
}
|
|
@@ -146,5 +152,5 @@ const R = [
|
|
|
146
152
|
}
|
|
147
153
|
];
|
|
148
154
|
export {
|
|
149
|
-
|
|
155
|
+
O as ROUTES
|
|
150
156
|
};
|
|
@@ -37,6 +37,20 @@ export declare const useTheme: ({ fallbackThemeSlug, store, customThemes, }: {
|
|
|
37
37
|
fallbackThemeSlug: MaybeRefOrGetter<string>;
|
|
38
38
|
store: MaybeRefOrGetter<WorkspaceStore | null>;
|
|
39
39
|
}) => {
|
|
40
|
+
/**
|
|
41
|
+
* Computed ref containing the resolved theme styles object
|
|
42
|
+
* for the currently active theme. Always returns a style object,
|
|
43
|
+
* never null, with proper fallback logic if custom or workspace themes are missing.
|
|
44
|
+
*/
|
|
45
|
+
themeStyles: import("vue").ComputedRef<{
|
|
46
|
+
themeStyles: string;
|
|
47
|
+
themeSlug: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Computed ref containing a <style> tag as a string,
|
|
51
|
+
* ready to be injected into the DOM.
|
|
52
|
+
* This wraps the currently active theme CSS variables/styles.
|
|
53
|
+
*/
|
|
40
54
|
themeStyleTag: import("vue").ComputedRef<string>;
|
|
41
55
|
};
|
|
42
56
|
//# sourceMappingURL=use-theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/hooks/use-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAA8B,MAAM,gBAAgB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,KAAK,CAAA;AAkC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,QAAQ,GAAI,6CAItB;IACD,YAAY,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAA;IACvC,iBAAiB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC3C,KAAK,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;CAC/C;;
|
|
1
|
+
{"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/hooks/use-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAA8B,MAAM,gBAAgB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,KAAK,CAAA;AAkC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,QAAQ,GAAI,6CAItB;IACD,YAAY,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAA;IACvC,iBAAiB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC3C,KAAK,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;CAC/C;IA6CG;;;;OAIG;;qBAhDuC,MAAM;mBAAa,MAAM;;IAmDnE;;;;OAIG;;CAGN,CAAA"}
|
|
@@ -1,34 +1,48 @@
|
|
|
1
|
-
import { themePresets as
|
|
2
|
-
import { computed as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
${
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
1
|
+
import { themePresets as p, defaultFonts as g } from "@scalar/themes";
|
|
2
|
+
import { computed as d, toValue as a } from "vue";
|
|
3
|
+
const i = new Map(p.map((e) => [e.slug, e])), T = (e, l = "scalar-theme") => `<style id="scalar-theme" data-testid="${l}">${e}</style>`, o = (e, l) => {
|
|
4
|
+
const t = (r) => `${r}
|
|
5
|
+
${g}`;
|
|
6
|
+
if (i.has(e))
|
|
7
|
+
return t(i.get(e)?.theme ?? "");
|
|
8
|
+
const s = l.find((r) => r.slug === e);
|
|
9
|
+
if (s)
|
|
10
|
+
return t(s.theme);
|
|
11
11
|
}, w = ({
|
|
12
12
|
fallbackThemeSlug: e,
|
|
13
|
-
store:
|
|
14
|
-
customThemes:
|
|
15
|
-
}) =>
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
22
|
-
const
|
|
23
|
-
return
|
|
13
|
+
store: l,
|
|
14
|
+
customThemes: t
|
|
15
|
+
}) => {
|
|
16
|
+
const s = d(() => {
|
|
17
|
+
const u = { themeStyles: o("default", []), themeSlug: "default" }, c = a(l), n = a(e);
|
|
18
|
+
if (c === null)
|
|
19
|
+
return u;
|
|
20
|
+
const h = c.workspace["x-scalar-theme"], m = h === "none" ? n : h;
|
|
21
|
+
if (!m) {
|
|
22
|
+
const y = o(n, a(t));
|
|
23
|
+
return y ? { themeStyles: y, themeSlug: n } : u;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
})
|
|
31
|
-
|
|
25
|
+
const S = o(m, a(t));
|
|
26
|
+
if (S)
|
|
27
|
+
return { themeStyles: S, themeSlug: m };
|
|
28
|
+
const f = o(n, a(t));
|
|
29
|
+
return f ? { themeStyles: f, themeSlug: n } : u;
|
|
30
|
+
}), r = d(() => T(s.value.themeStyles, s.value.themeSlug));
|
|
31
|
+
return {
|
|
32
|
+
/**
|
|
33
|
+
* Computed ref containing the resolved theme styles object
|
|
34
|
+
* for the currently active theme. Always returns a style object,
|
|
35
|
+
* never null, with proper fallback logic if custom or workspace themes are missing.
|
|
36
|
+
*/
|
|
37
|
+
themeStyles: s,
|
|
38
|
+
/**
|
|
39
|
+
* Computed ref containing a <style> tag as a string,
|
|
40
|
+
* ready to be injected into the DOM.
|
|
41
|
+
* This wraps the currently active theme CSS variables/styles.
|
|
42
|
+
*/
|
|
43
|
+
themeStyleTag: r
|
|
44
|
+
};
|
|
45
|
+
};
|
|
32
46
|
export {
|
|
33
47
|
w as useTheme
|
|
34
48
|
};
|