@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
@@ -0,0 +1,72 @@
1
+ import * as c from "monaco-editor";
2
+ import { parseJsonPointerPath as m } from "./json-pointer-path.js";
3
+ const d = "scalar-json-pointer", g = (r, o) => {
4
+ if (r[o] !== '"')
5
+ return !1;
6
+ let t = 0;
7
+ for (let e = o - 1; e >= 0 && r[e] === "\\"; e--)
8
+ t++;
9
+ return t % 2 === 0;
10
+ }, k = (r, o) => {
11
+ let t = -1;
12
+ for (let n = o; n >= 0; n--)
13
+ if (g(r, n)) {
14
+ t = n;
15
+ break;
16
+ }
17
+ if (t === -1)
18
+ return null;
19
+ let e = -1;
20
+ for (let n = Math.max(t + 1, o); n < r.length; n++)
21
+ if (g(r, n)) {
22
+ e = n;
23
+ break;
24
+ }
25
+ return e === -1 || e <= t ? null : { left: t, right: e };
26
+ }, b = (r) => {
27
+ c.languages.registerLinkProvider("json", {
28
+ provideLinks(e) {
29
+ const n = [], l = e.getLineCount();
30
+ for (let s = 1; s <= l; s++) {
31
+ const a = e.getLineContent(s);
32
+ let u = 0;
33
+ for (; ; ) {
34
+ const f = a.indexOf("#/", u);
35
+ if (f === -1)
36
+ break;
37
+ const i = k(a, f);
38
+ if (!i) {
39
+ u = f + 2;
40
+ continue;
41
+ }
42
+ const p = a.slice(i.left + 1, i.right);
43
+ if (!m(p)) {
44
+ u = i.right + 1;
45
+ continue;
46
+ }
47
+ const h = new c.Range(s, i.left + 2, s, i.right + 1);
48
+ n.push({
49
+ range: h,
50
+ url: c.Uri.parse(`${d}:${encodeURIComponent(p)}`),
51
+ tooltip: "Follow link"
52
+ }), u = i.right + 1;
53
+ }
54
+ }
55
+ return { links: n };
56
+ }
57
+ });
58
+ const o = c.editor.registerLinkOpener({
59
+ open(e) {
60
+ if (e.scheme !== d)
61
+ return !1;
62
+ const n = (e.path || "").replace(/^\//, ""), l = decodeURIComponent(n);
63
+ return l ? Promise.resolve(r(l)).then(() => !0) : !1;
64
+ }
65
+ });
66
+ return { linkOpener: o, dispose: () => {
67
+ o.dispose();
68
+ } };
69
+ };
70
+ export {
71
+ b as ensureJsonPointerLinkSupport
72
+ };
@@ -0,0 +1,7 @@
1
+ import type { JsonPath } from './json-ast.js';
2
+ /**
3
+ * Parses a JSON Pointer (RFC 6901) and returns a "JSON path" compatible with this editor.
4
+ * Supports raw pointers ("/paths/...") and URI fragments ("#/paths/...").
5
+ */
6
+ export declare const parseJsonPointerPath: (pointer: string) => JsonPath | null;
7
+ //# sourceMappingURL=json-pointer-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-pointer-path.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/helpers/json-pointer-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AA+B1C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,KAAG,QAAQ,GAAG,IAOjE,CAAA"}
@@ -0,0 +1,20 @@
1
+ const i = (e) => e.replace(/~1/g, "/").replace(/~0/g, "~"), c = (e) => {
2
+ const t = e.trim();
3
+ if (t.startsWith("/"))
4
+ return t;
5
+ if (t.startsWith("#")) {
6
+ const s = t.slice(1);
7
+ return s.startsWith("/") ? s : null;
8
+ }
9
+ const r = t.indexOf("#");
10
+ if (r === -1)
11
+ return null;
12
+ const n = t.slice(r + 1);
13
+ return n.startsWith("/") ? n : null;
14
+ }, o = (e) => {
15
+ const t = c(e);
16
+ return t ? t.split("/").slice(1).map(i) : null;
17
+ };
18
+ export {
19
+ o as parseJsonPointerPath
20
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Extracts CSS custom properties (variables) from a given CSS string
3
+ * for .light-mode and .dark-mode selectors and returns an object
4
+ * with 'light' and 'dark' keys containing the filtered variables.
5
+ * Only variables matching hex color values (#RRGGBB or #RRGGBBAA) are accepted.
6
+ *
7
+ * @param css - The CSS string to parse.
8
+ * @returns An object with `light` and `dark` properties containing the extracted CSS variables.
9
+ */
10
+ export declare const loadCssVariables: (css: string) => Promise<{
11
+ light: any;
12
+ dark: any;
13
+ }>;
14
+ //# sourceMappingURL=load-css-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-css-variables.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/helpers/load-css-variables.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM;WAIU,GAAG;UAAQ,GAAG;EA2CzE,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { z as n } from "zod";
2
+ const f = async (a) => {
3
+ const i = new CSSStyleSheet();
4
+ return await i.replace(a), Array.from(i.cssRules).reduce(
5
+ (e, r) => {
6
+ if (!(r instanceof CSSStyleRule))
7
+ return e;
8
+ const l = Object.values(r.style).reduce((t, s) => {
9
+ if (!s.startsWith("--"))
10
+ return t;
11
+ const o = n.string().regex(/^(?:#(?:[0-9A-F]{6}|[0-9A-F]{8}))$/i).safeParse(r.style.getPropertyValue(s).toUpperCase().trim());
12
+ return o.error || (t[s] = o.data), t;
13
+ }, {});
14
+ return r.selectorText.includes(".light-mode") && (e.light = { ...e.light, ...l }), r.selectorText.includes(".dark-mode") && (e.dark = { ...e.dark, ...l }), e;
15
+ },
16
+ { light: {}, dark: {} }
17
+ );
18
+ };
19
+ export {
20
+ f as loadCssVariables
21
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parses the editor value string in either JSON or YAML format.
3
+ * Returns the parsed object if valid and an object, otherwise returns null.
4
+ *
5
+ * @param value - The input string to parse.
6
+ * @param language - The language of the input string, either 'json' or 'yaml'.
7
+ * @returns The parsed object if it's valid, or null.
8
+ */
9
+ export declare const parseEditorObject: (value: string, language: "json" | "yaml") => Record<string, unknown> | null;
10
+ //# sourceMappingURL=parse-editor-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-editor-object.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/helpers/parse-editor-object.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,GAAG,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAOtG,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { isObject as n } from "@scalar/helpers/object/is-object";
2
+ import { parse as s } from "yaml";
3
+ const a = (r) => {
4
+ try {
5
+ return JSON.parse(r);
6
+ } catch {
7
+ return null;
8
+ }
9
+ }, o = (r) => {
10
+ try {
11
+ return s(r);
12
+ } catch {
13
+ return null;
14
+ }
15
+ }, l = (r, e) => {
16
+ const t = e === "yaml" ? o(r) : a(r);
17
+ return n(t) ? t : null;
18
+ };
19
+ export {
20
+ l as parseEditorObject
21
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Stringifies a JavaScript object/document into a formatted string.
3
+ * Uses YAML format if language is 'yaml', otherwise uses JSON.
4
+ *
5
+ * @param document - The JavaScript object to stringify
6
+ * @param language - Output language, expected to be either 'json' or 'yaml'
7
+ * @returns The stringified document in the specified language
8
+ */
9
+ export declare const stringifyDocument: (document: unknown, language: "json" | "yaml") => string;
10
+ //# sourceMappingURL=stringify-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-document.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/helpers/stringify-document.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,OAAO,EAAE,UAAU,MAAM,GAAG,MAAM,KAAG,MAMhF,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { stringify as n } from "yaml";
2
+ const f = (r, i) => i === "yaml" ? n(r, { indent: 2 }) : JSON.stringify(r, null, 2);
3
+ export {
4
+ f as stringifyDocument
5
+ };
@@ -0,0 +1,2 @@
1
+ import 'monaco-yaml/yaml.worker.js';
2
+ //# sourceMappingURL=yaml.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.worker.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/helpers/yaml.worker.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAA"}
@@ -0,0 +1,11 @@
1
+ function r(e) {
2
+ return new Worker(
3
+ "/assets/yaml.worker-CcQnAKCg.js",
4
+ {
5
+ name: e?.name
6
+ }
7
+ );
8
+ }
9
+ export {
10
+ r as default
11
+ };
@@ -0,0 +1,152 @@
1
+ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
2
+ import { type MaybeRefOrGetter } from 'vue';
3
+ export declare const useEditorMarkers: (editorRef: MaybeRefOrGetter<monaco.editor.IStandaloneCodeEditor | undefined>) => {
4
+ markers: import("vue").Ref<{
5
+ owner: string;
6
+ resource: {
7
+ readonly scheme: string;
8
+ readonly authority: string;
9
+ readonly path: string;
10
+ readonly query: string;
11
+ readonly fragment: string;
12
+ readonly fsPath: string;
13
+ with: (change: {
14
+ scheme?: string;
15
+ authority?: string | null;
16
+ path?: string | null;
17
+ query?: string | null;
18
+ fragment?: string | null;
19
+ }) => monaco.Uri;
20
+ toString: (skipEncoding?: boolean) => string;
21
+ toJSON: () => monaco.UriComponents;
22
+ };
23
+ severity: monaco.MarkerSeverity;
24
+ code?: string | {
25
+ value: string;
26
+ target: {
27
+ readonly scheme: string;
28
+ readonly authority: string;
29
+ readonly path: string;
30
+ readonly query: string;
31
+ readonly fragment: string;
32
+ readonly fsPath: string;
33
+ with: (change: {
34
+ scheme?: string;
35
+ authority?: string | null;
36
+ path?: string | null;
37
+ query?: string | null;
38
+ fragment?: string | null;
39
+ }) => monaco.Uri;
40
+ toString: (skipEncoding?: boolean) => string;
41
+ toJSON: () => monaco.UriComponents;
42
+ };
43
+ } | undefined;
44
+ message: string;
45
+ source?: string | undefined;
46
+ startLineNumber: number;
47
+ startColumn: number;
48
+ endLineNumber: number;
49
+ endColumn: number;
50
+ modelVersionId?: number | undefined;
51
+ relatedInformation?: {
52
+ resource: {
53
+ readonly scheme: string;
54
+ readonly authority: string;
55
+ readonly path: string;
56
+ readonly query: string;
57
+ readonly fragment: string;
58
+ readonly fsPath: string;
59
+ with: (change: {
60
+ scheme?: string;
61
+ authority?: string | null;
62
+ path?: string | null;
63
+ query?: string | null;
64
+ fragment?: string | null;
65
+ }) => monaco.Uri;
66
+ toString: (skipEncoding?: boolean) => string;
67
+ toJSON: () => monaco.UriComponents;
68
+ };
69
+ message: string;
70
+ startLineNumber: number;
71
+ startColumn: number;
72
+ endLineNumber: number;
73
+ endColumn: number;
74
+ }[] | undefined;
75
+ tags?: monaco.MarkerTag[] | undefined;
76
+ origin?: string | undefined | undefined;
77
+ }[], monaco.editor.IMarker[] | {
78
+ owner: string;
79
+ resource: {
80
+ readonly scheme: string;
81
+ readonly authority: string;
82
+ readonly path: string;
83
+ readonly query: string;
84
+ readonly fragment: string;
85
+ readonly fsPath: string;
86
+ with: (change: {
87
+ scheme?: string;
88
+ authority?: string | null;
89
+ path?: string | null;
90
+ query?: string | null;
91
+ fragment?: string | null;
92
+ }) => monaco.Uri;
93
+ toString: (skipEncoding?: boolean) => string;
94
+ toJSON: () => monaco.UriComponents;
95
+ };
96
+ severity: monaco.MarkerSeverity;
97
+ code?: string | {
98
+ value: string;
99
+ target: {
100
+ readonly scheme: string;
101
+ readonly authority: string;
102
+ readonly path: string;
103
+ readonly query: string;
104
+ readonly fragment: string;
105
+ readonly fsPath: string;
106
+ with: (change: {
107
+ scheme?: string;
108
+ authority?: string | null;
109
+ path?: string | null;
110
+ query?: string | null;
111
+ fragment?: string | null;
112
+ }) => monaco.Uri;
113
+ toString: (skipEncoding?: boolean) => string;
114
+ toJSON: () => monaco.UriComponents;
115
+ };
116
+ } | undefined;
117
+ message: string;
118
+ source?: string | undefined;
119
+ startLineNumber: number;
120
+ startColumn: number;
121
+ endLineNumber: number;
122
+ endColumn: number;
123
+ modelVersionId?: number | undefined;
124
+ relatedInformation?: {
125
+ resource: {
126
+ readonly scheme: string;
127
+ readonly authority: string;
128
+ readonly path: string;
129
+ readonly query: string;
130
+ readonly fragment: string;
131
+ readonly fsPath: string;
132
+ with: (change: {
133
+ scheme?: string;
134
+ authority?: string | null;
135
+ path?: string | null;
136
+ query?: string | null;
137
+ fragment?: string | null;
138
+ }) => monaco.Uri;
139
+ toString: (skipEncoding?: boolean) => string;
140
+ toJSON: () => monaco.UriComponents;
141
+ };
142
+ message: string;
143
+ startLineNumber: number;
144
+ startColumn: number;
145
+ endLineNumber: number;
146
+ endColumn: number;
147
+ }[] | undefined;
148
+ tags?: monaco.MarkerTag[] | undefined;
149
+ origin?: string | undefined | undefined;
150
+ }[]>;
151
+ };
152
+ //# sourceMappingURL=use-editor-markers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor-markers.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/hooks/use-editor-markers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,2CAA2C,CAAA;AACnE,OAAO,EAAE,KAAK,gBAAgB,EAAmD,MAAM,KAAK,CAAA;AAE5F,eAAO,MAAM,gBAAgB,GAAI,WAAW,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,GAAG,SAAS,CAAC;;;;;;;;;;;sBAkD0iJ,CAAC;yBAA2B,CAAC;oBAA6B,CAAC;qBAA8B,CAAC;wBAAiC,CAAC;;;;;;;;;;;;;;;;0BAA5H,CAAC;6BAA2B,CAAC;wBAA6B,CAAC;yBAA8B,CAAC;4BAAiC,CAAC;;;;;;;;;;;;;;;;;;;;;;0BAA5H,CAAC;6BAA2B,CAAC;wBAA6B,CAAC;yBAA8B,CAAC;4BAAiC,CAAC;;;;;;;;;;;;;;;;;;;;;;;sBAA5H,CAAC;yBAA2B,CAAC;oBAA6B,CAAC;qBAA8B,CAAC;wBAAiC,CAAC;;;;;;;;;;;;;;;;0BAA5H,CAAC;6BAA2B,CAAC;wBAA6B,CAAC;yBAA8B,CAAC;4BAAiC,CAAC;;;;;;;;;;;;;;;;;;;;;;0BAA5H,CAAC;6BAA2B,CAAC;wBAA6B,CAAC;yBAA8B,CAAC;4BAAiC,CAAC;;;;;;;;;;;;;;CADlxJ,CAAA"}
@@ -0,0 +1,34 @@
1
+ import * as a from "monaco-editor/esm/vs/editor/editor.api.js";
2
+ import { ref as m, onMounted as l, onBeforeUnmount as M, watch as g, toValue as d } from "vue";
3
+ const f = (o) => {
4
+ const e = m([]);
5
+ let s = null;
6
+ const i = [], t = () => {
7
+ const n = d(o)?.getModel()?.uri;
8
+ if (!n) {
9
+ e.value = [];
10
+ return;
11
+ }
12
+ e.value = a.editor.getModelMarkers({}).filter((c) => c.resource.toString() === n.toString());
13
+ }, r = () => {
14
+ i.push(setTimeout(t, 0), setTimeout(t, 80), setTimeout(t, 220));
15
+ };
16
+ return l(() => {
17
+ s = a.editor.onDidChangeMarkers(() => {
18
+ r();
19
+ }), r();
20
+ }), M(() => {
21
+ s?.dispose(), i.forEach((u) => clearTimeout(u));
22
+ }), g(
23
+ () => d(o)?.getModel()?.uri?.toString(),
24
+ () => {
25
+ r();
26
+ },
27
+ { immediate: !0 }
28
+ ), {
29
+ markers: e
30
+ };
31
+ };
32
+ export {
33
+ f as useEditorMarkers
34
+ };
@@ -0,0 +1,14 @@
1
+ import type { MonacoEditorLanguage } from '../../../../../../v2/features/collection/components/Editor/hooks/use-editor.js';
2
+ export declare const useEditorState: () => {
3
+ isAutoSaveEnabled: import("vue").Ref<boolean, boolean>;
4
+ isDirty: import("vue").Ref<boolean, boolean>;
5
+ editorLanguage: import("vue").Ref<MonacoEditorLanguage, MonacoEditorLanguage>;
6
+ isDiagnosticsPaneExpanded: import("vue").Ref<boolean, boolean>;
7
+ isEditorMaximized: import("vue").Ref<boolean, boolean>;
8
+ isYamlMode: import("vue").ComputedRef<boolean>;
9
+ editorBottomPadding: import("vue").ComputedRef<46 | 155>;
10
+ editorRootClass: import("vue").ComputedRef<"" | "fixed inset-0 z-50 h-screen w-screen border bg-b-1 p-3">;
11
+ getLanguageToggleClass: (isActive: boolean) => string;
12
+ toggleEditorMaximized: () => void;
13
+ };
14
+ //# sourceMappingURL=use-editor-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor-state.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/hooks/use-editor-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AAKvG,eAAO,MAAM,cAAc;;;;;;;;;uCAeiB,OAAO,KAAG,MAAM;iCAQxB,IAAI;CAgBvC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { ref as e, computed as o } from "vue";
2
+ const g = 46, u = 155, E = () => {
3
+ const n = e(!1), a = e(!1), s = e("json"), i = e(!1), t = e(!1), c = o(() => s.value === "yaml"), r = o(
4
+ () => i.value ? u : g
5
+ ), d = o(
6
+ () => t.value ? "fixed inset-0 z-50 h-screen w-screen border bg-b-1 p-3" : ""
7
+ );
8
+ return {
9
+ isAutoSaveEnabled: n,
10
+ isDirty: a,
11
+ editorLanguage: s,
12
+ isDiagnosticsPaneExpanded: i,
13
+ isEditorMaximized: t,
14
+ isYamlMode: c,
15
+ editorBottomPadding: r,
16
+ editorRootClass: d,
17
+ getLanguageToggleClass: (l) => `rounded-none px-2 py-1 text-[11px] leading-4 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-c-accent/30 focus-visible:ring-offset-1 focus-visible:ring-offset-b-1 first:rounded-md last:rounded-md ${l ? "bg-b-2 text-c-1 hover:bg-b-2" : "text-c-2 hover:bg-b-2/60 hover:text-c-1"}`,
18
+ toggleEditorMaximized: () => {
19
+ t.value = !t.value;
20
+ }
21
+ };
22
+ };
23
+ export {
24
+ E as useEditorState
25
+ };
@@ -0,0 +1,39 @@
1
+ import * as monaco from 'monaco-editor';
2
+ import 'monaco-editor/esm/vs/language/json/monaco.contribution';
3
+ import 'monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution';
4
+ import 'monaco-editor/esm/vs/editor/contrib/folding/browser/folding';
5
+ import 'monaco-editor/esm/vs/editor/contrib/folding/browser/folding.css';
6
+ import 'monaco-editor/esm/vs/base/browser/ui/codicons/codicon/codicon.css';
7
+ import { type MaybeRefOrGetter } from 'vue';
8
+ import type { JsonPath } from '../../../../../../v2/features/collection/components/Editor/helpers/json-ast.js';
9
+ type MonacoEditorAction = {
10
+ id: string;
11
+ label: string;
12
+ keybindings?: number[];
13
+ run: () => void | Promise<void>;
14
+ };
15
+ export type MonacoEditorLanguage = 'json' | 'yaml';
16
+ export declare const useEditor: ({ element, value, onChange, actions, readOnly, isDarkMode, theme, language, }: {
17
+ element: HTMLElement;
18
+ value?: MaybeRefOrGetter<string>;
19
+ readOnly?: MaybeRefOrGetter<boolean>;
20
+ onChange?: (e: string) => void;
21
+ actions?: MonacoEditorAction[];
22
+ isDarkMode?: MaybeRefOrGetter<boolean>;
23
+ theme?: MaybeRefOrGetter<string>;
24
+ language?: MonacoEditorLanguage;
25
+ }) => {
26
+ editor: monaco.editor.IStandaloneCodeEditor;
27
+ model: monaco.editor.ITextModel;
28
+ highlightPath: (path: JsonPath) => Promise<void>;
29
+ focusPath: (path: JsonPath) => Promise<void>;
30
+ formatDocument: () => Promise<void>;
31
+ getValue: () => string;
32
+ setValue: (nextValue: string, isProgrammaticUpdate?: boolean) => void;
33
+ hasTextFocus: () => boolean;
34
+ setLanguage: (nextLanguage: MonacoEditorLanguage) => void;
35
+ setCursorToMarker: (marker: monaco.editor.IMarker) => void;
36
+ dispose: () => void;
37
+ };
38
+ export {};
39
+ //# sourceMappingURL=use-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/features/collection/components/Editor/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,wDAAwD,CAAA;AAC/D,OAAO,6DAA6D,CAAA;AACpE,OAAO,6DAA6D,CAAA;AACpE,OAAO,iEAAiE,CAAA;AACxE,OAAO,mEAAmE,CAAA;AAG1E,OAAO,EAAE,KAAK,gBAAgB,EAAkB,MAAM,KAAK,CAAA;AAO3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6DAA6D,CAAA;AAI3F,KAAK,kBAAkB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,CAAA;AAMlD,eAAO,MAAM,SAAS,GAAI,+EASvB;IACD,OAAO,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACpC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAC9B,UAAU,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACtC,KAAK,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,oBAAoB,CAAA;CAChC;;;0BA2FoC,QAAQ;sBASZ,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC;0BAoFtB,OAAO,CAAC,IAAI,CAAC;oBAIzB,MAAM;0BAEE,MAAM,qCAAiC,IAAI;wBAQ/C,OAAO;gCAEG,oBAAoB,KAAG,IAAI;gCAI3B,MAAM,CAAC,MAAM,CAAC,OAAO,KAAG,IAAI;mBAO3C,IAAI;CAmBzB,CAAA"}
@@ -0,0 +1,153 @@
1
+ import * as r from "monaco-editor";
2
+ import "monaco-editor/esm/vs/editor/contrib/folding/browser/folding.css";
3
+ import "monaco-editor/esm/vs/base/browser/ui/codicons/codicon/codicon.css";
4
+ import { presets as E } from "@scalar/themes";
5
+ import { toValue as a, watch as c } from "vue";
6
+ import { applyScalarTheme as J } from "../helpers/apply-scalar-theme.js";
7
+ import { configureLanguageSupport as R } from "../helpers/configure-language-support.js";
8
+ import { ensureMonacoEnvironment as k } from "../helpers/ensure-monaco-environment.js";
9
+ import { getJsonAstNodeFromPath as D } from "../helpers/get-json-ast-node-from-path.js";
10
+ import { getYamlNodeRangeFromPath as j } from "../helpers/get-yaml-node-range-from-path.js";
11
+ import { ensureJsonPointerLinkSupport as z } from "../helpers/json-pointer-links.js";
12
+ import { parseJsonPointerPath as B } from "../helpers/json-pointer-path.js";
13
+ const ot = ({
14
+ element: w,
15
+ value: f,
16
+ onChange: b,
17
+ actions: O,
18
+ readOnly: m = !1,
19
+ isDarkMode: x = !1,
20
+ theme: S = E.default.theme,
21
+ language: C = "json"
22
+ }) => {
23
+ k();
24
+ const n = r.editor.createModel(a(f) ?? "", C);
25
+ R(n.uri.toString());
26
+ const o = r.editor.create(w, {
27
+ model: n,
28
+ automaticLayout: !0,
29
+ folding: !0,
30
+ showFoldingControls: "always",
31
+ glyphMargin: !0,
32
+ lineNumbers: "on",
33
+ minimap: { enabled: !1 },
34
+ overviewRulerLanes: 0,
35
+ readOnly: a(m),
36
+ scrollbar: {
37
+ useShadows: !1,
38
+ verticalScrollbarSize: 5
39
+ },
40
+ scrollBeyondLastLine: !1,
41
+ guides: {
42
+ indentation: !0
43
+ },
44
+ formatOnPaste: !0,
45
+ renderValidationDecorations: "on",
46
+ formatOnType: !0,
47
+ lineHeight: 20,
48
+ renderLineHighlight: "none",
49
+ fontFamily: "'JetBrains Mono', monospace"
50
+ });
51
+ o.updateOptions({ insertSpaces: !0, tabSize: 2 });
52
+ let d = [], u = 0;
53
+ O?.forEach((t) => {
54
+ o.addAction({
55
+ id: t.id,
56
+ label: t.label,
57
+ keybindings: t.keybindings,
58
+ run: async () => {
59
+ await t.run();
60
+ }
61
+ });
62
+ });
63
+ const g = (t, e) => {
64
+ const s = n.getPositionAt(t), i = Math.max(t, e - 1), F = n.getPositionAt(i), P = Math.max(1, s.lineNumber), M = Math.max(P, F.lineNumber);
65
+ return new r.Range(P, 1, M, n.getLineMaxColumn(M));
66
+ }, p = async (t) => {
67
+ if (n.getLanguageId() === "yaml")
68
+ return j(n.getValue(), t);
69
+ const e = await D(n, t);
70
+ return e ? { startOffset: e.offset, endOffset: e.offset + e.length } : null;
71
+ }, l = async (t) => {
72
+ await o.getAction(t)?.run();
73
+ }, h = ({ startOffset: t, endOffset: e }) => {
74
+ const s = g(t, e);
75
+ d = o.deltaDecorations(d, [
76
+ {
77
+ range: s,
78
+ options: {
79
+ isWholeLine: !0,
80
+ className: "json-focus-highlight"
81
+ }
82
+ }
83
+ ]);
84
+ }, T = async (t) => {
85
+ const e = await p(t);
86
+ e && h(e);
87
+ }, y = async (t) => {
88
+ const e = await p(t);
89
+ if (!e)
90
+ return;
91
+ const s = g(e.startOffset, e.endOffset);
92
+ await l("editor.foldAll"), o.setSelection(s), await l("editor.unfoldRecursively");
93
+ const i = n.getPositionAt(e.startOffset);
94
+ o.setPosition(i), o.revealPositionNearTop(i), h(e);
95
+ }, N = async (t) => {
96
+ const e = B(t);
97
+ e && await y(e);
98
+ }, { dispose: v } = z(N);
99
+ o.onDidChangeModelContent(() => {
100
+ if (u > 0) {
101
+ u -= 1;
102
+ return;
103
+ }
104
+ const t = o.getValue();
105
+ typeof t == "string" && b?.(t ?? "");
106
+ }), c(
107
+ () => a(f),
108
+ (t) => {
109
+ t && o.getValue() !== t && L(t, !0);
110
+ }
111
+ ), c(
112
+ [() => a(S), () => a(x)],
113
+ async ([t, e]) => {
114
+ await J(t, e);
115
+ },
116
+ {
117
+ immediate: !0
118
+ }
119
+ ), c(
120
+ () => a(m),
121
+ (t) => {
122
+ o?.updateOptions({ readOnly: t });
123
+ }
124
+ );
125
+ const A = async () => {
126
+ await l("editor.action.formatDocument");
127
+ }, V = () => o.getValue(), L = (t, e = !1) => {
128
+ e && (u += 1), o.setValue(t);
129
+ };
130
+ return {
131
+ editor: o,
132
+ model: n,
133
+ highlightPath: T,
134
+ focusPath: y,
135
+ formatDocument: A,
136
+ getValue: V,
137
+ setValue: L,
138
+ hasTextFocus: () => o.hasTextFocus(),
139
+ setLanguage: (t) => {
140
+ r.editor.setModelLanguage(n, t);
141
+ },
142
+ setCursorToMarker: (t) => {
143
+ const e = Math.min(Math.max(t.startLineNumber || 1, 1), n.getLineCount()), s = Math.min(Math.max(t.startColumn || 1, 1), n.getLineMaxColumn(e));
144
+ o.setPosition({ lineNumber: e, column: s });
145
+ },
146
+ dispose: () => {
147
+ o.dispose(), n.dispose(), v();
148
+ }
149
+ };
150
+ };
151
+ export {
152
+ ot as useEditor
153
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Editor } from './Editor.vue.js';
2
+ //# sourceMappingURL=index.d.ts.map