@scalar/api-client 2.32.0 → 2.34.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 (114) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/assets/yaml.worker-CcQnAKCg.js +490 -0
  3. package/dist/style.css +1 -1
  4. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  5. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
  6. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js +45 -39
  7. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
  8. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js +41 -34
  9. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +6 -2
  10. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
  11. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +66 -66
  12. package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts +2 -2
  13. package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts.map +1 -1
  14. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts +1 -0
  15. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
  16. package/dist/v2/features/app/App.vue.d.ts +0 -5
  17. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  18. package/dist/v2/features/app/App.vue.js +57 -60
  19. package/dist/v2/features/app/app-state.d.ts +17 -2
  20. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  21. package/dist/v2/features/app/app-state.js +114 -102
  22. package/dist/v2/features/app/helpers/create-api-client-app.d.ts +1 -1
  23. package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
  24. package/dist/v2/features/app/helpers/create-api-client-app.js +2 -4
  25. package/dist/v2/features/app/helpers/routes.d.ts +17 -0
  26. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  27. package/dist/v2/features/app/helpers/routes.js +8 -2
  28. package/dist/v2/features/app/hooks/use-theme.d.ts +14 -0
  29. package/dist/v2/features/app/hooks/use-theme.d.ts.map +1 -1
  30. package/dist/v2/features/app/hooks/use-theme.js +42 -28
  31. package/dist/v2/features/collection/DocumentCollection.vue.js +8 -6
  32. package/dist/v2/features/collection/OperationCollection.vue.js +14 -12
  33. package/dist/v2/features/collection/WorkspaceCollection.vue.js +9 -7
  34. package/dist/v2/features/collection/components/Authentication.vue2.js +19 -17
  35. package/dist/v2/features/collection/components/Cookies.vue.js +10 -8
  36. package/dist/v2/features/collection/components/Editor/Editor.vue.d.ts +16 -0
  37. package/dist/v2/features/collection/components/Editor/Editor.vue.d.ts.map +1 -0
  38. package/dist/v2/features/collection/components/Editor/Editor.vue.js +7 -0
  39. package/dist/v2/features/collection/components/Editor/Editor.vue2.js +333 -0
  40. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.d.ts +19 -0
  41. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.d.ts.map +1 -0
  42. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.js +78 -0
  43. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue2.js +4 -0
  44. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.d.ts +16 -0
  45. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.d.ts.map +1 -0
  46. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.js +83 -0
  47. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue2.js +4 -0
  48. package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.d.ts +16 -0
  49. package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.d.ts.map +1 -0
  50. package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.js +56 -0
  51. package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.d.ts +7 -0
  52. package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.d.ts.map +1 -0
  53. package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.js +40 -0
  54. package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.d.ts +6 -0
  55. package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.d.ts.map +1 -0
  56. package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.js +23 -0
  57. package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.d.ts +12 -0
  58. package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.d.ts.map +1 -0
  59. package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.js +10 -0
  60. package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.d.ts +14 -0
  61. package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.d.ts.map +1 -0
  62. package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.js +9 -0
  63. package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.d.ts +11 -0
  64. package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.d.ts.map +1 -0
  65. package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.js +5 -0
  66. package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.d.ts +7 -0
  67. package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.d.ts.map +1 -0
  68. package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.js +5 -0
  69. package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.d.ts +19 -0
  70. package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.d.ts.map +1 -0
  71. package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.js +50 -0
  72. package/dist/v2/features/collection/components/Editor/helpers/json-ast.d.ts +12 -0
  73. package/dist/v2/features/collection/components/Editor/helpers/json-ast.d.ts.map +1 -0
  74. package/dist/v2/features/collection/components/Editor/helpers/json-ast.js +24 -0
  75. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.d.ts +15 -0
  76. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.d.ts.map +1 -0
  77. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.js +72 -0
  78. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.d.ts +7 -0
  79. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.d.ts.map +1 -0
  80. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.js +20 -0
  81. package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.d.ts +14 -0
  82. package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.d.ts.map +1 -0
  83. package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.js +21 -0
  84. package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.d.ts +10 -0
  85. package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.d.ts.map +1 -0
  86. package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.js +21 -0
  87. package/dist/v2/features/collection/components/Editor/helpers/stringify-document.d.ts +10 -0
  88. package/dist/v2/features/collection/components/Editor/helpers/stringify-document.d.ts.map +1 -0
  89. package/dist/v2/features/collection/components/Editor/helpers/stringify-document.js +5 -0
  90. package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.d.ts +2 -0
  91. package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.d.ts.map +1 -0
  92. package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.js +11 -0
  93. package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.d.ts +152 -0
  94. package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.d.ts.map +1 -0
  95. package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.js +34 -0
  96. package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.d.ts +14 -0
  97. package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.d.ts.map +1 -0
  98. package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.js +25 -0
  99. package/dist/v2/features/collection/components/Editor/hooks/use-editor.d.ts +39 -0
  100. package/dist/v2/features/collection/components/Editor/hooks/use-editor.d.ts.map +1 -0
  101. package/dist/v2/features/collection/components/Editor/hooks/use-editor.js +153 -0
  102. package/dist/v2/features/collection/components/Editor/index.d.ts +2 -0
  103. package/dist/v2/features/collection/components/Editor/index.d.ts.map +1 -0
  104. package/dist/v2/features/collection/components/Editor/index.js +4 -0
  105. package/dist/v2/features/collection/components/Editor/schemas/openapi-3.1-schema.json.js +25 -0
  106. package/dist/v2/features/collection/components/Environment.vue.js +8 -6
  107. package/dist/v2/features/collection/components/Overview.vue2.js +16 -14
  108. package/dist/v2/features/collection/components/Servers.vue.js +18 -16
  109. package/dist/v2/features/collection/components/Settings.vue.d.ts.map +1 -1
  110. package/dist/v2/features/collection/components/Settings.vue.js +6 -4
  111. package/dist/v2/features/collection/components/Tabs.vue.js +4 -4
  112. package/dist/v2/features/operation/Operation.vue.js +9 -7
  113. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  114. package/package.json +20 -13
