@typespec/playground 0.3.0-dev.8 → 0.3.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 (122) hide show
  1. package/dist/.storybook/main.d.ts +5 -0
  2. package/dist/.storybook/main.d.ts.map +1 -0
  3. package/dist/.storybook/preview.d.ts +5 -0
  4. package/dist/.storybook/preview.d.ts.map +1 -0
  5. package/dist/index.js +31 -34
  6. package/dist/react/index.js +1430 -783
  7. package/dist/react/viewers/index.js +8 -7
  8. package/dist/react-wrapper-CT3xxCSW.js +20 -0
  9. package/dist/src/browser-host.d.ts +3 -2
  10. package/dist/src/browser-host.d.ts.map +1 -1
  11. package/dist/src/core.d.ts +1 -1
  12. package/dist/src/core.d.ts.map +1 -1
  13. package/dist/src/editor-command-bar/editor-command-bar.d.ts +4 -3
  14. package/dist/src/editor-command-bar/editor-command-bar.d.ts.map +1 -1
  15. package/dist/src/index.d.ts +5 -5
  16. package/dist/src/index.d.ts.map +1 -1
  17. package/dist/src/lsp/monaco-to-lsp.d.ts +1 -1
  18. package/dist/src/manifest.d.ts +2 -4
  19. package/dist/src/manifest.d.ts.map +1 -1
  20. package/dist/src/react/context/index.d.ts +1 -1
  21. package/dist/src/react/context/index.d.ts.map +1 -1
  22. package/dist/src/react/context/playground-context.d.ts +4 -4
  23. package/dist/src/react/context/playground-context.d.ts.map +1 -1
  24. package/dist/src/react/default-footer.d.ts +2 -1
  25. package/dist/src/react/default-footer.d.ts.map +1 -1
  26. package/dist/src/react/diagnostic-list/diagnostic-list.d.ts +3 -2
  27. package/dist/src/react/diagnostic-list/diagnostic-list.d.ts.map +1 -1
  28. package/dist/src/react/editor.d.ts +3 -2
  29. package/dist/src/react/editor.d.ts.map +1 -1
  30. package/dist/src/react/emitter-dropdown.d.ts +2 -1
  31. package/dist/src/react/emitter-dropdown.d.ts.map +1 -1
  32. package/dist/src/react/file-output/file-output.d.ts +6 -5
  33. package/dist/src/react/file-output/file-output.d.ts.map +1 -1
  34. package/dist/src/react/footer/footer-item.d.ts +2 -1
  35. package/dist/src/react/footer/footer-item.d.ts.map +1 -1
  36. package/dist/src/react/footer/footer-version-item.d.ts +1 -1
  37. package/dist/src/react/footer/footer.d.ts +2 -1
  38. package/dist/src/react/footer/footer.d.ts.map +1 -1
  39. package/dist/src/react/footer/index.d.ts +3 -3
  40. package/dist/src/react/footer/index.d.ts.map +1 -1
  41. package/dist/src/react/index.d.ts +6 -6
  42. package/dist/src/react/index.d.ts.map +1 -1
  43. package/dist/src/react/output-tabs/output-tabs.d.ts +3 -7
  44. package/dist/src/react/output-tabs/output-tabs.d.ts.map +1 -1
  45. package/dist/src/react/output-view/file-viewer.d.ts +4 -0
  46. package/dist/src/react/output-view/file-viewer.d.ts.map +1 -0
  47. package/dist/src/react/output-view/output-view.d.ts +9 -4
  48. package/dist/src/react/output-view/output-view.d.ts.map +1 -1
  49. package/dist/src/react/output-view/type-graph-viewer.d.ts +4 -0
  50. package/dist/src/react/output-view/type-graph-viewer.d.ts.map +1 -0
  51. package/dist/src/react/playground.d.ts +8 -5
  52. package/dist/src/react/playground.d.ts.map +1 -1
  53. package/dist/src/react/problem-pane/header.d.ts +4 -3
  54. package/dist/src/react/problem-pane/header.d.ts.map +1 -1
  55. package/dist/src/react/problem-pane/index.d.ts +1 -1
  56. package/dist/src/react/problem-pane/problem-pane.d.ts +4 -3
  57. package/dist/src/react/problem-pane/problem-pane.d.ts.map +1 -1
  58. package/dist/src/react/samples-dropdown.d.ts +3 -2
  59. package/dist/src/react/samples-dropdown.d.ts.map +1 -1
  60. package/dist/src/react/settings/compiler-settings-dialog-button.d.ts +2 -1
  61. package/dist/src/react/settings/compiler-settings.d.ts +4 -3
  62. package/dist/src/react/settings/compiler-settings.d.ts.map +1 -1
  63. package/dist/src/react/settings/emitter-options-form.d.ts +4 -3
  64. package/dist/src/react/settings/emitter-options-form.d.ts.map +1 -1
  65. package/dist/src/react/settings/linter-form.d.ts +4 -3
  66. package/dist/src/react/settings/linter-form.d.ts.map +1 -1
  67. package/dist/src/react/split-pane/index.d.ts +1 -1
  68. package/dist/src/react/split-pane/index.d.ts.map +1 -1
  69. package/dist/src/react/split-pane/pane.d.ts +2 -1
  70. package/dist/src/react/split-pane/pane.d.ts.map +1 -1
  71. package/dist/src/react/split-pane/sash-content.d.ts +2 -1
  72. package/dist/src/react/split-pane/sash-content.d.ts.map +1 -1
  73. package/dist/src/react/split-pane/sash.d.ts +2 -1
  74. package/dist/src/react/split-pane/sash.d.ts.map +1 -1
  75. package/dist/src/react/split-pane/split-pane.d.ts +2 -1
  76. package/dist/src/react/split-pane/split-pane.d.ts.map +1 -1
  77. package/dist/src/react/standalone.d.ts +5 -4
  78. package/dist/src/react/standalone.d.ts.map +1 -1
  79. package/dist/src/react/types.d.ts +20 -8
  80. package/dist/src/react/types.d.ts.map +1 -1
  81. package/dist/src/react/typespec-editor.d.ts +5 -4
  82. package/dist/src/react/typespec-editor.d.ts.map +1 -1
  83. package/dist/src/react/viewers/index.d.ts +2 -1
  84. package/dist/src/react/viewers/index.d.ts.map +1 -1
  85. package/dist/src/react/viewers/swagger-ui.d.ts +2 -2
  86. package/dist/src/react/viewers/swagger-ui.d.ts.map +1 -1
  87. package/dist/src/services.d.ts +3 -2
  88. package/dist/src/services.d.ts.map +1 -1
  89. package/dist/src/tooling/index.d.ts +2 -1
  90. package/dist/src/tooling/index.d.ts.map +1 -1
  91. package/dist/src/tooling/types.d.ts +2 -1
  92. package/dist/src/tooling/types.d.ts.map +1 -1
  93. package/dist/src/types.d.ts +2 -1
  94. package/dist/src/types.d.ts.map +1 -1
  95. package/dist/src/vite/index.d.ts +3 -2
  96. package/dist/src/vite/index.d.ts.map +1 -1
  97. package/dist/src/vite/types.d.ts +4 -3
  98. package/dist/src/vite/types.d.ts.map +1 -1
  99. package/dist/state-storage-BjOULkS3.js +654 -0
  100. package/dist/stories/footer/footer-item.stories.d.ts +9 -0
  101. package/dist/stories/footer/footer-item.stories.d.ts.map +1 -0
  102. package/dist/stories/footer/footer-version-item.stories.d.ts +9 -0
  103. package/dist/stories/footer/footer-version-item.stories.d.ts.map +1 -0
  104. package/dist/stories/footer/footer.stories.d.ts +9 -0
  105. package/dist/stories/footer/footer.stories.d.ts.map +1 -0
  106. package/dist/stories/playground.stories.d.ts +9 -0
  107. package/dist/stories/playground.stories.d.ts.map +1 -0
  108. package/dist/{index.css → style.css} +170 -163
  109. package/dist/tooling/index.js +18 -23
  110. package/dist/vite/index.js +74 -76
  111. package/dist/vite.config.d.ts +3 -0
  112. package/dist/vite.config.d.ts.map +1 -0
  113. package/package.json +40 -39
  114. package/dist/index.js.map +0 -1
  115. package/dist/react/index.js.map +0 -1
  116. package/dist/react/viewers/index.js.map +0 -1
  117. package/dist/react-wrapper-DhFQQ2Do.js +0 -21
  118. package/dist/react-wrapper-DhFQQ2Do.js.map +0 -1
  119. package/dist/state-storage-BYkGBmXj.js +0 -657
  120. package/dist/state-storage-BYkGBmXj.js.map +0 -1
  121. package/dist/tooling/index.js.map +0 -1
  122. package/dist/vite/index.js.map +0 -1
@@ -1,919 +1,1566 @@
1
1
  import { createContext, useContext, memo, useCallback, useMemo, useRef, useEffect, useState, useId as useId$1 } from 'react';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, useId, Label, RadioGroup, Radio, Input, Switch, Checkbox, Divider, Dialog, DialogTrigger, ToolbarButton, DialogSurface, DialogBody, DialogTitle, DialogContent, Link, Toolbar, Tooltip, TabList, Tab, tokens, useToastController, Toast, ToastTitle, ToastBody, Toaster, FluentProvider, webLightTheme } from '@fluentui/react-components';
3
+ import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, useId, Label, RadioGroup, Radio, Input, Switch, Checkbox, Divider, Dialog, DialogTrigger, ToolbarButton, DialogSurface, DialogBody, DialogTitle, DialogContent, Toolbar, Tooltip, Link, TabList, Tab, tokens, useToastController, Toast, ToastTitle, ToastBody, Toaster, FluentProvider, webLightTheme } from '@fluentui/react-components';
4
4
  import debounce from 'debounce';
5
- import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
5
+ import { Uri, editor, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
6
6
  import { CompletionItemTag } from 'vscode-languageserver';
7
- import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
8
- import { g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage, a as createUrlStateStorage } from '../state-storage-BYkGBmXj.js';
7
+ import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
8
+ import { g as getMonacoRange, a as createUrlStateStorage, c as createBrowserHost, r as registerMonacoLanguage } from '../state-storage-BjOULkS3.js';
9
9
  import { ColorProvider, TypeSpecProgramViewer } from '@typespec/html-program-viewer';
10
10
  import { getSourceLocation } from '@typespec/compiler';
11
11
  import { createRoot } from 'react-dom/client';
12
- import 'vscode-languageserver-textdocument';
13
- import 'lzutf8';
14
12
 
15
- const PlaygroundContext = createContext(undefined);
13
+ const PlaygroundContext = createContext(void 0);
16
14
  const PlaygroundContextProvider = PlaygroundContext.Provider;
17
15
  function usePlaygroundContext() {
18
- const context = useContext(PlaygroundContext);
19
- if (context === undefined) {
20
- throw new Error("usePlaygroundContext must be used within a PlaygroundContextProvider");
21
- }
22
- return context;
16
+ const context = useContext(PlaygroundContext);
17
+ if (context === void 0) {
18
+ throw new Error("usePlaygroundContext must be used within a PlaygroundContextProvider");
19
+ }
20
+ return context;
23
21
  }
24
22
 
25
- var style$b = {"footer":"footer-module_footer__QqUEE","footer-item":"footer-module_footer-item__7rhbZ"};
23
+ const footer = "_footer_cn8nf_1";
24
+ const style$b = {
25
+ footer: footer,
26
+ "footer-item": "_footer-item_cn8nf_9"
27
+ };
26
28
 
27
29
  const FooterItem = ({ children, link, className }) => {
28
- const resolvedClassName = mergeClasses(style$b["footer-item"], className);
29
- return link ? (jsx("a", { className: resolvedClassName, href: link, target: "_blank", rel: "noopener noreferrer", children: children })) : (jsx("div", { className: resolvedClassName, children: children }));
30
+ const resolvedClassName = mergeClasses(style$b["footer-item"], className);
31
+ return link ? /* @__PURE__ */ jsx("a", { className: resolvedClassName, href: link, target: "_blank", rel: "noopener noreferrer", children }) : /* @__PURE__ */ jsx("div", { className: resolvedClassName, children });
30
32
  };
31
33
 
32
- var style$a = {"version-item":"footer-version-item-module_version-item__pjuvV","button":"footer-version-item-module_button__70iqf"};
34
+ const button = "_button_1c15n_4";
35
+ const style$a = {
36
+ "version-item": "_version-item_1c15n_1",
37
+ button: button
38
+ };
33
39
 
34
40
  const FooterVersionItem = memo(({ versionSelector }) => {
35
- const { host } = usePlaygroundContext();
36
- const latest = versionSelector?.latest;
37
- const selected = versionSelector?.selected ?? host.compiler.MANIFEST.version;
38
- return (jsx(FooterItem, { className: style$a["version-item"], children: jsxs(Popover, { children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsxs("div", { className: style$a["button"], children: [jsx("span", { children: "Version " }), jsx("span", { children: selected }), jsx("span", { children: latest ? (latest === selected ? " (latest)" : " (old)") : "" })] }) }), jsx(PopoverSurface, { children: jsx(VersionsPopup, { versionSelector: versionSelector }) })] }) }));
41
+ const { host } = usePlaygroundContext();
42
+ const latest = versionSelector?.latest;
43
+ const selected = versionSelector?.selected ?? host.compiler.MANIFEST.version;
44
+ return /* @__PURE__ */ jsx(FooterItem, { className: style$a["version-item"], children: /* @__PURE__ */ jsxs(Popover, { children: [
45
+ /* @__PURE__ */ jsx(PopoverTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsxs("div", { className: style$a["button"], children: [
46
+ /* @__PURE__ */ jsx("span", { children: "Version " }),
47
+ /* @__PURE__ */ jsx("span", { children: selected }),
48
+ /* @__PURE__ */ jsx("span", { children: latest ? latest === selected ? " (latest)" : " (old)" : "" })
49
+ ] }) }),
50
+ /* @__PURE__ */ jsx(PopoverSurface, { children: /* @__PURE__ */ jsx(VersionsPopup, { versionSelector }) })
51
+ ] }) });
39
52
  });
40
53
  const VersionsPopup = memo(({ versionSelector }) => {
41
- const { host } = usePlaygroundContext();
42
- return (jsxs("div", { style: { maxWidth: "400px" }, children: [versionSelector && jsx(VersionSelector, { ...versionSelector }), jsxs("div", { children: [jsx(Title3, { children: "Loaded libraries" }), jsxs(Table, { size: "small", children: [jsx(TableHeader, { children: jsx(TableRow, { children: columns.map((column) => (jsx(TableHeaderCell, { children: column.label }, column.columnKey))) }) }), jsx(TableBody, { children: Object.values(host.libraries).map((item) => (jsxs(TableRow, { children: [jsx(TableCell, { children: item.name }), jsx(TableCell, { children: item.packageJson.version })] }, item.name))) })] })] })] }));
54
+ const { host } = usePlaygroundContext();
55
+ return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "400px" }, children: [
56
+ versionSelector && /* @__PURE__ */ jsx(VersionSelector, { ...versionSelector }),
57
+ /* @__PURE__ */ jsxs("div", { children: [
58
+ /* @__PURE__ */ jsx(Title3, { children: "Loaded libraries" }),
59
+ /* @__PURE__ */ jsxs(Table, { size: "small", children: [
60
+ /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsx(TableRow, { children: columns.map((column) => /* @__PURE__ */ jsx(TableHeaderCell, { children: column.label }, column.columnKey)) }) }),
61
+ /* @__PURE__ */ jsx(TableBody, { children: Object.values(host.libraries).map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
62
+ /* @__PURE__ */ jsx(TableCell, { children: item.name }),
63
+ /* @__PURE__ */ jsx(TableCell, { children: item.packageJson.version })
64
+ ] }, item.name)) })
65
+ ] })
66
+ ] })
67
+ ] });
43
68
  });
44
69
  const columns = [
45
- { columnKey: "name", label: "Library" },
46
- { columnKey: "version", label: "Version" },
70
+ { columnKey: "name", label: "Library" },
71
+ { columnKey: "version", label: "Version" }
47
72
  ];
48
73
  const VersionSelector = memo(({ versions, selected, latest, onChange }) => {
49
- const changeVersion = useCallback((ev, data) => {
50
- onChange(versions.find((x) => x.name === data.value));
51
- }, [versions, onChange]);
52
- return (jsxs("div", { children: [jsx(Title3, { children: "Select release" }), jsx(Select, { value: selected, onChange: changeVersion, "aria-label": "Select version", children: versions.map((version) => (jsxs("option", { value: version.name, children: [version.label, " ", version.name === latest ? "(latest)" : ""] }, version.name))) })] }));
74
+ const changeVersion = useCallback(
75
+ (ev, data) => {
76
+ onChange(versions.find((x) => x.name === data.value));
77
+ },
78
+ [versions, onChange]
79
+ );
80
+ return /* @__PURE__ */ jsxs("div", { children: [
81
+ /* @__PURE__ */ jsx(Title3, { children: "Select release" }),
82
+ /* @__PURE__ */ jsx(Select, { value: selected, onChange: changeVersion, "aria-label": "Select version", children: versions.map((version) => /* @__PURE__ */ jsxs("option", { value: version.name, children: [
83
+ version.label,
84
+ " ",
85
+ version.name === latest ? "(latest)" : ""
86
+ ] }, version.name)) })
87
+ ] });
53
88
  });
54
89
 
55
90
  const Footer = ({ className, children }) => {
56
- return jsx("div", { className: mergeClasses(style$b.footer, className), children: children });
91
+ return /* @__PURE__ */ jsx("div", { className: mergeClasses(style$b.footer, className), children });
57
92
  };
58
93
 