@@ -1,34 +1,37 @@
1
- import { isDefined as M } from "@scalar/helpers/array/is-defined";
2
- import { sortByOrder as de } from "@scalar/helpers/array/sort-by-order";
3
- import { migrateLocalStorageToIndexDb as ve } from "@scalar/oas-utils/migrations";
4
- import { createSidebarState as fe, generateReverseIndex as he } from "@scalar/sidebar";
5
- import { createWorkspaceStore as Y } from "@scalar/workspace-store/client";
6
- import { createWorkspaceEventBus as we } from "@scalar/workspace-store/events";
7
- import { generateUniqueValue as ge } from "@scalar/workspace-store/helpers/generate-unique-value";
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 ke, getWorkspaceId as w } from "@scalar/workspace-store/persistence";
10
- import { persistencePlugin as xe } from "@scalar/workspace-store/plugins/client";
11
- import { extensions as be } from "@scalar/workspace-store/schemas/extensions";
12
- import { ref as p, computed as i, shallowRef as j, readonly as ye } from "vue";
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 Se } from "./helpers/group-workspaces.js";
15
- import { getActiveEnvironment as Ee } from "../../helpers/get-active-environment.js";
16
- import { getTabDetails as We } from "../../helpers/get-tab-details.js";
17
- import { slugify as Ue } from "../../helpers/slugify.js";
18
- import { workspaceStorage as Ie } from "../../helpers/storage.js";
19
- import { initializeAppEventHandlers as Te } from "./app-events.js";
20
- import { filterWorkspacesByTeam as De, canLoadWorkspace as H } from "./helpers/filter-workspaces.js";
21
- const Re = 1e3, Ae = 288, Xe = async ({
14
+ import { groupWorkspacesByTeam as Ue } from "./helpers/group-workspaces.js";
15
+ import { useTheme as Te } 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: z
24
+ fileLoader: J,
25
+ fallbackThemeSlug: Q = () => "default",
26
+ customThemes: B = () => []
24
27
  }) => {
25
- const S = we({
28
+ const S = xe({
26
29
  debug: !1
27
- }), { workspace: g } = await ke();
28
- await ve();
29
- const k = p("local"), f = p(void 0), x = p(void 0), E = p(void 0), B = p(void 0), L = p(void 0), N = p(void 0), W = p(!1);
30
- u.afterEach((e) => ie(e));
31
- const d = i(() => u.currentRoute.value ?? null), U = j(null), v = p([]), b = i(() => De(v.value, k.value)), G = i(() => Se(b.value, k.value)), s = j(null), D = i(() => s.value?.workspace.documents[E.value ?? ""] || null), J = i(() => Ee(s.value, D.value));
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), U = z(null), v = p([]), b = i(() => Be(v.value, k.value)), X = i(() => Ue(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 Q = async (e) => {
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
49
  await g.updateName({ namespace: a, slug: t }, e) !== void 0 && (v.value = v.value.map((r) => r.id === n ? { ...r, label: e } : r), U.value = { id: n, label: e });
47
- }, X = async ({
50
+ }, ae = async ({
48
51
  namespace: e,
49
52
  slug: a
50
- }) => Y({
53
+ }) => H({
51
54
  plugins: [
52
- await xe({
55
+ await Se({
53
56
  workspaceId: w(e, a),
54
- debounceDelay: Re
57
+ debounceDelay: Le
55
58
  })
56
59
  ],
57
- fileLoader: z
58
- }), Z = async (e, a) => {
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 X({ namespace: e, slug: a });
67
+ const n = await ae({ namespace: e, slug: a });
65
68
  return n.loadWorkspace(t.workspace), U.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
- }, ee = async ({
72
+ }, ne = async ({
70
73
  name: e,
71
74
  teamUid: a,
72
75
  namespace: t,
73
76
  slug: n
74
77
  }) => {
75
- const c = Y();
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
- }, O = async ({
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 ge({
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 (T) => !await g.has({ namespace: a ?? "local", slug: T }),
137
+ validation: async (I) => !await g.has({ namespace: a ?? "local", slug: I }),
135
138
  maxRetries: 100,
136
- transformation: Ue
139
+ transformation: Re
137
140
  });
138
141
  if (!c)
139
142
  return;
140
- const m = await ee({
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
- }, ae = async (e, a) => {
150
+ }, se = async (e, a) => {
148
151
  s.value = null, W.value = !0;
149
- const t = await Z(e, a);
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"], T = m?.[r];
152
- T && await u.replace({
153
- path: T.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 O({
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
- }, te = (e) => {
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 && H(a.teamUid, e)))
181
+ if (!(a && G(a.teamUid, e)))
179
182
  return y("local", "default");
180
- }, _ = i(() => {
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 de(Object.keys(e.workspace.documents), a, (t) => t).map((t) => e.workspace.documents[t]?.["x-scalar-navigation"]).filter(M);
186
- }), o = fe(_), R = ({
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(M)), P = i(
192
- () => he({
193
- items: _.value,
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
- ), I = (e) => {
207
- const a = P.value.get(R(e));
208
- return a || P.value.get(
209
+ ), T = (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
- }, V = (e) => {
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
- }, ne = async () => {
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
- }, F = (e) => {
276
+ }, K = (e) => {
274
277
  e && s.value?.buildSidebar(e);
275
- }, se = (e) => {
278
+ }, ce = (e) => {
276
279
  const a = D.value?.["x-scalar-navigation"]?.name;
277
280
  if (!a)
278
281
  return;
279
- const t = I({
282
+ const t = T({
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") && (F(a), d.value && q(d.value));
286
- }, oe = i(() => s.value?.workspace?.["x-scalar-sidebar-width"] ?? Ae), re = (e) => s.value?.update("x-scalar-sidebar-width", e), A = p(!0), ce = "x-scalar-tabs", le = "x-scalar-active-tab", C = (e) => {
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
- ...We({
292
+ ...De({
290
293
  workspace: c,
291
294
  document: n,
292
295
  path: t,
293
296
  method: a,
294
- getEntryByLocation: I
297
+ getEntryByLocation: T
295
298
  }),
296
299
  path: d.value?.path ?? ""
297
300
  };
298
- }, K = i(() => s.value?.workspace[ce] ?? [C(d.value)]), ue = i(() => s.value?.workspace[le] ?? 0), $ = async (e) => {
299
- const a = K.value[e];
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
- }, ie = (e) => {
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 && !H(c.teamUid, k.value))
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, B.value = l("method", e), L.value = l("pathEncoded", e), N.value = l("exampleName", e), e.path !== "" && Ie.setCurrentPath(e.path), w(f.value, a) !== U.value?.id)
320
- return ae(f.value, a);
321
- t && t !== s.value?.workspace[be.workspace.activeDocument] && s?.value?.update("x-scalar-active-document", t), pe(e), q(e);
322
- }, pe = (e) => {
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) !== U.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
- }, q = (e) => {
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 = I({
334
+ const t = T({
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
- Te({
342
+ Ce({
340
343
  eventBus: S,
341
344
  router: u,
342
345
  store: s,
343
- navigateToCurrentTab: ne,
344
- rebuildSidebar: F,
345
- onAfterExampleCreation: se,
346
- onSelectSidebarItem: V,
347
- onCopyTabUrl: (e) => $(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: Q
352
+ renameWorkspace: ee
350
353
  });
351
- const me = i(() => {
354
+ const Y = Te({
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,22 +364,22 @@ const Re = 1e3, Ae = 288, Xe = async ({
357
364
  store: s,
358
365
  sidebar: {
359
366
  state: o,
360
- width: oe,
367
+ width: le,
361
368
  isOpen: A,
362
- handleSelectItem: V,
363
- handleSidebarWidthUpdate: re,
364
- getEntryByLocation: I
369
+ handleSelectItem: F,
370
+ handleSidebarWidthUpdate: ue,
371
+ getEntryByLocation: T
365
372
  },
366
373
  tabs: {
367
- state: K,
368
- activeTabIndex: ue,
369
- copyTabUrl: $
374
+ state: $,
375
+ activeTabIndex: me,
376
+ copyTabUrl: q
370
377
  },
371
378
  workspace: {
372
- create: O,
379
+ create: _,
373
380
  workspaceList: v,
374
381
  filteredWorkspaceList: b,
375
- workspaceGroups: G,
382
+ workspaceGroups: X,
376
383
  activeWorkspace: U,
377
384
  navigateToWorkspace: y,
378
385
  isOpen: i(() => !!(x.value && !E.value))
@@ -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: L,
389
- method: B,
390
- exampleName: N,
391
- teamUid: ye(k),
392
- setTeamUid: te
395
+ path: N,
396
+ method: L,
397
+ exampleName: O,
398
+ teamUid: We(k),
399
+ setTeamUid: oe
393
400
  },
394
- environment: J,
401
+ environment: Z,
395
402
  document: D,
396
- isDarkMode: me
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
- Xe as createAppState
412
+ na as createAppState
401
413
  };
@@ -21,7 +21,7 @@ type CreateApiClientOptions = {
21
21
  * Fallback theme slug to use if no theme is selected for the workspace
22
22
  * @default 'default'
23
23
  */
24
- fallbackThemeSlug?: string;
24
+ fallbackThemeSlug?: () => string;
25
25
  };
26
26
  /**
27
27
  * Creates the appropriate router with the appropriate routes based on the layout
@@ -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;;;cAkCrG,CAAA"}
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,MAAM,CAAA;CACjC,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,sDAAkE,sBAAsB;;;cAgCzF,CAAA"}
@@ -5,12 +5,10 @@ import f from "../App.vue.js";
5
5
  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
- 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, {
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 }) => {
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;AAY1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,kDAAkD;AAClD,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,kBAAkB,CAAA;IAC/B,eAAe,EAAE,qBAAqB,CAAA;IACtC,cAAc,EAAE,cAAc,CAAA;IAC9B,eAAe,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;CAGvB,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;;;;;;;;;IA8JM,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
- const R = [
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
- R as ROUTES
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;;CA2CA,CAAA"}
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 y, defaultFonts as S } from "@scalar/themes";
2
- import { computed as T, toValue as a } from "vue";
3
- const p = new Map(y.map((e) => [e.slug, e])), l = (e, s = "scalar-theme") => `<style id="scalar-theme" data-testid="${s}">${e}</style>`, o = (e, s) => {
4
- const r = (t) => `${t}
5
- ${S}`;
6
- if (p.has(e))
7
- return r(p.get(e)?.theme ?? "");
8
- const c = s.find((t) => t.slug === e);
9
- if (c)
10
- return r(c.theme);
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: s,
14
- customThemes: r
15
- }) => ({
16
- themeStyleTag: T(() => {
17
- const t = l(o("default", []), "default"), m = a(s), n = a(e);
18
- if (m === null)
19
- return t;
20
- const f = m.workspace["x-scalar-theme"], u = f === "none" ? n : f;
21
- if (!u) {
22
- const i = o(n, a(r));
23
- return i ? l(i, n) : t;
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 h = o(u, a(r));
26
- if (h)
27
- return l(h, u);
28
- const d = o(n, a(r));
29
- return d ? l(d, n) : t;
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
  };