59
- const EmitterDropdown = ({ emitters, onSelectedEmitterChange, selectedEmitter, }) => {
60
- const options = emitters.map((emitterName) => {
61
- return jsx("option", { children: emitterName }, emitterName);
62
- });
63
- const handleSelected = useCallback((evt) => {
64
- onSelectedEmitterChange(evt.target.value);
65
- }, [onSelectedEmitterChange]);
66
- return (jsxs(Select, { className: "sample-dropdown", onChange: handleSelected, value: selectedEmitter, "aria-label": "Select an emitter", children: [jsx("option", { value: "", disabled: true, children: "Select emitter..." }), options] }));
94
+ const EmitterDropdown = ({
95
+ emitters,
96
+ onSelectedEmitterChange,
97
+ selectedEmitter
98
+ }) => {
99
+ const options = emitters.map((emitterName) => {
100
+ return /* @__PURE__ */ jsx("option", { children: emitterName }, emitterName);
101
+ });
102
+ const handleSelected = useCallback(
103
+ (evt) => {
104
+ onSelectedEmitterChange(evt.target.value);
105
+ },
106
+ [onSelectedEmitterChange]
107
+ );
108
+ return /* @__PURE__ */ jsxs(
109
+ Select,
110
+ {
111
+ className: "sample-dropdown",
112
+ onChange: handleSelected,
113
+ value: selectedEmitter,
114
+ "aria-label": "Select an emitter",
115
+ children: [
116
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select emitter..." }),
117
+ options
118
+ ]
119
+ }
120
+ );
67
121
  };
68
122
 
69
- const SamplesDropdown = ({ samples, selectedSampleName, onSelectedSampleNameChange, }) => {
70
- const options = Object.keys(samples).map((sample) => {
71
- return jsx("option", { children: sample }, sample);
72
- });
73
- const handleSelected = useCallback((evt) => {
74
- if (samples[evt.target.value]) {
75
- onSelectedSampleNameChange(evt.target.value);
76
- }
77
- }, [onSelectedSampleNameChange]);
78
- return (jsxs(Select, { className: "sample-dropdown", onChange: handleSelected, value: selectedSampleName ?? "", "aria-label": "Select a sample", children: [jsx("option", { value: "", disabled: true, children: "Select sample..." }), options] }));
123
+ const SamplesDropdown = ({
124
+ samples,
125
+ selectedSampleName,
126
+ onSelectedSampleNameChange
127
+ }) => {
128
+ const options = Object.keys(samples).map((sample) => {
129
+ return /* @__PURE__ */ jsx("option", { children: sample }, sample);
130
+ });
131
+ const handleSelected = useCallback(
132
+ (evt) => {
133
+ if (samples[evt.target.value]) {
134
+ onSelectedSampleNameChange(evt.target.value);
135
+ }
136
+ },
137
+ [onSelectedSampleNameChange]
138
+ );
139
+ return /* @__PURE__ */ jsxs(
140
+ Select,
141
+ {
142
+ className: "sample-dropdown",
143
+ onChange: handleSelected,
144
+ value: selectedSampleName ?? "",
145
+ "aria-label": "Select a sample",
146
+ children: [
147
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select sample..." }),
148
+ options
149
+ ]
150
+ }
151
+ );
79
152
  };
80
153
 
81
- var style$9 = {"form":"emitter-options-form-module_form__dm2RP","item":"emitter-options-form-module_item__WocHP","switch":"emitter-options-form-module_switch__d4EQs"};
154
+ const form = "_form_sqeas_1";
155
+ const item$1 = "_item_sqeas_7";
156
+ const style$9 = {
157
+ form: form,
158
+ item: item$1,
159
+ "switch": "_switch_sqeas_13"
160
+ };
82
161
 
83
- const EmitterOptionsForm = ({ library, options, optionsChanged, }) => {
84
- const emitterOptionsSchema = library.definition?.emitter?.options?.properties;
85
- if (emitterOptionsSchema === undefined) {
86
- return jsx(Fragment, { children: "\"No options\"" });
87
- }
88
- const entries = Object.entries(emitterOptionsSchema);
89
- const handleChange = useCallback(({ name, value }) => {
90
- optionsChanged({
91
- ...options,
92
- [library.name]: {
93
- ...options[library.name],
94
- [name]: value,
95
- },
96
- });
97
- }, [options, optionsChanged]);
98
- return (jsx("div", { className: style$9["form"], children: entries.map(([key, value]) => {
99
- return (jsx("div", { className: style$9["form-item"], children: jsx(JsonSchemaPropertyInput, { emitterOptions: options[library.name] ?? {}, name: key, prop: value, onChange: handleChange }) }, key));
100
- }) }));
101
- };
102
- const JsonSchemaPropertyInput = ({ emitterOptions, name, prop, onChange, }) => {
103
- const prettyName = useMemo(() => name[0].toUpperCase() + name.slice(1).replace(/-/g, " "), [name]);
104
- const inputId = useId("input");
105
- const value = emitterOptions[name] ?? prop.default;
106
- const handleChange = useCallback((_, data) => onChange({ name, value: "value" in data ? data.value : data.checked }), [onChange]);
107
- switch (prop.type) {
108
- case "boolean":
109
- return (jsx(Switch, { className: style$9["switch"], label: prettyName, labelPosition: "above", checked: value, onChange: handleChange }));
110
- case "string":
111
- default:
112
- return (jsxs("div", { className: style$9["item"], children: [jsx(Label, { htmlFor: inputId, title: name, children: prettyName }), prop.enum ? (jsx(RadioGroup, { layout: "horizontal", id: inputId, value: value, onChange: handleChange, children: prop.enum.map((x) => (jsx(Radio, { value: x, label: x }, x))) })) : (jsx(Input, { id: inputId, value: value, onChange: handleChange }))] }));
113
- }
162
+ const EmitterOptionsForm = ({
163
+ library,
164
+ options,
165
+ optionsChanged
166
+ }) => {
167
+ const emitterOptionsSchema = library.definition?.emitter?.options?.properties;
168
+ if (emitterOptionsSchema === void 0) {
169
+ return /* @__PURE__ */ jsx(Fragment, { children: '"No options"' });
170
+ }
171
+ const entries = Object.entries(emitterOptionsSchema);
172
+ const handleChange = useCallback(
173
+ ({ name, value }) => {
174
+ optionsChanged({
175
+ ...options,
176
+ [library.name]: {
177
+ ...options[library.name],
178
+ [name]: value
179
+ }
180
+ });
181
+ },
182
+ [options, optionsChanged]
183
+ );
184
+ return /* @__PURE__ */ jsx("div", { className: style$9["form"], children: entries.map(([key, value]) => {
185
+ return /* @__PURE__ */ jsx("div", { className: style$9["form-item"], children: /* @__PURE__ */ jsx(
186
+ JsonSchemaPropertyInput,
187
+ {
188
+ emitterOptions: options[library.name] ?? {},
189
+ name: key,
190
+ prop: value,
191
+ onChange: handleChange
192
+ }
193
+ ) }, key);
194
+ }) });
195
+ };
196
+ const JsonSchemaPropertyInput = ({
197
+ emitterOptions,
198
+ name,
199
+ prop,
200
+ onChange
201
+ }) => {
202
+ const prettyName = useMemo(
203
+ () => name[0].toUpperCase() + name.slice(1).replace(/-/g, " "),
204
+ [name]
205
+ );
206
+ const inputId = useId("input");
207
+ const value = emitterOptions[name] ?? prop.default;
208
+ const handleChange = useCallback(
209
+ (_, data) => onChange({ name, value: "value" in data ? data.value : data.checked }),
210
+ [onChange]
211
+ );
212
+ switch (prop.type) {
213
+ case "boolean":
214
+ return /* @__PURE__ */ jsx(
215
+ Switch,
216
+ {
217
+ className: style$9["switch"],
218
+ label: prettyName,
219
+ labelPosition: "above",
220
+ checked: value,
221
+ onChange: handleChange
222
+ }
223
+ );
224
+ case "string":
225
+ default:
226
+ return /* @__PURE__ */ jsxs("div", { className: style$9["item"], children: [
227
+ /* @__PURE__ */ jsx(Label, { htmlFor: inputId, title: name, children: prettyName }),
228
+ prop.enum ? /* @__PURE__ */ jsx(RadioGroup, { layout: "horizontal", id: inputId, value, onChange: handleChange, children: prop.enum.map((x) => /* @__PURE__ */ jsx(Radio, { value: x, label: x }, x)) }) : /* @__PURE__ */ jsx(Input, { id: inputId, value, onChange: handleChange })
229
+ ] });
230
+ }
114
231
  };
115
232
 
116
- const LinterForm = ({ libraries, linterRuleSet, onLinterRuleSetChanged, }) => {
117
- const rulesets = Object.values(libraries).flatMap((lib) => {
118
- // eslint-disable-next-line deprecation/deprecation
119
- const linter = lib.linter ?? lib.definition?.linter;
120
- return Object.keys(linter?.ruleSets ?? {}).map((x) => `${lib.name}/${x}`);
233
+ const LinterForm = ({
234
+ libraries,
235
+ linterRuleSet,
236
+ onLinterRuleSetChanged
237
+ }) => {
238
+ const rulesets = Object.values(libraries).flatMap((lib) => {
239
+ const linter = lib.linter ?? lib.definition?.linter;
240
+ return Object.keys(linter?.ruleSets ?? {}).map((x) => `${lib.name}/${x}`);
241
+ });
242
+ if (rulesets.length === 0) {
243
+ return /* @__PURE__ */ jsx(Fragment, { children: "No ruleset available" });
244
+ }
245
+ const handleChange = (ruleSet, checked) => {
246
+ const ruleSets = linterRuleSet.extends ?? [];
247
+ const updatedRuleSets = checked ? [...ruleSets, ruleSet] : ruleSets.filter((x) => x !== ruleSet);
248
+ onLinterRuleSetChanged({
249
+ extends: updatedRuleSets
121
250
  });
122
- if (rulesets.length === 0) {
123
- return jsx(Fragment, { children: "No ruleset available" });
124
- }
125
- const handleChange = (ruleSet, checked) => {
126
- const ruleSets = linterRuleSet.extends ?? [];
127
- const updatedRuleSets = checked
128
- ? [...ruleSets, ruleSet]
129
- : ruleSets.filter((x) => x !== ruleSet);
130
- onLinterRuleSetChanged({
131
- extends: updatedRuleSets,
132
- });
133
- };
134
- return (jsx(Fragment, { children: rulesets.map((ruleSet) => {
135
- return (jsx(RuleSetCheckbox, { ruleSet: ruleSet, checked: linterRuleSet.extends?.includes(ruleSet), onChange: handleChange }, ruleSet));
136
- }) }));
251
+ };
252
+ return /* @__PURE__ */ jsx(Fragment, { children: rulesets.map((ruleSet) => {
253
+ return /* @__PURE__ */ jsx(
254
+ RuleSetCheckbox,
255
+ {
256
+ ruleSet,
257
+ checked: linterRuleSet.extends?.includes(ruleSet),
258
+ onChange: handleChange
259
+ },
260
+ ruleSet
261
+ );
262
+ }) });
137
263
  };
138
264
  const RuleSetCheckbox = ({ ruleSet, checked, onChange }) => {
139
- const handleChange = useCallback((_, data) => {
140
- onChange(ruleSet, !!data.checked);
141
- }, [ruleSet, checked, onChange]);
142
- return jsx(Checkbox, { label: ruleSet, checked: checked, onChange: handleChange });
265
+ const handleChange = useCallback(
266
+ (_, data) => {
267
+ onChange(ruleSet, !!data.checked);
268
+ },
269
+ [ruleSet, checked, onChange]
270
+ );
271
+ return /* @__PURE__ */ jsx(Checkbox, { label: ruleSet, checked, onChange: handleChange });
143
272
  };
144
273
 
145
- const CompilerSettings = ({ selectedEmitter, host, options, onOptionsChanged, }) => {
146
- const emitterOptionsChanged = useCallback((emitterOptions) => {
147
- onOptionsChanged({
148
- ...options,
149
- options: emitterOptions,
150
- });
151
- }, [options]);
152
- const library = host.libraries[selectedEmitter];
153
- const linterRuleSet = options.linterRuleSet ?? {};
154
- const linterRuleSetChanged = useCallback((linterRuleSet) => {
155
- onOptionsChanged({
156
- ...options,
157
- linterRuleSet,
158
- });
159
- }, [options]);
160
- return (jsxs("div", { children: [jsxs(Fragment, { children: ["Emitter: ", selectedEmitter] }), jsx(Divider, { style: { marginTop: 20 } }), jsx("h3", { children: "Options" }), library && (jsx(EmitterOptionsForm, { library: library, options: options.options ?? {}, optionsChanged: emitterOptionsChanged })), jsx(Divider, { style: { marginTop: 20 } }), jsx("h3", { children: "Linter" }), jsx(LinterForm, { libraries: host.libraries, linterRuleSet: linterRuleSet, onLinterRuleSetChanged: linterRuleSetChanged })] }));
274
+ const CompilerSettings = ({
275
+ selectedEmitter,
276
+ host,
277
+ options,
278
+ onOptionsChanged
279
+ }) => {
280
+ const emitterOptionsChanged = useCallback(
281
+ (emitterOptions) => {
282
+ onOptionsChanged({
283
+ ...options,
284
+ options: emitterOptions
285
+ });
286
+ },
287
+ [options]
288
+ );
289
+ const library = host.libraries[selectedEmitter];
290
+ const linterRuleSet = options.linterRuleSet ?? {};
291
+ const linterRuleSetChanged = useCallback(
292
+ (linterRuleSet2) => {
293
+ onOptionsChanged({
294
+ ...options,
295
+ linterRuleSet: linterRuleSet2
296
+ });
297
+ },
298
+ [options]
299
+ );
300
+ return /* @__PURE__ */ jsxs("div", { children: [
301
+ /* @__PURE__ */ jsxs(Fragment, { children: [
302
+ "Emitter: ",
303
+ selectedEmitter
304
+ ] }),
305
+ /* @__PURE__ */ jsx(Divider, { style: { marginTop: 20 } }),
306
+ /* @__PURE__ */ jsx("h3", { children: "Options" }),
307
+ library && /* @__PURE__ */ jsx(
308
+ EmitterOptionsForm,
309
+ {
310
+ library,
311
+ options: options.options ?? {},
312
+ optionsChanged: emitterOptionsChanged
313
+ }
314
+ ),
315
+ /* @__PURE__ */ jsx(Divider, { style: { marginTop: 20 } }),
316
+ /* @__PURE__ */ jsx("h3", { children: "Linter" }),
317
+ /* @__PURE__ */ jsx(
318
+ LinterForm,
319
+ {
320
+ libraries: host.libraries,
321
+ linterRuleSet,
322
+ onLinterRuleSetChanged: linterRuleSetChanged
323
+ }
324
+ )
325
+ ] });
161
326
  };
162
327
 
163
- const CompilerSettingsDialogButton = ({ selectedEmitter, compilerOptions, onCompilerOptionsChange, }) => {
164
- const { host } = usePlaygroundContext();
165
- return (jsxs(Dialog, { children: [jsx(DialogTrigger, { children: jsx(ToolbarButton, { icon: jsx(Settings24Regular, {}), "aria-label": "Open Settings" }) }), jsx(DialogSurface, { children: jsxs(DialogBody, { children: [jsx(DialogTitle, { children: "Settings" }), jsx(DialogContent, { children: jsx(CompilerSettings, { host: host, selectedEmitter: selectedEmitter, options: compilerOptions, onOptionsChanged: onCompilerOptionsChange }) })] }) })] }));
328
+ const CompilerSettingsDialogButton = ({
329
+ selectedEmitter,
330
+ compilerOptions,
331
+ onCompilerOptionsChange
332
+ }) => {
333
+ const { host } = usePlaygroundContext();
334
+ return /* @__PURE__ */ jsxs(Dialog, { children: [
335
+ /* @__PURE__ */ jsx(DialogTrigger, { children: /* @__PURE__ */ jsx(ToolbarButton, { icon: /* @__PURE__ */ jsx(Settings24Regular, {}), "aria-label": "Open Settings" }) }),
336
+ /* @__PURE__ */ jsx(DialogSurface, { children: /* @__PURE__ */ jsxs(DialogBody, { children: [
337
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Settings" }),
338
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(
339
+ CompilerSettings,
340
+ {
341
+ host,
342
+ selectedEmitter,
343
+ options: compilerOptions,
344
+ onOptionsChanged: onCompilerOptionsChange
345
+ }
346
+ ) })
347
+ ] }) })
348
+ ] });
166
349
  };
167
350
 
168
- var style$8 = {"bar":"editor-command-bar-module_bar__5q4D5","divider":"editor-command-bar-module_divider__iDahk","spacer":"editor-command-bar-module_spacer__hlHE9"};
351
+ const bar = "_bar_15c2c_1";
352
+ const divider = "_divider_15c2c_5";
353
+ const spacer = "_spacer_15c2c_9";
354
+ const style$8 = {
355
+ bar: bar,
356
+ divider: divider,
357
+ spacer: spacer
358
+ };
169
359
 
170
- const EditorCommandBar = ({ documentationUrl, saveCode, formatCode, fileBug, host, selectedEmitter, onSelectedEmitterChange, compilerOptions, onCompilerOptionsChange, samples, selectedSampleName, onSelectedSampleNameChange, }) => {
171
- const documentation = documentationUrl ? (jsx("label", { children: jsx(Link, { href: documentationUrl, target: "_blank", children: "Docs" }) })) : undefined;
172
- const bugButton = fileBug ? jsx(FileBugButton, { onClick: fileBug }) : undefined;
173
- const emitters = useMemo(() => Object.values(host.libraries)
174
- .filter((x) => x.isEmitter)
175
- .map((x) => x.name), [host.libraries]);
176
- return (jsx("div", { className: style$8["bar"], children: jsxs(Toolbar, { children: [jsx(Tooltip, { content: "Save", relationship: "description", withArrow: true, children: jsx(ToolbarButton, { "aria-label": "Save", icon: jsx(Save16Regular, {}), onClick: saveCode }) }), jsx(Tooltip, { content: "Format", relationship: "description", withArrow: true, children: jsx(ToolbarButton, { "aria-label": "Format", icon: jsx(Broom16Filled, {}), onClick: formatCode }) }), samples && (jsxs(Fragment, { children: [jsx(SamplesDropdown, { samples: samples, selectedSampleName: selectedSampleName, onSelectedSampleNameChange: onSelectedSampleNameChange }), jsx("div", { className: style$8["spacer"] })] })), jsx(EmitterDropdown, { emitters: emitters, onSelectedEmitterChange: onSelectedEmitterChange, selectedEmitter: selectedEmitter }), documentation && (jsxs(Fragment, { children: [jsx("div", { className: style$8["spacer"] }), documentation] })), jsx("div", { className: style$8["divider"] }), bugButton, jsx(CompilerSettingsDialogButton, { compilerOptions: compilerOptions, onCompilerOptionsChange: onCompilerOptionsChange, selectedEmitter: selectedEmitter })] }) }));
360
+ const EditorCommandBar = ({
361
+ documentationUrl,
362
+ saveCode,
363
+ formatCode,
364
+ fileBug,
365
+ host,
366
+ selectedEmitter,
367
+ onSelectedEmitterChange,
368
+ compilerOptions,
369
+ onCompilerOptionsChange,
370
+ samples,
371
+ selectedSampleName,
372
+ onSelectedSampleNameChange
373
+ }) => {
374
+ const documentation = documentationUrl ? /* @__PURE__ */ jsx("label", { children: /* @__PURE__ */ jsx(Link, { href: documentationUrl, target: "_blank", children: "Docs" }) }) : void 0;
375
+ const bugButton = fileBug ? /* @__PURE__ */ jsx(FileBugButton, { onClick: fileBug }) : void 0;
376
+ const emitters = useMemo(
377
+ () => Object.values(host.libraries).filter((x) => x.isEmitter).map((x) => x.name),
378
+ [host.libraries]
379
+ );
380
+ return /* @__PURE__ */ jsx("div", { className: style$8["bar"], children: /* @__PURE__ */ jsxs(Toolbar, { children: [
381
+ /* @__PURE__ */ jsx(Tooltip, { content: "Save", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { "aria-label": "Save", icon: /* @__PURE__ */ jsx(Save16Regular, {}), onClick: saveCode }) }),
382
+ /* @__PURE__ */ jsx(Tooltip, { content: "Format", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { "aria-label": "Format", icon: /* @__PURE__ */ jsx(Broom16Filled, {}), onClick: formatCode }) }),
383
+ samples && /* @__PURE__ */ jsxs(Fragment, { children: [
384
+ /* @__PURE__ */ jsx(
385
+ SamplesDropdown,
386
+ {
387
+ samples,
388
+ selectedSampleName,
389
+ onSelectedSampleNameChange
390
+ }
391
+ ),
392
+ /* @__PURE__ */ jsx("div", { className: style$8["spacer"] })
393
+ ] }),
394
+ /* @__PURE__ */ jsx(
395
+ EmitterDropdown,
396
+ {
397
+ emitters,
398
+ onSelectedEmitterChange,
399
+ selectedEmitter
400
+ }
401
+ ),
402
+ documentation && /* @__PURE__ */ jsxs(Fragment, { children: [
403
+ /* @__PURE__ */ jsx("div", { className: style$8["spacer"] }),
404
+ documentation
405
+ ] }),
406
+ /* @__PURE__ */ jsx("div", { className: style$8["divider"] }),
407
+ bugButton,
408
+ /* @__PURE__ */ jsx(
409
+ CompilerSettingsDialogButton,
410
+ {
411
+ compilerOptions,
412
+ onCompilerOptionsChange,
413
+ selectedEmitter
414
+ }
415
+ )
416
+ ] }) });
177
417
  };
178
418
  const FileBugButton = ({ onClick }) => {
179
- return (jsx(Tooltip, { content: "File Bug Report", relationship: "description", withArrow: true, children: jsx(ToolbarButton, { appearance: "subtle", "aria-label": "File Bug Report", icon: jsx(Bug16Regular, {}), onClick: onClick }) }));
419
+ return /* @__PURE__ */ jsx(Tooltip, { content: "File Bug Report", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(
420
+ ToolbarButton,
421
+ {
422
+ appearance: "subtle",
423
+ "aria-label": "File Bug Report",
424
+ icon: /* @__PURE__ */ jsx(Bug16Regular, {}),
425
+ onClick
426
+ }
427
+ ) });
180
428
  };
181
429
 
182
430
  const DefaultFooter = () => {
183
- return (jsx(Footer, { children: jsx(FooterVersionItem, {}) }));
431
+ return /* @__PURE__ */ jsx(Footer, { children: /* @__PURE__ */ jsx(FooterVersionItem, {}) });
184
432
  };
185
433
 
186
434
  const Editor = ({ model, options, actions, onMount }) => {
187
- const editorContainerRef = useRef(null);
188
- const editorRef = useRef(null);
189
- useEffect(() => {
190
- editorRef.current = editor.create(editorContainerRef.current, {
191
- model,
192
- automaticLayout: true,
193
- ...options,
194
- });
195
- onMount?.({ editor: editorRef.current });
196
- }, []);
197
- useEffect(() => {
198
- editor.setTheme(options.theme ?? "typespec");
199
- }, [options.theme]);
200
- useEffect(() => {
201
- const disposables = [];
202
- for (const command of actions ?? []) {
203
- disposables.push(editorRef.current.addAction(command));
204
- }
205
- return () => {
206
- disposables.forEach((x) => x.dispose());
207
- };
208
- }, [actions]);
209
- useEffect(() => {
210
- if (editorRef.current) {
211
- editorRef.current.setModel(model);
212
- }
213
- }, [model]);
214
- return (jsx("div", { className: "monaco-editor-container", style: { width: "100%", height: "100%", overflow: "hidden" }, ref: editorContainerRef, "data-tabster": '{"uncontrolled": {}}' // https://github.com/microsoft/tabster/issues/316
215
- }));
435
+ const editorContainerRef = useRef(null);
436
+ const editorRef = useRef(null);
437
+ useEffect(() => {
438
+ editorRef.current = editor.create(editorContainerRef.current, {
439
+ model,
440
+ automaticLayout: true,
441
+ ...options
442
+ });
443
+ onMount?.({ editor: editorRef.current });
444
+ }, []);
445
+ useEffect(() => {
446
+ editor.setTheme(options.theme ?? "typespec");
447
+ }, [options.theme]);
448
+ useEffect(() => {
449
+ const disposables = [];
450
+ for (const command of actions ?? []) {
451
+ disposables.push(editorRef.current.addAction(command));
452
+ }
453
+ return () => {
454
+ disposables.forEach((x) => x.dispose());
455
+ };
456
+ }, [actions]);
457
+ useEffect(() => {
458
+ if (editorRef.current) {
459
+ editorRef.current.setModel(model);
460
+ }
461
+ }, [model]);
462
+ return /* @__PURE__ */ jsx(
463
+ "div",
464
+ {
465
+ className: "monaco-editor-container",
466
+ style: { width: "100%", height: "100%" },
467
+ ref: editorContainerRef,
468
+ "data-tabster": '{"uncontrolled": {}}'
469
+ }
470
+ );
216
471
  };
217
472
  function useMonacoModel(uri, language) {
218
- return useMemo(() => {
219
- const monacoUri = Uri.parse(uri);
220
- return editor.getModel(monacoUri) ?? editor.createModel("", language, monacoUri);
221
- }, [uri, language]);
473
+ return useMemo(() => {
474
+ const monacoUri = Uri.parse(uri);
475
+ return editor.getModel(monacoUri) ?? editor.createModel("", language, monacoUri);
476
+ }, [uri, language]);
222
477
  }
223
478
 
224
- /**
225
- * Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
226
- * text box string.
227
- * @param controlledValue - The controlled value passed in the props. This value will always be used if provided,
228
- * and the internal state will be updated to reflect it.
229
- * @param defaultUncontrolledValue - Initial value for the internal state in the uncontrolled case.
230
- * @returns An array of the current value and an updater callback. Like `React.useState`, the updater
231
- * callback always has the same identity, and it can take either a new value, or a function which
232
- * is passed the previous value and returns the new value.
233
- * @see https://reactjs.org/docs/uncontrolled-components.html
234
- */
235
479
  function useControllableValue(controlledValue, defaultUncontrolledValue, onChange) {
236
- const [value, setValue] = useState(defaultUncontrolledValue);
237
- const isControlled = useMemo(() => controlledValue !== undefined, []);
238
- const currentValue = isControlled ? controlledValue : value;
239
- // Duplicate the current value and onChange in refs so they're accessible from
240
- // setValueOrCallOnChange without creating a new callback every time
241
- const valueRef = useRef(currentValue);
242
- const onChangeRef = useRef(onChange);
243
- useEffect(() => {
244
- valueRef.current = currentValue;
245
- onChangeRef.current = onChange;
246
- });
247
- // To match the behavior of the setter returned by React.useState, this callback's identity
248
- // should never change. This means it MUST NOT directly reference variables that can change.
249
- const setValueOrCallOnChange = useMemo(() => (update) => {
250
- // Assuming here that TValue is not a function, because a controllable value will typically
251
- // be something a user can enter as input
252
- const newValue = typeof update === "function" ? update(valueRef.current) : update;
253
- if (onChangeRef.current) {
254
- onChangeRef.current(newValue);
255
- }
256
- if (!isControlled) {
257
- setValue(newValue);
258
- }
259
- }, []);
260
- return [currentValue, setValueOrCallOnChange];
261
- }
262
- function useAsyncMemo(callback, defaultValue, deps) {
263
- const [value, setValue] = useState(defaultValue);
264
- useEffect(() => {
265
- callback()
266
- .then(setValue)
267
- // eslint-disable-next-line no-console
268
- .catch(() => console.error("Failed to load async memo"));
269
- }, deps);
270
- return value;
480
+ const [value, setValue] = useState(defaultUncontrolledValue);
481
+ const isControlled = useMemo(() => controlledValue !== void 0, []);
482
+ const currentValue = isControlled ? controlledValue : value;
483
+ const valueRef = useRef(currentValue);
484
+ const onChangeRef = useRef(onChange);
485
+ useEffect(() => {
486
+ valueRef.current = currentValue;
487
+ onChangeRef.current = onChange;
488
+ });
489
+ const setValueOrCallOnChange = useMemo(
490
+ () => (update) => {
491
+ const newValue = typeof update === "function" ? update(valueRef.current) : update;
492
+ if (onChangeRef.current) {
493
+ onChangeRef.current(newValue);
494
+ }
495
+ if (!isControlled) {
496
+ setValue(newValue);
497
+ }
498
+ },
499
+ []
500
+ );
501
+ return [currentValue, setValueOrCallOnChange];
271
502
  }
272
503
 
273
- var style$7 = {"file-output":"file-output-module_file-output__YBaE7","viewer-selector":"file-output-module_viewer-selector__fNWoo"};
504
+ const TypeSpecEditor = ({
505
+ actions,
506
+ options,
507
+ ...other
508
+ }) => {
509
+ const resolvedOptions = {
510
+ "semanticHighlighting.enabled": true,
511
+ automaticLayout: true,
512
+ tabSize: 2,
513
+ minimap: {
514
+ enabled: false
515
+ },
516
+ ...options
517
+ };
518
+ return /* @__PURE__ */ jsx(Editor, { actions, options: resolvedOptions, ...other });
519
+ };
520
+ const OutputEditor = ({ filename, value, editorOptions }) => {
521
+ if (filename === "") {
522
+ return null;
523
+ }
524
+ const options = {
525
+ ...editorOptions,
526
+ readOnly: true,
527
+ automaticLayout: true,
528
+ minimap: {
529
+ enabled: false
530
+ }
531
+ };
532
+ const model = useMonacoModel(filename);
533
+ model.setValue(value);
534
+ return /* @__PURE__ */ jsx(Editor, { model, options });
535
+ };
536
+
537
+ const style$7 = {
538
+ "file-output": "_file-output_jzw6j_1",
539
+ "viewer-selector": "_viewer-selector_jzw6j_5"
540
+ };
274
541
 
275
- /**
276
- * Display a file output using different viewers.
277
- */
278
542
  const FileOutput = ({ filename, content, viewers }) => {
279
- if (viewers.length === 0) {
280
- return jsx(Fragment, { children: "No viewers" });
281
- }
282
- else if (viewers.length === 1) {
283
- return viewers[0].render({ filename, content });
284
- }
285
- const [selected, setSelected] = useState(viewers[0].key);
286
- const handleSelected = useCallback((_, data) => {
287
- setSelected(data.value);
288
- }, [selected]);
289
- const selectedRender = useMemo(() => {
290
- return viewers.find((x) => x.key === selected)?.render;
291
- }, [selected, viewers]);
292
- return (jsxs("div", { className: style$7["file-output"], children: [jsx("div", { className: style$7["viewer-selector"], children: jsx(Select, { value: selected, onChange: handleSelected, "aria-label": "Select viewer", children: viewers.map(({ key, label }) => (jsx("option", { value: key, children: label }, key))) }) }), selectedRender && selectedRender({ filename, content })] }));
293
- };
294
-
295
- var style$6 = {"tabs":"output-tabs-module_tabs__MFCRl","tab-divider":"output-tabs-module_tab-divider__9Fv--","tab":"output-tabs-module_tab__FJ78k","tab--selected":"output-tabs-module_tab--selected__GjCZY"};
296
-
297
- const OutputTabs = ({ tabs, selected, onSelect }) => {
298
- const [leftTabs, rightTabs] = chunk(tabs, (x) => x.align === "left");
299
- const onTabSelect = useCallback((event, data) => {
300
- onSelect(data.value);
301
- }, [onSelect]);
302
- return (jsxs(TabList, { selectedValue: selected, onTabSelect: onTabSelect, className: style$6["tabs"], children: [leftTabs.map((tab) => {
303
- return (jsx(OutputTabEl, { value: tab.id, className: tab.id === selected && style$6["tab--selected"], children: tab.name }, tab.id));
304
- }), jsx("div", { className: style$6["tab-divider"] }), rightTabs.map((tab) => {
305
- return (jsx(OutputTabEl, { value: tab.id, className: tab.id === selected && style$6["tab--selected"], children: tab.name }, tab.id));
306
- })] }));
307
- };
308
- const OutputTabEl = (props) => {
309
- return jsx(Tab, { ...props, className: mergeClasses(style$6["tab"], props.className) });
310
- };
311
- function chunk(items, condition) {
312
- const match = [];
313
- const unMatch = [];
314
- for (const item of items) {
315
- if (condition(item)) {
316
- match.push(item);
317
- }
318
- else {
319
- unMatch.push(item);
320
- }
321
- }
322
- return [match, unMatch];
323
- }
543
+ const resolvedViewers = useMemo(
544
+ () => ({
545
+ [RawFileViewer.key]: RawFileViewer,
546
+ ...viewers
547
+ }),
548
+ [viewers]
549
+ );
550
+ const keys = Object.keys(resolvedViewers);
551
+ if (keys.length === 0) {
552
+ return /* @__PURE__ */ jsx(Fragment, { children: "No viewers" });
553
+ } else if (keys.length === 1) {
554
+ return resolvedViewers[keys[0]].render({ filename, content });
555
+ }
556
+ const [selected, setSelected] = useState(keys[0]);
557
+ const handleSelected = useCallback(
558
+ (_, data) => {
559
+ setSelected(data.value);
560
+ },
561
+ [selected]
562
+ );
563
+ const selectedRender = useMemo(() => {
564
+ return resolvedViewers[selected].render;
565
+ }, [selected, resolvedViewers]);
566
+ return /* @__PURE__ */ jsxs("div", { className: style$7["file-output"], children: [
567
+ /* @__PURE__ */ jsx("div", { className: style$7["viewer-selector"], children: /* @__PURE__ */ jsx(Select, { value: selected, onChange: handleSelected, "aria-label": "Select viewer", children: Object.values(resolvedViewers).map(({ key, label }) => /* @__PURE__ */ jsx("option", { value: key, children: label }, key)) }) }),
568
+ selectedRender && selectedRender({ filename, content })
569
+ ] });
570
+ };
571
+ const RawFileViewer = {
572
+ key: "raw",
573
+ label: "File",
574
+ render: ({ filename, content }) => /* @__PURE__ */ jsx(OutputEditor, { filename, value: content })
575
+ };
324
576
 
325
- const TypeSpecEditor = ({ actions, options, ...other }) => {
326
- const resolvedOptions = {
327
- "semanticHighlighting.enabled": true,
328
- automaticLayout: true,
329
- tabSize: 2,
330
- minimap: {
331
- enabled: false,
332
- },
333
- ...options,
334
- };
335
- return jsx(Editor, { actions: actions, options: resolvedOptions, ...other });
577
+ const tabs = "_tabs_1x6x2_1";
578
+ const tab = "_tab_1x6x2_1";
579
+ const style$6 = {
580
+ tabs: tabs,
581
+ "tab-divider": "_tab-divider_1x6x2_7",
582
+ tab: tab,
583
+ "tab--selected": "_tab--selected_1x6x2_18"
336
584
  };
337
- const OutputEditor = ({ filename, value, editorOptions }) => {
338
- if (filename === "") {
339
- return null;
340
- }
341
- const options = {
342
- ...editorOptions,
343
- readOnly: true,
344
- automaticLayout: true,
345
- minimap: {
346
- enabled: false,
347
- },
348
- };
349
- const model = useMonacoModel(filename);
350
- model.setValue(value);
351
- return jsx(Editor, { model: model, options: options });
585
+
586
+ const OutputTabs = ({
587
+ filenames,
588
+ selected,
589
+ onSelect
590
+ }) => {
591
+ const onTabSelect = useCallback(
592
+ (event, data) => {
593
+ onSelect(data.value);
594
+ },
595
+ [onSelect]
596
+ );
597
+ return /* @__PURE__ */ jsx(TabList, { selectedValue: selected, onTabSelect, className: style$6["tabs"], children: filenames.map((filename) => {
598
+ return /* @__PURE__ */ jsx(
599
+ Tab,
600
+ {
601
+ value: filename,
602
+ className: mergeClasses(style$6["tab"], filename === selected && style$6["tab--selected"]),
603
+ children: filename
604
+ },
605
+ filename
606
+ );
607
+ }) });
352
608
  };
353
609
 
354
- var style$5 = {"output-view":"output-view-module_output-view__uT5Ae","output-content":"output-view-module_output-content__Lis-G","type-graph-viewer":"output-view-module_type-graph-viewer__tUDEV"};
610
+ const style$5 = {
611
+ "output-view": "_output-view_18pnu_1",
612
+ "file-viewer": "_file-viewer_18pnu_6",
613
+ "output-content": "_output-content_18pnu_12",
614
+ "file-viewer-content": "_file-viewer-content_18pnu_16",
615
+ "type-graph-viewer": "_type-graph-viewer_18pnu_21",
616
+ "viewer-tabs-container": "_viewer-tabs-container_18pnu_26"
617
+ };
355
618
 
356
- const OutputView = ({ compilationState, viewers, editorOptions, }) => {
357
- if (compilationState === undefined) {
358
- return jsx(Fragment, {});
619
+ const FileViewerComponent = ({
620
+ program,
621
+ outputFiles,
622
+ fileViewers
623
+ }) => {
624
+ const [filename, setFilename] = useState("");
625
+ const [content, setContent] = useState("");
626
+ useEffect(() => {
627
+ if (outputFiles.length > 0) {
628
+ const fileStillThere = outputFiles.find((x) => x === filename);
629
+ const newFilename = fileStillThere ?? outputFiles[0];
630
+ setFilename(newFilename);
631
+ void loadOutputFile(fileStillThere ?? outputFiles[0]);
632
+ } else {
633
+ setFilename("");
359
634
  }
360
- if ("internalCompilerError" in compilationState) {
361
- return jsx(Fragment, {});
362
- }
363
- return (jsx(OutputViewInternal, { compilationResult: compilationState, viewers: viewers, editorOptions: editorOptions }));
635
+ }, [program, outputFiles]);
636
+ async function loadOutputFile(path) {
637
+ const contents = await program.host.readFile("./tsp-output/" + path);
638
+ setContent(contents.text);
639
+ }
640
+ const handleTabSelection = useCallback(
641
+ (newFilename) => {
642
+ setFilename(newFilename);
643
+ void loadOutputFile(newFilename);
644
+ },
645
+ [setFilename]
646
+ );
647
+ if (outputFiles.length === 0) {
648
+ return /* @__PURE__ */ jsx(Fragment, { children: "No files emitted." });
649
+ }
650
+ return /* @__PURE__ */ jsxs("div", { className: style$5["file-viewer"], children: [
651
+ /* @__PURE__ */ jsx(OutputTabs, { filenames: outputFiles, selected: filename, onSelect: handleTabSelection }),
652
+ /* @__PURE__ */ jsx("div", { className: style$5["file-viewer-content"], children: /* @__PURE__ */ jsx(FileOutput, { filename, content, viewers: fileViewers }) })
653
+ ] });
364
654
  };
365
- const OutputViewInternal = ({ compilationResult, viewers, editorOptions }) => {
366
- const { program, outputFiles } = compilationResult;
367
- const [viewSelection, setViewSelection] = useState({
368
- type: "file",
369
- filename: "",
370
- content: "",
371
- });
372
- useEffect(() => {
373
- if (viewSelection.type === "file") {
374
- if (outputFiles.length > 0) {
375
- const fileStillThere = outputFiles.find((x) => x === viewSelection.filename);
376
- void loadOutputFile(fileStillThere ?? outputFiles[0]);
377
- }
378
- else {
379
- setViewSelection({ type: "file", filename: viewSelection.filename, content: "" });
380
- }
381
- }
382
- }, [program, outputFiles]);
383
- async function loadOutputFile(path) {
384
- const contents = await program.host.readFile("./tsp-output/" + path);
385
- setViewSelection({ type: "file", filename: path, content: contents.text });
655
+ function createFileViewer(fileViewers) {
656
+ const viewerMap = Object.fromEntries(fileViewers.map((x) => [x.key, x]));
657
+ return {
658
+ key: "file-output",
659
+ label: "Output explorer",
660
+ icon: /* @__PURE__ */ jsx(FolderListRegular, {}),
661
+ render: (props) => {
662
+ return /* @__PURE__ */ jsx(FileViewerComponent, { ...props, fileViewers: viewerMap });
386
663
  }
387
- const diagnostics = program.diagnostics;
388
- const tabs = useMemo(() => {
389
- return [
390
- ...outputFiles.map((x) => ({
391
- align: "left",
392
- name: x,
393
- id: x,
394
- })),
395
- { id: "type-graph", name: "Type Graph", align: "right" },
396
- ];
397
- }, [outputFiles, diagnostics]);
398
- const handleTabSelection = useCallback((tabId) => {
399
- if (tabId === "type-graph") {
400
- setViewSelection({ type: "type-graph" });
401
- }
402
- else {
403
- void loadOutputFile(tabId);
404
- }
405
- }, []);
406
- return (jsxs("div", { className: style$5["output-view"], children: [jsx(OutputTabs, { tabs: tabs, selected: viewSelection.type === "file" ? viewSelection.filename : viewSelection.type, onSelect: handleTabSelection }), jsx("div", { className: style$5["output-content"], children: jsx(OutputContent, { viewSelection: viewSelection, editorOptions: editorOptions, program: program, viewers: viewers }) })] }));
407
- };
408
- function getRawFileViewer(editorOptions) {
409
- return {
410
- key: "raw",
411
- label: "File",
412
- render: ({ filename, content }) => (jsx(OutputEditor, { editorOptions: editorOptions, filename: filename, value: content })),
413
- };
664
+ };
414
665
  }
415
- const OutputContent = ({ viewSelection, program, viewers, editorOptions, }) => {
416
- const resolvedViewers = useMemo(() => [getRawFileViewer(editorOptions), ...(viewers ?? [])], [viewers]);
417
- switch (viewSelection.type) {
418
- case "file":
419
- return (jsx(FileOutput, { filename: viewSelection.filename, content: viewSelection.content, viewers: resolvedViewers }));
420
- default:
421
- return program && jsx(TypeGraphViewer, { program: program });
422
- }
423
- };
424
- const TypeGraphViewer = ({ program }) => {
425
- return (jsx("div", { className: style$5["type-graph-viewer"], children: jsx(ColorProvider, { colors: TypeGraphColors, children: jsx(TypeSpecProgramViewer, { program: program }) }) }));
666
+
667
+ const TypeGraphViewerComponent = ({ program }) => {
668
+ return /* @__PURE__ */ jsx("div", { className: style$5["type-graph-viewer"], children: /* @__PURE__ */ jsx(ColorProvider, { colors: TypeGraphColors, children: /* @__PURE__ */ jsx(TypeSpecProgramViewer, { program }) }) });
426
669
  };
427
670
  const TypeGraphColors = {
428
- background: tokens.colorNeutralBackground1,
429
- typeKind: tokens.colorPaletteBerryForeground2,
430
- typeName: tokens.colorNeutralForeground2,
431
- dataKey: tokens.colorNeutralForeground2,
432
- ref: tokens.colorBrandForeground1,
433
- literal: tokens.colorPaletteLightGreenForeground2,
434
- indentationGuide: tokens.colorNeutralForeground4,
435
- property: tokens.colorPaletteMarigoldForeground2,
671
+ background: tokens.colorNeutralBackground1,
672
+ typeKind: tokens.colorPaletteBerryForeground2,
673
+ typeName: tokens.colorNeutralForeground2,
674
+ dataKey: tokens.colorNeutralForeground2,
675
+ ref: tokens.colorBrandForeground1,
676
+ literal: tokens.colorPaletteLightGreenForeground2,
677
+ indentationGuide: tokens.colorNeutralForeground4,
678
+ property: tokens.colorPaletteMarigoldForeground2
679
+ };
680
+ const TypeGraphViewer = {
681
+ key: "type-graph",
682
+ label: "Type graph",
683
+ icon: /* @__PURE__ */ jsx(DataLineRegular, {}),
684
+ render: TypeGraphViewerComponent
436
685
  };
437
686
 
438
- var style$4 = {"layout":"playground-module_layout__SCPgt"};
687
+ const OutputView = ({
688
+ compilationState,
689
+ viewers,
690
+ fileViewers,
691
+ editorOptions
692
+ }) => {
693
+ if (compilationState === void 0) {
694
+ return /* @__PURE__ */ jsx(Fragment, {});
695
+ }
696
+ if ("internalCompilerError" in compilationState) {
697
+ return /* @__PURE__ */ jsx(Fragment, {});
698
+ }
699
+ const resolvedViewers = useMemo(() => resolveViewers(viewers, fileViewers), [viewers]);
700
+ return /* @__PURE__ */ jsx(
701
+ OutputViewInternal,
702
+ {
703
+ compilationResult: compilationState,
704
+ viewers: resolvedViewers,
705
+ editorOptions
706
+ }
707
+ );
708
+ };
709
+ function resolveViewers(viewers, fileViewers) {
710
+ const fileViewer = createFileViewer(fileViewers ?? []);
711
+ const output = {
712
+ programViewers: {
713
+ [fileViewer.key]: fileViewer,
714
+ [TypeGraphViewer.key]: TypeGraphViewer
715
+ }
716
+ };
717
+ for (const item of viewers ?? []) {
718
+ output.programViewers[item.key] = item;
719
+ }
720
+ return output;
721
+ }
722
+ const OutputViewInternal = ({ compilationResult, viewers, editorOptions }) => {
723
+ const viewerList = Object.values(viewers.programViewers);
724
+ const [selected, setSelected] = useState(viewerList[0].key);
725
+ const onTabSelect = useCallback(
726
+ (_, data) => setSelected(data.value),
727
+ [setSelected]
728
+ );
729
+ const viewer = useMemo(() => {
730
+ return viewers.programViewers[selected];
731
+ }, [viewers.programViewers, selected]);
732
+ return /* @__PURE__ */ jsxs("div", { className: style$5["output-view"], children: [
733
+ /* @__PURE__ */ jsx("div", { className: style$5["output-content"], children: /* @__PURE__ */ jsx(
734
+ viewer.render,
735
+ {
736
+ program: compilationResult.program,
737
+ outputFiles: compilationResult.outputFiles
738
+ }
739
+ ) }),
740
+ /* @__PURE__ */ jsx("div", { className: style$5["viewer-tabs-container"], children: /* @__PURE__ */ jsx(
741
+ TabList,
742
+ {
743
+ vertical: true,
744
+ size: "large",
745
+ selectedValue: selected,
746
+ onTabSelect,
747
+ className: style$5["viewer-tabs"],
748
+ children: viewerList.map((viewer2) => {
749
+ return /* @__PURE__ */ jsx(Tab, { value: viewer2.key, className: style$5["viewer-tab"], children: /* @__PURE__ */ jsx("span", { title: viewer2.label, children: viewer2.icon }) }, viewer2.key);
750
+ })
751
+ }
752
+ ) })
753
+ ] });
754
+ };
439
755
 
440
- var style$3 = {"list":"diagnostic-list-module_list__6tVpz","item":"diagnostic-list-module_item__BE8Fr","item--error":"diagnostic-list-module_item--error__tnhWA","item--warning":"diagnostic-list-module_item--warning__J7vIN","item-code":"diagnostic-list-module_item-code__AgVjZ","item-loc":"diagnostic-list-module_item-loc__IeYnW"};
756
+ const layout = "_layout_l03ni_1";
757
+ const style$4 = {
758
+ layout: layout,
759
+ "edit-pane": "_edit-pane_l03ni_9"
760
+ };
441
761
 
442
- const DiagnosticList = ({ diagnostics, onDiagnosticSelected, }) => {
443
- if (diagnostics.length === 0) {
444
- return jsx("div", { className: style$3["list"], children: "No errors" });
445
- }
446
- const handleItemSelected = useCallback((diagnostic) => {
447
- onDiagnosticSelected?.(diagnostic);
448
- }, [onDiagnosticSelected]);
449
- return (jsx("div", { className: style$3["list"], children: diagnostics.map((x, i) => {
450
- return jsx(DiagnosticItem, { diagnostic: x, onItemSelected: handleItemSelected }, i);
451
- }) }));
762
+ const list = "_list_wrnwm_1";
763
+ const item = "_item_wrnwm_4";
764
+ const style$3 = {
765
+ list: list,
766
+ item: item,
767
+ "item--error": "_item--error_wrnwm_15",
768
+ "item--warning": "_item--warning_wrnwm_19",
769
+ "item-code": "_item-code_wrnwm_23",
770
+ "item-loc": "_item-loc_wrnwm_27"
771
+ };
772
+
773
+ const DiagnosticList = ({
774
+ diagnostics,
775
+ onDiagnosticSelected
776
+ }) => {
777
+ if (diagnostics.length === 0) {
778
+ return /* @__PURE__ */ jsx("div", { className: style$3["list"], children: "No errors" });
779
+ }
780
+ const handleItemSelected = useCallback(
781
+ (diagnostic) => {
782
+ onDiagnosticSelected?.(diagnostic);
783
+ },
784
+ [onDiagnosticSelected]
785
+ );
786
+ return /* @__PURE__ */ jsx("div", { className: style$3["list"], children: diagnostics.map((x, i) => {
787
+ return /* @__PURE__ */ jsx(DiagnosticItem, { diagnostic: x, onItemSelected: handleItemSelected }, i);
788
+ }) });
452
789
  };
453
790
  const DiagnosticItem = ({ diagnostic, onItemSelected }) => {
454
- const handleClick = useCallback(() => {
455
- onItemSelected(diagnostic);
456
- }, [diagnostic, onItemSelected]);
457
- return (jsxs("div", { tabIndex: 0, className: style$3["item"], onClick: handleClick, children: [jsx("div", { className: mergeClasses((style$3["item-severity"],
458
- style$3[diagnostic.severity === "error" ? "item--error" : "item--warning"])), children: diagnostic.severity }), jsx("div", { className: style$3["item-code"], children: diagnostic.code }), jsx("div", { className: style$3["item-message"], children: diagnostic.message }), jsx("div", { className: style$3["item-loc"], children: jsx(DiagnosticTargetLink, { target: diagnostic.target }) })] }));
791
+ const handleClick = useCallback(() => {
792
+ onItemSelected(diagnostic);
793
+ }, [diagnostic, onItemSelected]);
794
+ return /* @__PURE__ */ jsxs("div", { tabIndex: 0, className: style$3["item"], onClick: handleClick, children: [
795
+ /* @__PURE__ */ jsx(
796
+ "div",
797
+ {
798
+ className: mergeClasses(
799
+ (style$3[diagnostic.severity === "error" ? "item--error" : "item--warning"])
800
+ ),
801
+ children: diagnostic.severity
802
+ }
803
+ ),
804
+ /* @__PURE__ */ jsx("div", { className: style$3["item-code"], children: diagnostic.code }),
805
+ /* @__PURE__ */ jsx("div", { className: style$3["item-message"], children: diagnostic.message }),
806
+ /* @__PURE__ */ jsx("div", { className: style$3["item-loc"], children: /* @__PURE__ */ jsx(DiagnosticTargetLink, { target: diagnostic.target }) })
807
+ ] });
459
808
  };
460
809
  const DiagnosticTargetLink = memo(({ target }) => {
461
- if (typeof target === "symbol") {
462
- return jsx("span", {});
463
- }
464
- const location = getSourceLocation(target);
465
- const file = location.file.path === "/test/main.tsp" ? "" : `${location.file.path}:`;
466
- const { line, character } = location.file.getLineAndCharacterOfPosition(location.pos);
467
- return (jsxs("span", { children: [file, line + 1, ":", character + 1] }));
810
+ if (typeof target === "symbol") {
811
+ return /* @__PURE__ */ jsx("span", {});
812
+ }
813
+ const location = getSourceLocation(target);
814
+ const file = location.file.path === "/test/main.tsp" ? "" : `${location.file.path}:`;
815
+ const { line, character } = location.file.getLineAndCharacterOfPosition(location.pos);
816
+ return /* @__PURE__ */ jsxs("span", { children: [
817
+ file,
818
+ line + 1,
819
+ ":",
820
+ character + 1
821
+ ] });
468
822
  });
469
823
 
470
- var style$2 = {"header":"header-module_header__LyUNg","header--error":"header-module_header--error__8MKzf","error-icon":"header-module_error-icon__gb-oB","header--warning":"header-module_header--warning__QPFEE","warning-icon":"header-module_warning-icon__u14P3","header-content":"header-module_header-content__Uc4HJ","header-chevron":"header-module_header-chevron__HXm6b","header-chevron--collapsed":"header-module_header-chevron--collapsed__wKyHV"};
824
+ const header = "_header_1qhql_1";
825
+ const style$2 = {
826
+ header: header,
827
+ "header--error": "_header--error_1qhql_12",
828
+ "error-icon": "_error-icon_1qhql_17",
829
+ "header--warning": "_header--warning_1qhql_21",
830
+ "warning-icon": "_warning-icon_1qhql_26",
831
+ "header-content": "_header-content_1qhql_30",
832
+ "header-chevron": "_header-chevron_1qhql_36",
833
+ "header-chevron--collapsed": "_header-chevron--collapsed_1qhql_39"
834
+ };
471
835
 
472
836
  const ProblemPaneHeader = memo(({ compilationState, ...props }) => {
473
- const noProblem = (jsx(Container, { status: "none", ...props, children: "No problems" }));
474
- if (compilationState === undefined) {
475
- return noProblem;
476
- }
477
- if ("internalCompilerError" in compilationState) {
478
- return (jsxs(Container, { status: "error", ...props, children: [jsx(ErrorCircle16Filled, {}), " Internal Compiler Error"] }));
479
- }
480
- const diagnostics = compilationState.program.diagnostics;
481
- if (diagnostics.length === 0) {
482
- return noProblem;
483
- }
484
- const errors = diagnostics.filter((x) => x.severity === "error");
485
- const warnings = diagnostics.filter((x) => x.severity === "warning");
486
- return (jsxs(Container, { status: errors.length > 0 ? "error" : "warning", ...props, children: [errors.length > 0 ? (jsxs(Fragment, { children: [jsx(ErrorCircle16Filled, { className: style$2["error-icon"] }), " ", errors.length, " errors"] })) : null, warnings.length > 0 ? (jsxs(Fragment, { children: [jsx(Warning16Filled, { className: style$2["warning-icon"] }), " ", warnings.length, " warnings"] })) : null] }));
837
+ const noProblem = /* @__PURE__ */ jsx(Container, { status: "none", ...props, children: "No problems" });
838
+ if (compilationState === void 0) {
839
+ return noProblem;
840
+ }
841
+ if ("internalCompilerError" in compilationState) {
842
+ return /* @__PURE__ */ jsxs(Container, { status: "error", ...props, children: [
843
+ /* @__PURE__ */ jsx(ErrorCircle16Filled, {}),
844
+ " Internal Compiler Error"
845
+ ] });
846
+ }
847
+ const diagnostics = compilationState.program.diagnostics;
848
+ if (diagnostics.length === 0) {
849
+ return noProblem;
850
+ }
851
+ const errors = diagnostics.filter((x) => x.severity === "error");
852
+ const warnings = diagnostics.filter((x) => x.severity === "warning");
853
+ return /* @__PURE__ */ jsxs(Container, { status: errors.length > 0 ? "error" : "warning", ...props, children: [
854
+ errors.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
855
+ /* @__PURE__ */ jsx(ErrorCircle16Filled, { className: style$2["error-icon"] }),
856
+ " ",
857
+ errors.length,
858
+ " errors"
859
+ ] }) : null,
860
+ warnings.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
861
+ /* @__PURE__ */ jsx(Warning16Filled, { className: style$2["warning-icon"] }),
862
+ " ",
863
+ warnings.length,
864
+ " warnings"
865
+ ] }) : null
866
+ ] });
487
867
  });
488
868
  const Container = ({ children, className, status, onClick, collaped }) => {
489
- return (jsxs("div", { tabIndex: onClick === undefined ? undefined : 0, className: mergeClasses(style$2["header"], status === "error" && style$2["header--error"], status === "warning" && style$2["header--warning"], className), onClick: onClick, children: [jsx("div", { className: style$2["header-content"], children: children }), jsx(ChevronDown16Regular, { className: mergeClasses(style$2["header-chevron"], collaped && style$2["header-chevron--collapsed"]) })] }));
869
+ return /* @__PURE__ */ jsxs(
870
+ "div",
871
+ {
872
+ tabIndex: onClick === void 0 ? void 0 : 0,
873
+ className: mergeClasses(
874
+ style$2["header"],
875
+ status === "error" && style$2["header--error"],
876
+ status === "warning" && style$2["header--warning"],
877
+ className
878
+ ),
879
+ onClick,
880
+ children: [
881
+ /* @__PURE__ */ jsx("div", { className: style$2["header-content"], children }),
882
+ /* @__PURE__ */ jsx(
883
+ ChevronDown16Regular,
884
+ {
885
+ className: mergeClasses(
886
+ style$2["header-chevron"],
887
+ collaped && style$2["header-chevron--collapsed"]
888
+ )
889
+ }
890
+ )
891
+ ]
892
+ }
893
+ );
490
894
  };
491
895
 
492
- var style$1 = {"problem-pane":"problem-pane-module_problem-pane__GJKF4","problem-content":"problem-pane-module_problem-content__rYzbh","no-problems":"problem-pane-module_no-problems__Ub8R-","internal-compiler-error":"problem-pane-module_internal-compiler-error__laE4f"};
896
+ const style$1 = {
897
+ "problem-pane": "_problem-pane_kxgwp_1",
898
+ "problem-content": "_problem-content_kxgwp_9",
899
+ "no-problems": "_no-problems_kxgwp_12",
900
+ "internal-compiler-error": "_internal-compiler-error_kxgwp_16"
901
+ };
493
902
 
494
- const ProblemPane = ({ collapsed, compilationState, onHeaderClick, onDiagnosticSelected, }) => {
495
- return (jsxs("div", { className: style$1["problem-pane"], children: [jsx(ProblemPaneHeader, { compilationState: compilationState, onClick: onHeaderClick, collaped: collapsed }), jsx("div", { className: style$1["problem-content"], "aria-hidden": collapsed, children: jsx(ProblemPaneContent, { compilationState: compilationState, onDiagnosticSelected: onDiagnosticSelected }) })] }));
903
+ const ProblemPane = ({
904
+ collapsed,
905
+ compilationState,
906
+ onHeaderClick,
907
+ onDiagnosticSelected
908
+ }) => {
909
+ return /* @__PURE__ */ jsxs("div", { className: style$1["problem-pane"], children: [
910
+ /* @__PURE__ */ jsx(
911
+ ProblemPaneHeader,
912
+ {
913
+ compilationState,
914
+ onClick: onHeaderClick,
915
+ collaped: collapsed
916
+ }
917
+ ),
918
+ /* @__PURE__ */ jsx("div", { className: style$1["problem-content"], "aria-hidden": collapsed, children: /* @__PURE__ */ jsx(
919
+ ProblemPaneContent,
920
+ {
921
+ compilationState,
922
+ onDiagnosticSelected
923
+ }
924
+ ) })
925
+ ] });
496
926
  };
497
- const ProblemPaneContent = ({ compilationState, onDiagnosticSelected, }) => {
498
- if (compilationState === undefined) {
499
- return jsx(Fragment, {});
500
- }
501
- if ("internalCompilerError" in compilationState) {
502
- return (jsx("pre", { className: style$1["internal-compiler-error"], children: String(compilationState.internalCompilerError) }));
503
- }
504
- const diagnostics = compilationState.program.diagnostics;
505
- return diagnostics.length === 0 ? (jsx("div", { className: style$1["no-problems"], children: " No problems" })) : (jsx(DiagnosticList, { diagnostics: diagnostics, onDiagnosticSelected: onDiagnosticSelected }));
927
+ const ProblemPaneContent = ({
928
+ compilationState,
929
+ onDiagnosticSelected
930
+ }) => {
931
+ if (compilationState === void 0) {
932
+ return /* @__PURE__ */ jsx(Fragment, {});
933
+ }
934
+ if ("internalCompilerError" in compilationState) {
935
+ return /* @__PURE__ */ jsx("pre", { className: style$1["internal-compiler-error"], children: String(compilationState.internalCompilerError) });
936
+ }
937
+ const diagnostics = compilationState.program.diagnostics;
938
+ return diagnostics.length === 0 ? /* @__PURE__ */ jsx("div", { className: style$1["no-problems"], children: " No problems" }) : /* @__PURE__ */ jsx(DiagnosticList, { diagnostics, onDiagnosticSelected });
506
939
  };
507
940
 
508
- function Pane({ children, ...props }) {
509
- return jsx("div", { ...props, children: children });
941
+ function Pane({
942
+ children,
943
+ ...props
944
+ }) {
945
+ return /* @__PURE__ */ jsx("div", { ...props, children });
510
946
  }
511
947
 
512
- var style = {"split-pane":"split-pane-module_split-pane__XCqR8","split-disabled":"split-pane-module_split-disabled__fZ0Sg","split-pane-dragging":"split-pane-module_split-pane-dragging__mQJnZ","react-split-vertical":"split-pane-module_react-split-vertical__WTUQ1","react-split-horizontal":"split-pane-module_react-split-horizontal__Fpls-","sash":"split-pane-module_sash__hNWH6","sash-disabled":"split-pane-module_sash-disabled__z6uCV","sash-vertical":"split-pane-module_sash-vertical__S8HbH","sash-horizontal":"split-pane-module_sash-horizontal__BTUaN","sash-content":"split-pane-module_sash-content__DLAt4","sash-content-dragging":"split-pane-module_sash-content-dragging__NkKQP","pane":"split-pane-module_pane__m1zQB"};
948
+ const sash = "_sash_v2eo6_20";
949
+ const pane = "_pane_v2eo6_70";
950
+ const style = {
951
+ "split-pane": "_split-pane_v2eo6_1",
952
+ "split-disabled": "_split-disabled_v2eo6_8",
953
+ "split-pane-dragging": "_split-pane-dragging_v2eo6_12",
954
+ "react-split-vertical": "_react-split-vertical_v2eo6_12",
955
+ "react-split-horizontal": "_react-split-horizontal_v2eo6_16",
956
+ sash: sash,
957
+ "sash-disabled": "_sash-disabled_v2eo6_29",
958
+ "sash-vertical": "_sash-vertical_v2eo6_33",
959
+ "sash-horizontal": "_sash-horizontal_v2eo6_37",
960
+ "sash-content": "_sash-content_v2eo6_41",
961
+ "sash-content-dragging": "_sash-content-dragging_v2eo6_47",
962
+ pane: pane
963
+ };
513
964
 
514
- const SashContent = ({ className, children, dragging, ...others }) => {
515
- return (jsx("div", { className: mergeClasses(style["sash-content"], dragging && style["sash-content-dragging"], className), ...others, children: children }));
965
+ const SashContent = ({
966
+ className,
967
+ children,
968
+ dragging,
969
+ ...others
970
+ }) => {
971
+ return /* @__PURE__ */ jsx(
972
+ "div",
973
+ {
974
+ className: mergeClasses(
975
+ style["sash-content"],
976
+ dragging && style["sash-content-dragging"],
977
+ className
978
+ ),
979
+ ...others,
980
+ children
981
+ }
982
+ );
516
983
  };
517
984
 
518
- const Sash = ({ className, render, onDragStart, onDragging, onDragEnd, onReset, ...others }) => {
519
- const [draging, setDrag] = useState(false);
520
- const handleMouseMove = (e) => {
521
- onDragging(e);
522
- };
523
- const handleMouseUp = (e) => {
524
- setDrag(false);
525
- onDragEnd(e);
526
- window.removeEventListener("mousemove", handleMouseMove);
527
- window.removeEventListener("mouseup", handleMouseUp);
985
+ const Sash = ({
986
+ className,
987
+ render,
988
+ onDragStart,
989
+ onDragging,
990
+ onDragEnd,
991
+ onReset,
992
+ ...others
993
+ }) => {
994
+ const [draging, setDrag] = useState(false);
995
+ const handleMouseMove = (e) => {
996
+ onDragging(e);
997
+ };
998
+ const handleMouseUp = (e) => {
999
+ setDrag(false);
1000
+ onDragEnd(e);
1001
+ window.removeEventListener("mousemove", handleMouseMove);
1002
+ window.removeEventListener("mouseup", handleMouseUp);
1003
+ };
1004
+ return /* @__PURE__ */ jsx(
1005
+ "div",
1006
+ {
1007
+ className: mergeClasses(style["sash"], className),
1008
+ onMouseDown: (e) => {
1009
+ setDrag(true);
1010
+ onDragStart(e);
1011
+ window.addEventListener("mousemove", handleMouseMove);
1012
+ window.addEventListener("mouseup", handleMouseUp);
1013
+ },
1014
+ onDoubleClick: onReset,
1015
+ ...others,
1016
+ children: render(draging)
1017
+ }
1018
+ );
1019
+ };
1020
+
1021
+ const SplitPane = ({
1022
+ children,
1023
+ sizes: propSizes,
1024
+ initialSizes: defaultSizes,
1025
+ allowResize = true,
1026
+ split = "vertical",
1027
+ className: wrapClassName,
1028
+ sashRender = (_, active) => /* @__PURE__ */ jsx(SashContent, { dragging: active }),
1029
+ resizerSize = 4,
1030
+ performanceMode = false,
1031
+ onChange = () => null,
1032
+ onDragStart = () => null,
1033
+ onDragEnd = () => null,
1034
+ ...others
1035
+ }) => {
1036
+ const [resolvedPropSize, updateSizes] = useControllableValue(
1037
+ propSizes,
1038
+ defaultSizes,
1039
+ onChange
1040
+ );
1041
+ const axis = useRef({ x: 0, y: 0 });
1042
+ const wrapper = useRef(null);
1043
+ const cacheSizes = useRef({ sizes: [], sashPosSizes: [] });
1044
+ const [wrapperRect, setWrapperRect] = useState({});
1045
+ const [isDragging, setDragging] = useState(false);
1046
+ useEffect(() => {
1047
+ const resizeObserver = new ResizeObserver(() => {
1048
+ setWrapperRect(wrapper?.current?.getBoundingClientRect() ?? {});
1049
+ });
1050
+ resizeObserver.observe(wrapper.current);
1051
+ return () => {
1052
+ resizeObserver.disconnect();
528
1053
  };
529
- return (jsx("div", { className: mergeClasses(style["sash"], className), onMouseDown: (e) => {
530
- setDrag(true);
531
- onDragStart(e);
532
- window.addEventListener("mousemove", handleMouseMove);
533
- window.addEventListener("mouseup", handleMouseUp);
534
- }, onDoubleClick: onReset, ...others, children: render(draging) }));
535
- };
536
-
537
- const SplitPane = ({ children, sizes: propSizes, initialSizes: defaultSizes, allowResize = true, split = "vertical", className: wrapClassName, sashRender = (_, active) => jsx(SashContent, { dragging: active }), resizerSize = 4, performanceMode = false, onChange = () => null, onDragStart = () => null, onDragEnd = () => null, ...others }) => {
538
- const [resolvedPropSize, updateSizes] = useControllableValue(propSizes, defaultSizes, onChange);
539
- const axis = useRef({ x: 0, y: 0 });
540
- const wrapper = useRef(null);
541
- const cacheSizes = useRef({ sizes: [], sashPosSizes: [] });
542
- const [wrapperRect, setWrapperRect] = useState({});
543
- const [isDragging, setDragging] = useState(false);
544
- useEffect(() => {
545
- const resizeObserver = new ResizeObserver(() => {
546
- setWrapperRect(wrapper?.current?.getBoundingClientRect() ?? {});
1054
+ }, []);
1055
+ const { sizeName, splitPos, splitAxis } = useMemo(
1056
+ () => ({
1057
+ sizeName: split === "vertical" ? "width" : "height",
1058
+ splitPos: split === "vertical" ? "left" : "top",
1059
+ splitAxis: split === "vertical" ? "x" : "y"
1060
+ }),
1061
+ [split]
1062
+ );
1063
+ const wrapSize = wrapperRect[sizeName] ?? 0;
1064
+ const paneLimitSizes = useMemo(
1065
+ () => children.map((childNode) => {
1066
+ const limits = [0, Infinity];
1067
+ if (childNode?.type === Pane) {
1068
+ const { minSize, maxSize } = childNode.props;
1069
+ limits[0] = assertsSize(minSize, wrapSize, 0);
1070
+ limits[1] = assertsSize(maxSize, wrapSize);
1071
+ }
1072
+ return limits;
1073
+ }),
1074
+ [children, wrapSize]
1075
+ );
1076
+ const sizes = useMemo(
1077
+ function() {
1078
+ let count = 0;
1079
+ let curSum = 0;
1080
+ const res = children.map((_, index) => {
1081
+ const size = assertsSize(resolvedPropSize[index], wrapSize);
1082
+ size === Infinity ? count++ : curSum += size;
1083
+ return size;
1084
+ });
1085
+ if (curSum > wrapSize || !count && curSum < wrapSize) {
1086
+ const cacheNum = (curSum - wrapSize) / curSum;
1087
+ return res.map((size) => {
1088
+ return size === Infinity ? 0 : size - size * cacheNum;
547
1089
  });
548
- resizeObserver.observe(wrapper.current);
549
- return () => {
550
- resizeObserver.disconnect();
551
- };
552
- }, []);
553
- const { sizeName, splitPos, splitAxis } = useMemo(() => ({
554
- sizeName: split === "vertical" ? "width" : "height",
555
- splitPos: split === "vertical" ? "left" : "top",
556
- splitAxis: split === "vertical" ? "x" : "y",
557
- }), [split]);
558
- const wrapSize = wrapperRect[sizeName] ?? 0;
559
- // Get limit sizes via children
560
- const paneLimitSizes = useMemo(() => children.map((childNode) => {
561
- const limits = [0, Infinity];
562
- if (childNode?.type === Pane) {
563
- const { minSize, maxSize } = childNode.props;
564
- limits[0] = assertsSize(minSize, wrapSize, 0);
565
- limits[1] = assertsSize(maxSize, wrapSize);
566
- }
567
- return limits;
568
- }), [children, wrapSize]);
569
- const sizes = useMemo(function () {
570
- let count = 0;
571
- let curSum = 0;
572
- const res = children.map((_, index) => {
573
- const size = assertsSize(resolvedPropSize[index], wrapSize);
574
- size === Infinity ? count++ : (curSum += size);
575
- return size;
1090
+ }
1091
+ if (count > 0) {
1092
+ const average = (wrapSize - curSum) / count;
1093
+ return res.map((size) => {
1094
+ return size === Infinity ? average : size;
576
1095
  });
577
- // resize or illegal size input,recalculate pane sizes
578
- if (curSum > wrapSize || (!count && curSum < wrapSize)) {
579
- const cacheNum = (curSum - wrapSize) / curSum;
580
- return res.map((size) => {
581
- return size === Infinity ? 0 : size - size * cacheNum;
582
- });
583
- }
584
- if (count > 0) {
585
- const average = (wrapSize - curSum) / count;
586
- return res.map((size) => {
587
- return size === Infinity ? average : size;
588
- });
589
- }
590
- return res;
591
- }, [...resolvedPropSize, children.length, wrapSize]);
592
- const sashPosSizes = useMemo(() => sizes.reduce((a, b) => [...a, a[a.length - 1] + b], [0]), [...sizes]);
593
- const dragStart = useCallback((e) => {
594
- document?.body?.classList?.add(style["split-disabled"]);
595
- axis.current = { x: e.pageX, y: e.pageY };
596
- cacheSizes.current = { sizes, sashPosSizes };
597
- setDragging(true);
598
- onDragStart(e);
599
- }, [onDragStart, sizes, sashPosSizes]);
600
- const resetPosition = useCallback(() => {
601
- if (defaultSizes) {
602
- updateSizes(defaultSizes);
603
- }
604
- }, [defaultSizes, updateSizes]);
605
- const dragEnd = useCallback((e) => {
606
- document?.body?.classList?.remove(style["split-disabled"]);
607
- axis.current = { x: e.pageX, y: e.pageY };
608
- cacheSizes.current = { sizes, sashPosSizes };
609
- setDragging(false);
610
- onDragEnd(e);
611
- }, [onDragEnd, sizes, sashPosSizes]);
612
- const onDragging = useCallback(function (e, i) {
613
- const curAxis = { x: e.pageX, y: e.pageY };
614
- let distanceX = curAxis[splitAxis] - axis.current[splitAxis];
615
- const leftBorder = -Math.min(sizes[i] - paneLimitSizes[i][0], paneLimitSizes[i + 1][1] - sizes[i + 1]);
616
- const rightBorder = Math.min(sizes[i + 1] - paneLimitSizes[i + 1][0], paneLimitSizes[i][1] - sizes[i]);
617
- if (distanceX < leftBorder) {
618
- distanceX = leftBorder;
619
- }
620
- if (distanceX > rightBorder) {
621
- distanceX = rightBorder;
622
- }
623
- const nextSizes = [...sizes];
624
- nextSizes[i] += distanceX;
625
- nextSizes[i + 1] -= distanceX;
626
- updateSizes(nextSizes);
627
- }, [paneLimitSizes, onChange]);
628
- const paneFollow = !(performanceMode && isDragging);
629
- const paneSizes = paneFollow ? sizes : cacheSizes.current.sizes;
630
- const panePoses = paneFollow ? sashPosSizes : cacheSizes.current.sashPosSizes;
631
- return (jsxs("div", { className: mergeClasses(style["split-pane"], split === "vertical" && style["split-pane-vertical"], split === "horizontal" && style["split-pane-horizontal"], isDragging && style["split-pane-dragging"], wrapClassName), ref: wrapper, ...others, children: [children.map((childNode, childIndex) => {
632
- const isPane = childNode.type === Pane;
633
- const paneProps = isPane ? childNode.props : {};
634
- return (jsx(Pane, { className: mergeClasses(style["pane"], paneProps.className), style: {
635
- ...paneProps.style,
636
- [sizeName]: paneSizes[childIndex],
637
- [splitPos]: panePoses[childIndex],
638
- }, children: isPane ? paneProps.children : childNode }, childIndex));
639
- }), sashPosSizes.slice(1, -1).map((posSize, index) => (jsx(Sash, { className: mergeClasses(!allowResize && style["sash-disabled"], split === "vertical" ? style["sash-vertical"] : style["sash-horizontal"]), style: {
640
- [sizeName]: resizerSize,
641
- [splitPos]: posSize - resizerSize / 2,
642
- }, render: sashRender.bind(null, index), onReset: resetPosition, onDragStart: dragStart, onDragging: (e) => onDragging(e, index), onDragEnd: dragEnd }, index)))] }));
643
- };
644
- /**
645
- * Convert size to absolute number or Infinity
646
- * SplitPane allows sizes in string and number, but the state sizes only support number,
647
- * so convert string and number to number in here
648
- * 'auto' -> divide the remaining space equally
649
- * 'xxx px' -> xxx
650
- * 'xxx%' -> wrapper.size * xxx/100
651
- * xxx -> xxx
652
- */
1096
+ }
1097
+ return res;
1098
+ },
1099
+ [...resolvedPropSize, children.length, wrapSize]
1100
+ );
1101
+ const sashPosSizes = useMemo(
1102
+ () => sizes.reduce((a, b) => [...a, a[a.length - 1] + b], [0]),
1103
+ [...sizes]
1104
+ );
1105
+ const dragStart = useCallback(
1106
+ (e) => {
1107
+ document?.body?.classList?.add(style["split-disabled"]);
1108
+ axis.current = { x: e.pageX, y: e.pageY };
1109
+ cacheSizes.current = { sizes, sashPosSizes };
1110
+ setDragging(true);
1111
+ onDragStart(e);
1112
+ },
1113
+ [onDragStart, sizes, sashPosSizes]
1114
+ );
1115
+ const resetPosition = useCallback(() => {
1116
+ if (defaultSizes) {
1117
+ updateSizes(defaultSizes);
1118
+ }
1119
+ }, [defaultSizes, updateSizes]);
1120
+ const dragEnd = useCallback(
1121
+ (e) => {
1122
+ document?.body?.classList?.remove(style["split-disabled"]);
1123
+ axis.current = { x: e.pageX, y: e.pageY };
1124
+ cacheSizes.current = { sizes, sashPosSizes };
1125
+ setDragging(false);
1126
+ onDragEnd(e);
1127
+ },
1128
+ [onDragEnd, sizes, sashPosSizes]
1129
+ );
1130
+ const onDragging = useCallback(
1131
+ function(e, i) {
1132
+ const curAxis = { x: e.pageX, y: e.pageY };
1133
+ let distanceX = curAxis[splitAxis] - axis.current[splitAxis];
1134
+ const leftBorder = -Math.min(
1135
+ sizes[i] - paneLimitSizes[i][0],
1136
+ paneLimitSizes[i + 1][1] - sizes[i + 1]
1137
+ );
1138
+ const rightBorder = Math.min(
1139
+ sizes[i + 1] - paneLimitSizes[i + 1][0],
1140
+ paneLimitSizes[i][1] - sizes[i]
1141
+ );
1142
+ if (distanceX < leftBorder) {
1143
+ distanceX = leftBorder;
1144
+ }
1145
+ if (distanceX > rightBorder) {
1146
+ distanceX = rightBorder;
1147
+ }
1148
+ const nextSizes = [...sizes];
1149
+ nextSizes[i] += distanceX;
1150
+ nextSizes[i + 1] -= distanceX;
1151
+ updateSizes(nextSizes);
1152
+ },
1153
+ [paneLimitSizes, onChange]
1154
+ );
1155
+ const paneFollow = !(performanceMode && isDragging);
1156
+ const paneSizes = paneFollow ? sizes : cacheSizes.current.sizes;
1157
+ const panePoses = paneFollow ? sashPosSizes : cacheSizes.current.sashPosSizes;
1158
+ return /* @__PURE__ */ jsxs(
1159
+ "div",
1160
+ {
1161
+ className: mergeClasses(
1162
+ style["split-pane"],
1163
+ split === "vertical" && style["split-pane-vertical"],
1164
+ split === "horizontal" && style["split-pane-horizontal"],
1165
+ isDragging && style["split-pane-dragging"],
1166
+ wrapClassName
1167
+ ),
1168
+ ref: wrapper,
1169
+ ...others,
1170
+ children: [
1171
+ children.map((childNode, childIndex) => {
1172
+ const isPane = childNode.type === Pane;
1173
+ const paneProps = isPane ? childNode.props : {};
1174
+ return /* @__PURE__ */ jsx(
1175
+ Pane,
1176
+ {
1177
+ className: mergeClasses(style["pane"], paneProps.className),
1178
+ style: {
1179
+ ...paneProps.style,
1180
+ [sizeName]: paneSizes[childIndex],
1181
+ [splitPos]: panePoses[childIndex]
1182
+ },
1183
+ children: isPane ? paneProps.children : childNode
1184
+ },
1185
+ childIndex
1186
+ );
1187
+ }),
1188
+ sashPosSizes.slice(1, -1).map((posSize, index) => /* @__PURE__ */ jsx(
1189
+ Sash,
1190
+ {
1191
+ className: mergeClasses(
1192
+ !allowResize && style["sash-disabled"],
1193
+ split === "vertical" ? style["sash-vertical"] : style["sash-horizontal"]
1194
+ ),
1195
+ style: {
1196
+ [sizeName]: resizerSize,
1197
+ [splitPos]: posSize - resizerSize / 2
1198
+ },
1199
+ render: sashRender.bind(null, index),
1200
+ onReset: resetPosition,
1201
+ onDragStart: dragStart,
1202
+ onDragging: (e) => onDragging(e, index),
1203
+ onDragEnd: dragEnd
1204
+ },
1205
+ index
1206
+ ))
1207
+ ]
1208
+ }
1209
+ );
1210
+ };
653
1211
  function assertsSize(size, sum, defaultValue = Infinity) {
654
- if (typeof size === "undefined")
655
- return defaultValue;
656
- if (typeof size === "number")
657
- return size;
658
- if (size.endsWith("%"))
659
- return sum * (+size.replace("%", "") / 100);
660
- if (size.endsWith("px"))
661
- return +size.replace("px", "");
1212
+ if (typeof size === "undefined")
662
1213
  return defaultValue;
1214
+ if (typeof size === "number")
1215
+ return size;
1216
+ if (size.endsWith("%"))
1217
+ return sum * (+size.replace("%", "") / 100);
1218
+ if (size.endsWith("px"))
1219
+ return +size.replace("px", "");
1220
+ return defaultValue;
663
1221
  }
664
1222
 
665
1223
  const Playground = (props) => {
666
- const { host, onSave } = props;
667
- const editorRef = useRef(undefined);
668
- const [selectedEmitter, onSelectedEmitterChange] = useControllableValue(props.emitter, props.defaultEmitter, props.onEmitterChange);
669
- const [compilerOptions, onCompilerOptionsChange] = useControllableValue(props.compilerOptions, props.defaultCompilerOptions ?? {}, props.onCompilerOptionsChange);
670
- const [selectedSampleName, onSelectedSampleNameChange] = useControllableValue(props.sampleName, props.defaultSampleName, props.onSampleNameChange);
671
- const [content, setContent] = useState(props.defaultContent);
672
- const isSampleUntouched = useMemo(() => {
673
- return Boolean(selectedSampleName && content === props.samples?.[selectedSampleName]?.content);
674
- }, [content, selectedSampleName, props.samples]);
675
- const typespecModel = useMonacoModel("inmemory://test/main.tsp", "typespec");
676
- const [compilationState, setCompilationState] = useState(undefined);
677
- const doCompile = useCallback(async () => {
678
- const content = typespecModel.getValue();
679
- setContent(content);
680
- const typespecCompiler = host.compiler;
681
- const state = await compile(host, content, selectedEmitter, compilerOptions);
682
- setCompilationState(state);
683
- if ("program" in state) {
684
- const markers = state.program.diagnostics.map((diag) => ({
685
- ...getMonacoRange(typespecCompiler, diag.target),
686
- message: diag.message,
687
- severity: diag.severity === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning,
688
- tags: diag.code === "deprecated" ? [CompletionItemTag.Deprecated] : undefined,
689
- }));
690
- editor.setModelMarkers(typespecModel, "owner", markers ?? []);
691
- }
692
- else {
693
- editor.setModelMarkers(typespecModel, "owner", []);
1224
+ const { host, onSave } = props;
1225
+ const editorRef = useRef(void 0);
1226
+ const [selectedEmitter, onSelectedEmitterChange] = useControllableValue(
1227
+ props.emitter,
1228
+ props.defaultEmitter,
1229
+ props.onEmitterChange
1230
+ );
1231
+ const [compilerOptions, onCompilerOptionsChange] = useControllableValue(
1232
+ props.compilerOptions,
1233
+ props.defaultCompilerOptions ?? {},
1234
+ props.onCompilerOptionsChange
1235
+ );
1236
+ const [selectedSampleName, onSelectedSampleNameChange] = useControllableValue(
1237
+ props.sampleName,
1238
+ props.defaultSampleName,
1239
+ props.onSampleNameChange
1240
+ );
1241
+ const [content, setContent] = useState(props.defaultContent);
1242
+ const isSampleUntouched = useMemo(() => {
1243
+ return Boolean(selectedSampleName && content === props.samples?.[selectedSampleName]?.content);
1244
+ }, [content, selectedSampleName, props.samples]);
1245
+ const typespecModel = useMonacoModel("inmemory://test/main.tsp", "typespec");
1246
+ const [compilationState, setCompilationState] = useState(void 0);
1247
+ const doCompile = useCallback(async () => {
1248
+ const content2 = typespecModel.getValue();
1249
+ setContent(content2);
1250
+ const typespecCompiler = host.compiler;
1251
+ const state = await compile(host, content2, selectedEmitter, compilerOptions);
1252
+ setCompilationState(state);
1253
+ if ("program" in state) {
1254
+ const markers = state.program.diagnostics.map((diag) => ({
1255
+ ...getMonacoRange(typespecCompiler, diag.target),
1256
+ message: diag.message,
1257
+ severity: diag.severity === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning,
1258
+ tags: diag.code === "deprecated" ? [CompletionItemTag.Deprecated] : void 0
1259
+ }));
1260
+ editor.setModelMarkers(typespecModel, "owner", markers ?? []);
1261
+ } else {
1262
+ editor.setModelMarkers(typespecModel, "owner", []);
1263
+ }
1264
+ }, [host, selectedEmitter, compilerOptions, typespecModel, setContent]);
1265
+ const updateTypeSpec = useCallback(
1266
+ (value) => {
1267
+ if (typespecModel.getValue() !== value) {
1268
+ typespecModel.setValue(value);
1269
+ }
1270
+ },
1271
+ [typespecModel]
1272
+ );
1273
+ useEffect(() => {
1274
+ updateTypeSpec(props.defaultContent ?? "");
1275
+ }, []);
1276
+ useEffect(() => {
1277
+ if (selectedSampleName && props.samples) {
1278
+ const config = props.samples[selectedSampleName];
1279
+ if (config.content) {
1280
+ updateTypeSpec(config.content);
1281
+ if (config.preferredEmitter) {
1282
+ onSelectedEmitterChange(config.preferredEmitter);
694
1283
  }
695
- }, [host, selectedEmitter, compilerOptions, typespecModel, setContent]);
696
- const updateTypeSpec = useCallback((value) => {
697
- if (typespecModel.getValue() !== value) {
698
- typespecModel.setValue(value);
1284
+ if (config.compilerOptions) {
1285
+ onCompilerOptionsChange(config.compilerOptions);
699
1286
  }
700
- }, [typespecModel]);
701
- useEffect(() => {
702
- updateTypeSpec(props.defaultContent ?? "");
703
- }, []);
704
- useEffect(() => {
705
- if (selectedSampleName && props.samples) {
706
- const config = props.samples[selectedSampleName];
707
- if (config.content) {
708
- updateTypeSpec(config.content);
709
- if (config.preferredEmitter) {
710
- onSelectedEmitterChange(config.preferredEmitter);
711
- }
712
- if (config.compilerOptions) {
713
- onCompilerOptionsChange(config.compilerOptions);
714
- }
1287
+ }
1288
+ }
1289
+ }, [updateTypeSpec, selectedSampleName]);
1290
+ useEffect(() => {
1291
+ const debouncer = debounce(() => doCompile(), 200);
1292
+ const disposable = typespecModel.onDidChangeContent(debouncer);
1293
+ return () => {
1294
+ debouncer.clear();
1295
+ disposable.dispose();
1296
+ };
1297
+ }, [typespecModel, doCompile]);
1298
+ useEffect(() => {
1299
+ void doCompile();
1300
+ }, [doCompile]);
1301
+ const saveCode = useCallback(() => {
1302
+ if (onSave) {
1303
+ onSave({
1304
+ content: typespecModel.getValue(),
1305
+ emitter: selectedEmitter,
1306
+ options: compilerOptions,
1307
+ sampleName: isSampleUntouched ? selectedSampleName : void 0
1308
+ });
1309
+ }
1310
+ }, [
1311
+ typespecModel,
1312
+ onSave,
1313
+ selectedEmitter,
1314
+ compilerOptions,
1315
+ selectedSampleName,
1316
+ isSampleUntouched
1317
+ ]);
1318
+ const formatCode = useCallback(() => {
1319
+ void editorRef.current?.getAction("editor.action.formatDocument")?.run();
1320
+ }, [typespecModel]);
1321
+ const fileBug = useCallback(async () => {
1322
+ if (props.onFileBug) {
1323
+ saveCode();
1324
+ props.onFileBug();
1325
+ }
1326
+ }, [saveCode, typespecModel, props.onFileBug]);
1327
+ const typespecEditorActions = useMemo(
1328
+ () => [
1329
+ // ctrl/cmd+S => save
1330
+ { id: "save", label: "Save", keybindings: [KeyMod.CtrlCmd | KeyCode.KeyS], run: saveCode }
1331
+ ],
1332
+ [saveCode]
1333
+ );
1334
+ const onTypeSpecEditorMount = useCallback(({ editor: editor2 }) => {
1335
+ editorRef.current = editor2;
1336
+ }, []);
1337
+ const [verticalPaneSizes, setVerticalPaneSizes] = useState(
1338
+ verticalPaneSizesConst.collapsed
1339
+ );
1340
+ const toggleProblemPane = useCallback(() => {
1341
+ setVerticalPaneSizes((value) => {
1342
+ return value === verticalPaneSizesConst.collapsed ? verticalPaneSizesConst.expanded : verticalPaneSizesConst.collapsed;
1343
+ });
1344
+ }, [setVerticalPaneSizes]);
1345
+ const onVerticalPaneSizeChange = useCallback(
1346
+ (sizes) => {
1347
+ setVerticalPaneSizes(sizes);
1348
+ },
1349
+ [setVerticalPaneSizes]
1350
+ );
1351
+ const handleDiagnosticSelected = useCallback(
1352
+ (diagnostic) => {
1353
+ editorRef.current?.setSelection(getMonacoRange(host.compiler, diagnostic.target));
1354
+ },
1355
+ [setVerticalPaneSizes]
1356
+ );
1357
+ return /* @__PURE__ */ jsx(PlaygroundContextProvider, { value: { host }, children: /* @__PURE__ */ jsxs("div", { className: style$4["layout"], children: [
1358
+ /* @__PURE__ */ jsxs(SplitPane, { sizes: verticalPaneSizes, onChange: onVerticalPaneSizeChange, split: "horizontal", children: [
1359
+ /* @__PURE__ */ jsx(Pane, { children: /* @__PURE__ */ jsxs(SplitPane, { initialSizes: ["50%", "50%"], children: [
1360
+ /* @__PURE__ */ jsxs(Pane, { className: style$4["edit-pane"], children: [
1361
+ /* @__PURE__ */ jsx(
1362
+ EditorCommandBar,
1363
+ {
1364
+ host,
1365
+ selectedEmitter,
1366
+ onSelectedEmitterChange,
1367
+ compilerOptions,
1368
+ onCompilerOptionsChange,
1369
+ samples: props.samples,
1370
+ selectedSampleName,
1371
+ onSelectedSampleNameChange,
1372
+ saveCode,
1373
+ formatCode,
1374
+ fileBug: props.onFileBug ? fileBug : void 0,
1375
+ documentationUrl: props.links?.documentationUrl
715
1376
  }
1377
+ ),
1378
+ /* @__PURE__ */ jsx(
1379
+ TypeSpecEditor,
1380
+ {
1381
+ model: typespecModel,
1382
+ actions: typespecEditorActions,
1383
+ options: props.editorOptions,
1384
+ onMount: onTypeSpecEditorMount
1385
+ }
1386
+ )
1387
+ ] }),
1388
+ /* @__PURE__ */ jsx(Pane, { children: /* @__PURE__ */ jsx(
1389
+ OutputView,
1390
+ {
1391
+ compilationState,
1392
+ editorOptions: props.editorOptions,
1393
+ viewers: props.viewers,
1394
+ fileViewers: props.emitterViewers?.[selectedEmitter]
1395
+ }
1396
+ ) })
1397
+ ] }) }),
1398
+ /* @__PURE__ */ jsx(Pane, { minSize: 30, children: /* @__PURE__ */ jsx(
1399
+ ProblemPane,
1400
+ {
1401
+ collapsed: verticalPaneSizes[1] === verticalPaneSizesConst.collapsed[1],
1402
+ compilationState,
1403
+ onHeaderClick: toggleProblemPane,
1404
+ onDiagnosticSelected: handleDiagnosticSelected
716
1405
  }
717
- }, [updateTypeSpec, selectedSampleName]);
718
- useEffect(() => {
719
- const debouncer = debounce(() => doCompile(), 200);
720
- const disposable = typespecModel.onDidChangeContent(debouncer);
721
- return () => {
722
- debouncer.clear();
723
- disposable.dispose();
724
- };
725
- }, [typespecModel, doCompile]);
726
- useEffect(() => {
727
- void doCompile();
728
- }, [doCompile]);
729
- const saveCode = useCallback(() => {
730
- if (onSave) {
731
- onSave({
732
- content: typespecModel.getValue(),
733
- emitter: selectedEmitter,
734
- options: compilerOptions,
735
- sampleName: isSampleUntouched ? selectedSampleName : undefined,
736
- });
737
- }
738
- }, [
739
- typespecModel,
740
- onSave,
741
- selectedEmitter,
742
- compilerOptions,
743
- selectedSampleName,
744
- isSampleUntouched,
745
- ]);
746
- const formatCode = useCallback(() => {
747
- void editorRef.current?.getAction("editor.action.formatDocument")?.run();
748
- }, [typespecModel]);
749
- const fileBug = useCallback(async () => {
750
- if (props.onFileBug) {
751
- saveCode();
752
- props.onFileBug();
753
- }
754
- }, [saveCode, typespecModel, props.onFileBug]);
755
- const typespecEditorActions = useMemo(() => [
756
- // ctrl/cmd+S => save
757
- { id: "save", label: "Save", keybindings: [KeyMod.CtrlCmd | KeyCode.KeyS], run: saveCode },
758
- ], [saveCode]);
759
- const onTypeSpecEditorMount = useCallback(({ editor }) => {
760
- editorRef.current = editor;
761
- }, []);
762
- const [verticalPaneSizes, setVerticalPaneSizes] = useState(verticalPaneSizesConst.collapsed);
763
- const toggleProblemPane = useCallback(() => {
764
- setVerticalPaneSizes((value) => {
765
- return value === verticalPaneSizesConst.collapsed
766
- ? verticalPaneSizesConst.expanded
767
- : verticalPaneSizesConst.collapsed;
768
- });
769
- }, [setVerticalPaneSizes]);
770
- const onVerticalPaneSizeChange = useCallback((sizes) => {
771
- setVerticalPaneSizes(sizes);
772
- }, [setVerticalPaneSizes]);
773
- const handleDiagnosticSelected = useCallback((diagnostic) => {
774
- editorRef.current?.setSelection(getMonacoRange(host.compiler, diagnostic.target));
775
- }, [setVerticalPaneSizes]);
776
- return (jsx(PlaygroundContextProvider, { value: { host }, children: jsxs("div", { className: style$4["layout"], children: [jsxs(SplitPane, { sizes: verticalPaneSizes, onChange: onVerticalPaneSizeChange, split: "horizontal", children: [jsx(Pane, { children: jsxs(SplitPane, { initialSizes: ["50%", "50%"], children: [jsxs(Pane, { children: [jsx(EditorCommandBar, { host: host, selectedEmitter: selectedEmitter, onSelectedEmitterChange: onSelectedEmitterChange, compilerOptions: compilerOptions, onCompilerOptionsChange: onCompilerOptionsChange, samples: props.samples, selectedSampleName: selectedSampleName, onSelectedSampleNameChange: onSelectedSampleNameChange, saveCode: saveCode, formatCode: formatCode, fileBug: props.onFileBug ? fileBug : undefined, documentationUrl: props.links?.documentationUrl }), jsx(TypeSpecEditor, { model: typespecModel, actions: typespecEditorActions, options: props.editorOptions, onMount: onTypeSpecEditorMount })] }), jsx(Pane, { children: jsx(OutputView, { compilationState: compilationState, editorOptions: props.editorOptions, viewers: props.emitterViewers?.[selectedEmitter] }) })] }) }), jsx(Pane, { minSize: 30, children: jsx(ProblemPane, { collapsed: verticalPaneSizes[1] === verticalPaneSizesConst.collapsed[1], compilationState: compilationState, onHeaderClick: toggleProblemPane, onDiagnosticSelected: handleDiagnosticSelected }) })] }), props.footer ?? jsx(DefaultFooter, {})] }) }));
1406
+ ) })
1407
+ ] }),
1408
+ props.footer ?? /* @__PURE__ */ jsx(DefaultFooter, {})
1409
+ ] }) });
777
1410
  };
778
1411
  const verticalPaneSizesConst = {
779
- collapsed: [undefined, 30],
780
- expanded: [undefined, 200],
1412
+ collapsed: [void 0, 30],
1413
+ expanded: [void 0, 200]
781
1414
  };
782
1415
  const outputDir = "./tsp-output";
783
1416
  async function compile(host, content, selectedEmitter, options) {
784
- await host.writeFile("main.tsp", content);
785
- await emptyOutputDir(host);
786
- try {
787
- const typespecCompiler = host.compiler;
788
- const program = await typespecCompiler.compile(host, "main.tsp", {
789
- ...options,
790
- options: {
791
- ...options.options,
792
- [selectedEmitter]: {
793
- ...options.options?.[selectedEmitter],
794
- "emitter-output-dir": "tsp-output",
795
- },
796
- },
797
- outputDir: "tsp-output",
798
- emit: [selectedEmitter],
799
- });
800
- const outputFiles = await findOutputFiles(host);
801
- return { program, outputFiles };
802
- }
803
- catch (error) {
804
- // eslint-disable-next-line no-console
805
- console.error("Internal compiler error", error);
806
- return { internalCompilerError: error };
807
- }
1417
+ await host.writeFile("main.tsp", content);
1418
+ await emptyOutputDir(host);
1419
+ try {
1420
+ const typespecCompiler = host.compiler;
1421
+ const program = await typespecCompiler.compile(host, "main.tsp", {
1422
+ ...options,
1423
+ options: {
1424
+ ...options.options,
1425
+ [selectedEmitter]: {
1426
+ ...options.options?.[selectedEmitter],
1427
+ "emitter-output-dir": "tsp-output"
1428
+ }
1429
+ },
1430
+ outputDir: "tsp-output",
1431
+ emit: selectedEmitter ? [selectedEmitter] : []
1432
+ });
1433
+ const outputFiles = await findOutputFiles(host);
1434
+ return { program, outputFiles };
1435
+ } catch (error) {
1436
+ console.error("Internal compiler error", error);
1437
+ return { internalCompilerError: error };
1438
+ }
808
1439
  }
809
1440
  async function findOutputFiles(host) {
810
- const files = [];
811
- async function addFiles(dir) {
812
- const items = await host.readDir(outputDir + dir);
813
- for (const item of items) {
814
- const itemPath = `${dir}/${item}`;
815
- if ((await host.stat(outputDir + itemPath)).isDirectory()) {
816
- await addFiles(itemPath);
817
- }
818
- else {
819
- files.push(dir === "" ? item : `${dir}/${item}`);
820
- }
821
- }
1441
+ const files = [];
1442
+ async function addFiles(dir) {
1443
+ const items = await host.readDir(outputDir + dir);
1444
+ for (const item of items) {
1445
+ const itemPath = `${dir}/${item}`;
1446
+ if ((await host.stat(outputDir + itemPath)).isDirectory()) {
1447
+ await addFiles(itemPath);
1448
+ } else {
1449
+ files.push(dir === "" ? item : `${dir}/${item}`);
1450
+ }
822
1451
  }
823
- await addFiles("");
824
- return files;
1452
+ }
1453
+ await addFiles("");
1454
+ return files;
825
1455
  }
826
1456
  async function emptyOutputDir(host) {
827
- // empty output directory
828
- const dirs = await host.readDir("./tsp-output");
829
- for (const file of dirs) {
830
- const path = "./tsp-output/" + file;
831
- const uri = Uri.parse(host.pathToFileURL(path));
832
- const model = editor.getModel(uri);
833
- if (model) {
834
- model.dispose();
835
- }
836
- await host.rm(path, { recursive: true });
1457
+ const dirs = await host.readDir("./tsp-output");
1458
+ for (const file of dirs) {
1459
+ const path = "./tsp-output/" + file;
1460
+ const uri = Uri.parse(host.pathToFileURL(path));
1461
+ const model = editor.getModel(uri);
1462
+ if (model) {
1463
+ model.dispose();
837
1464
  }
1465
+ await host.rm(path, { recursive: true });
1466
+ }
838
1467
  }
839
1468
 
840
1469
  function useStandalonePlaygroundContext(config) {
841
- const [context, setContext] = useState();
842
- useEffect(() => {
843
- const load = async () => {
844
- const host = await createBrowserHost(config.libraries, config.importConfig);
845
- await registerMonacoLanguage(host);
846
- const stateStorage = createStandalonePlaygroundStateStorage();
847
- const initialState = stateStorage.load();
848
- setContext({ host, initialState, stateStorage });
849
- };
850
- void load();
851
- }, []);
852
- return context;
1470
+ const [context, setContext] = useState();
1471
+ useEffect(() => {
1472
+ const load = async () => {
1473
+ const host = await createBrowserHost(config.libraries, config.importConfig);
1474
+ await registerMonacoLanguage(host);
1475
+ const stateStorage = createStandalonePlaygroundStateStorage();
1476
+ const initialState = stateStorage.load();
1477
+ setContext({ host, initialState, stateStorage });
1478
+ };
1479
+ void load();
1480
+ }, []);
1481
+ return context;
853
1482
  }
854
1483
  const StandalonePlayground = (config) => {
855
- const context = useStandalonePlaygroundContext(config);
856
- const toasterId = useId$1();
857
- const { dispatchToast } = useToastController(toasterId);
858
- const onSave = useCallback((value) => {
859
- if (!context) {
860
- return;
861
- }
862
- context.stateStorage.save(value);
863
- void navigator.clipboard.writeText(window.location.toString());
864
- dispatchToast(jsxs(Toast, { children: [jsx(ToastTitle, { children: "Saved!" }), jsx(ToastBody, { children: "Playground link has been copied to the clipboard." })] }), { intent: "success" });
865
- }, [dispatchToast, context]);
866
- const fixedOptions = useMemo(() => context && {
867
- host: context.host,
868
- libraries: config.libraries,
869
- defaultContent: context.initialState.content,
870
- defaultEmitter: context.initialState.emitter ?? config.defaultEmitter,
871
- defaultCompilerOptions: context.initialState.options,
872
- defaultSampleName: context.initialState.sampleName,
873
- }, [context]);
874
- if (context === undefined || fixedOptions === undefined) {
875
- return config.fallback;
876
- }
877
- const options = {
878
- ...config,
879
- ...fixedOptions,
880
- onSave,
881
- };
882
- return (jsxs(Fragment, { children: [jsx(Toaster, { toasterId: toasterId }), options && jsx(Playground, { ...options })] }));
1484
+ const context = useStandalonePlaygroundContext(config);
1485
+ const toasterId = useId$1();
1486
+ const { dispatchToast } = useToastController(toasterId);
1487
+ const onSave = useCallback(
1488
+ (value) => {
1489
+ if (!context) {
1490
+ return;
1491
+ }
1492
+ context.stateStorage.save(value);
1493
+ void navigator.clipboard.writeText(window.location.toString());
1494
+ dispatchToast(
1495
+ /* @__PURE__ */ jsxs(Toast, { children: [
1496
+ /* @__PURE__ */ jsx(ToastTitle, { children: "Saved!" }),
1497
+ /* @__PURE__ */ jsx(ToastBody, { children: "Playground link has been copied to the clipboard." })
1498
+ ] }),
1499
+ { intent: "success" }
1500
+ );
1501
+ },
1502
+ [dispatchToast, context]
1503
+ );
1504
+ const fixedOptions = useMemo(
1505
+ () => context && {
1506
+ host: context.host,
1507
+ libraries: config.libraries,
1508
+ defaultContent: context.initialState.content,
1509
+ defaultEmitter: context.initialState.emitter ?? config.defaultEmitter,
1510
+ defaultCompilerOptions: context.initialState.options,
1511
+ defaultSampleName: context.initialState.sampleName
1512
+ },
1513
+ [context]
1514
+ );
1515
+ if (context === void 0 || fixedOptions === void 0) {
1516
+ return config.fallback;
1517
+ }
1518
+ const options = {
1519
+ ...config,
1520
+ ...fixedOptions,
1521
+ onSave
1522
+ };
1523
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1524
+ /* @__PURE__ */ jsx(Toaster, { toasterId }),
1525
+ options && /* @__PURE__ */ jsx(Playground, { ...options })
1526
+ ] });
883
1527
  };
884
1528
  async function createReactPlayground(config) {
885
- return jsx(StandalonePlayground, { ...config });
1529
+ return /* @__PURE__ */ jsx(StandalonePlayground, { ...config });
886
1530
  }
887
1531
  async function renderReactPlayground(config) {
888
- const app = await createReactPlayground(config);
889
- const root = createRoot(document.getElementById("root"));
890
- root.render(jsx(FluentProvider, { theme: webLightTheme, style: { height: "100vh" }, children: app }));
1532
+ const app = await createReactPlayground(config);
1533
+ const root = createRoot(document.getElementById("root"));
1534
+ root.render(
1535
+ /* @__PURE__ */ jsx(FluentProvider, { theme: webLightTheme, style: { height: "100vh" }, children: app })
1536
+ );
891
1537
  }
892
1538
  function createStandalonePlaygroundStateStorage() {
893
- const stateStorage = createUrlStateStorage({
894
- content: {
895
- queryParam: "c",
896
- compress: "lz-base64",
897
- },
898
- emitter: {
899
- queryParam: "e",
900
- },
901
- options: {
902
- type: "object",
903
- queryParam: "options",
904
- },
905
- sampleName: {
906
- queryParam: "sample",
907
- },
908
- });
909
- return {
910
- load: stateStorage.load,
911
- resolveSearchParams: stateStorage.resolveSearchParams,
912
- save(data) {
913
- stateStorage.save(data.sampleName ? { sampleName: data.sampleName, options: data.options } : data);
914
- },
915
- };
1539
+ const stateStorage = createUrlStateStorage({
1540
+ content: {
1541
+ queryParam: "c",
1542
+ compress: "lz-base64"
1543
+ },
1544
+ emitter: {
1545
+ queryParam: "e"
1546
+ },
1547
+ options: {
1548
+ type: "object",
1549
+ queryParam: "options"
1550
+ },
1551
+ sampleName: {
1552
+ queryParam: "sample"
1553
+ }
1554
+ });
1555
+ return {
1556
+ load: stateStorage.load,
1557
+ resolveSearchParams: stateStorage.resolveSearchParams,
1558
+ save(data) {
1559
+ stateStorage.save(
1560
+ data.sampleName ? { sampleName: data.sampleName, options: data.options } : data
1561
+ );
1562
+ }
1563
+ };
916
1564
  }
917
1565
 
918
1566
  export { Footer, FooterItem, FooterVersionItem, Playground, StandalonePlayground, createReactPlayground, createStandalonePlaygroundStateStorage, renderReactPlayground, usePlaygroundContext };
919
- //# sourceMappingURL=index.js.map