@typespec/playground 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.css CHANGED
@@ -145,25 +145,6 @@
145
145
  overflow: hidden;
146
146
  }
147
147
 
148
- .problem-pane-module_problem-pane__GJKF4 {
149
- height: 100%;
150
- background-color: var(--colorNeutralBackground3);
151
- display: flex;
152
- flex-direction: column;
153
- max-height: 100%;
154
- }
155
-
156
- .problem-pane-module_problem-content__rYzbh {
157
- overflow-y: auto;
158
- }
159
- .problem-pane-module_no-problems__Ub8R- {
160
- padding: 10px;
161
- }
162
-
163
- .problem-pane-module_internal-compiler-error__laE4f {
164
- padding: 10px;
165
- }
166
-
167
148
  .file-output-module_file-output__YBaE7 {
168
149
  position: relative;
169
150
  height: 100%;
@@ -195,34 +176,23 @@
195
176
  background-color: var(--colorNeutralBackground5) !important;
196
177
  }
197
178
 
198
- .diagnostic-list-module_list__6tVpz {
199
- }
200
-
201
- .diagnostic-list-module_item__BE8Fr {
202
- cursor: pointer;
179
+ .problem-pane-module_problem-pane__GJKF4 {
180
+ height: 100%;
181
+ background-color: var(--colorNeutralBackground3);
203
182
  display: flex;
204
- gap: 10px;
205
- padding: 0 10px;
206
- }
207
-
208
- .diagnostic-list-module_item__BE8Fr:hover {
209
- background-color: var(--colorNeutralBackground3Hover);
210
- }
211
-
212
- .diagnostic-list-module_item--error__tnhWA {
213
- color: var(--colorStatusDangerForeground1);
183
+ flex-direction: column;
184
+ max-height: 100%;
214
185
  }
215
186
 
216
- .diagnostic-list-module_item--warning__J7vIN {
217
- color: var(--colorStatusWarningForeground1);
187
+ .problem-pane-module_problem-content__rYzbh {
188
+ overflow-y: auto;
218
189
  }
219
-
220
- .diagnostic-list-module_item-code__AgVjZ {
221
- color: var(--colorBrandForeground2);
190
+ .problem-pane-module_no-problems__Ub8R- {
191
+ padding: 10px;
222
192
  }
223
193
 
224
- .diagnostic-list-module_item-loc__IeYnW {
225
- color: var(--colorNeutralForeground3);
194
+ .problem-pane-module_internal-compiler-error__laE4f {
195
+ padding: 10px;
226
196
  }
227
197
 
228
198
  .header-module_header__LyUNg {
@@ -267,6 +237,36 @@
267
237
  transform: rotate(90deg);
268
238
  }
269
239
 
240
+ .diagnostic-list-module_list__6tVpz {
241
+ }
242
+
243
+ .diagnostic-list-module_item__BE8Fr {
244
+ cursor: pointer;
245
+ display: flex;
246
+ gap: 10px;
247
+ padding: 0 10px;
248
+ }
249
+
250
+ .diagnostic-list-module_item__BE8Fr:hover {
251
+ background-color: var(--colorNeutralBackground3Hover);
252
+ }
253
+
254
+ .diagnostic-list-module_item--error__tnhWA {
255
+ color: var(--colorStatusDangerForeground1);
256
+ }
257
+
258
+ .diagnostic-list-module_item--warning__J7vIN {
259
+ color: var(--colorStatusWarningForeground1);
260
+ }
261
+
262
+ .diagnostic-list-module_item-code__AgVjZ {
263
+ color: var(--colorBrandForeground2);
264
+ }
265
+
266
+ .diagnostic-list-module_item-loc__IeYnW {
267
+ color: var(--colorNeutralForeground3);
268
+ }
269
+
270
270
  .emitter-options-form-module_form__dm2RP {
271
271
  display: flex;
272
272
  flex-direction: column;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createBrowserHost, a as createUrlStateStorage, r as registerMonacoLanguage } from './state-storage-C_Vk3Rrw.js';
1
+ export { c as createBrowserHost, a as createUrlStateStorage, r as registerMonacoLanguage } from './state-storage-BuvyP4WR.js';
2
2
  import '@typespec/compiler';
3
3
  import 'monaco-editor';
4
4
  import 'vscode-languageserver';
@@ -5,7 +5,7 @@ import debounce from 'debounce';
5
5
  import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
6
6
  import { CompletionItemTag } from 'vscode-languageserver';
7
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-C_Vk3Rrw.js';
8
+ import { g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage, a as createUrlStateStorage } from '../state-storage-BuvyP4WR.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';
@@ -32,10 +32,9 @@ const FooterItem = ({ children, link, className }) => {
32
32
  var style$a = {"version-item":"footer-version-item-module_version-item__pjuvV","button":"footer-version-item-module_button__70iqf"};
33
33
 
34
34
  const FooterVersionItem = memo(({ versionSelector }) => {
35
- var _a;
36
35
  const { host } = usePlaygroundContext();
37
- const latest = versionSelector === null || versionSelector === void 0 ? void 0 : versionSelector.latest;
38
- const selected = (_a = versionSelector === null || versionSelector === void 0 ? void 0 : versionSelector.selected) !== null && _a !== void 0 ? _a : host.compiler.MANIFEST.version;
36
+ const latest = versionSelector?.latest;
37
+ const selected = versionSelector?.selected ?? host.compiler.MANIFEST.version;
39
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 }) })] }) }));
40
39
  });
41
40
  const VersionsPopup = memo(({ versionSelector }) => {
@@ -76,14 +75,13 @@ const SamplesDropdown = ({ samples, selectedSampleName, onSelectedSampleNameChan
76
75
  onSelectedSampleNameChange(evt.target.value);
77
76
  }
78
77
  }, [onSelectedSampleNameChange]);
79
- return (jsxs(Select, { className: "sample-dropdown", onChange: handleSelected, value: selectedSampleName !== null && selectedSampleName !== void 0 ? selectedSampleName : "", "aria-label": "Select a sample", children: [jsx("option", { value: "", disabled: true, children: "Select sample..." }), options] }));
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] }));
80
79
  };
81
80
 
82
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"};
83
82
 
84
83
  const EmitterOptionsForm = ({ library, options, optionsChanged, }) => {
85
- var _a, _b, _c;
86
- const emitterOptionsSchema = (_c = (_b = (_a = library.definition) === null || _a === void 0 ? void 0 : _a.emitter) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.properties;
84
+ const emitterOptionsSchema = library.definition?.emitter?.options?.properties;
87
85
  if (emitterOptionsSchema === undefined) {
88
86
  return jsx(Fragment, { children: "\"No options\"" });
89
87
  }
@@ -98,15 +96,13 @@ const EmitterOptionsForm = ({ library, options, optionsChanged, }) => {
98
96
  });
99
97
  }, [options, optionsChanged]);
100
98
  return (jsx("div", { className: style$9["form"], children: entries.map(([key, value]) => {
101
- var _a;
102
- return (jsx("div", { className: style$9["form-item"], children: jsx(JsonSchemaPropertyInput, { emitterOptions: (_a = options[library.name]) !== null && _a !== void 0 ? _a : {}, name: key, prop: value, onChange: handleChange }) }, key));
99
+ return (jsx("div", { className: style$9["form-item"], children: jsx(JsonSchemaPropertyInput, { emitterOptions: options[library.name] ?? {}, name: key, prop: value, onChange: handleChange }) }, key));
103
100
  }) }));
104
101
  };
105
102
  const JsonSchemaPropertyInput = ({ emitterOptions, name, prop, onChange, }) => {
106
- var _a;
107
103
  const prettyName = useMemo(() => name[0].toUpperCase() + name.slice(1).replace(/-/g, " "), [name]);
108
104
  const inputId = useId("input");
109
- const value = (_a = emitterOptions[name]) !== null && _a !== void 0 ? _a : prop.default;
105
+ const value = emitterOptions[name] ?? prop.default;
110
106
  const handleChange = useCallback((_, data) => onChange({ name, value: "value" in data ? data.value : data.checked }), [onChange]);
111
107
  switch (prop.type) {
112
108
  case "boolean":
@@ -119,17 +115,15 @@ const JsonSchemaPropertyInput = ({ emitterOptions, name, prop, onChange, }) => {
119
115
 
120
116
  const LinterForm = ({ libraries, linterRuleSet, onLinterRuleSetChanged, }) => {
121
117
  const rulesets = Object.values(libraries).flatMap((lib) => {
122
- var _a, _b, _c;
123
118
  // eslint-disable-next-line deprecation/deprecation
124
- const linter = (_a = lib.linter) !== null && _a !== void 0 ? _a : (_b = lib.definition) === null || _b === void 0 ? void 0 : _b.linter;
125
- return Object.keys((_c = linter === null || linter === void 0 ? void 0 : linter.ruleSets) !== null && _c !== void 0 ? _c : {}).map((x) => `${lib.name}/${x}`);
119
+ const linter = lib.linter ?? lib.definition?.linter;
120
+ return Object.keys(linter?.ruleSets ?? {}).map((x) => `${lib.name}/${x}`);
126
121
  });
127
122
  if (rulesets.length === 0) {
128
123
  return jsx(Fragment, { children: "No ruleset available" });
129
124
  }
130
125
  const handleChange = (ruleSet, checked) => {
131
- var _a;
132
- const ruleSets = (_a = linterRuleSet.extends) !== null && _a !== void 0 ? _a : [];
126
+ const ruleSets = linterRuleSet.extends ?? [];
133
127
  const updatedRuleSets = checked
134
128
  ? [...ruleSets, ruleSet]
135
129
  : ruleSets.filter((x) => x !== ruleSet);
@@ -138,8 +132,7 @@ const LinterForm = ({ libraries, linterRuleSet, onLinterRuleSetChanged, }) => {
138
132
  });
139
133
  };
140
134
  return (jsx(Fragment, { children: rulesets.map((ruleSet) => {
141
- var _a;
142
- return (jsx(RuleSetCheckbox, { ruleSet: ruleSet, checked: (_a = linterRuleSet.extends) === null || _a === void 0 ? void 0 : _a.includes(ruleSet), onChange: handleChange }, ruleSet));
135
+ return (jsx(RuleSetCheckbox, { ruleSet: ruleSet, checked: linterRuleSet.extends?.includes(ruleSet), onChange: handleChange }, ruleSet));
143
136
  }) }));
144
137
  };
145
138
  const RuleSetCheckbox = ({ ruleSet, checked, onChange }) => {
@@ -150,7 +143,6 @@ const RuleSetCheckbox = ({ ruleSet, checked, onChange }) => {
150
143
  };
151
144
 
152
145
  const CompilerSettings = ({ selectedEmitter, host, options, onOptionsChanged, }) => {
153
- var _a, _b;
154
146
  const emitterOptionsChanged = useCallback((emitterOptions) => {
155
147
  onOptionsChanged({
156
148
  ...options,
@@ -158,14 +150,14 @@ const CompilerSettings = ({ selectedEmitter, host, options, onOptionsChanged, })
158
150
  });
159
151
  }, [options]);
160
152
  const library = host.libraries[selectedEmitter];
161
- const linterRuleSet = (_a = options.linterRuleSet) !== null && _a !== void 0 ? _a : {};
153
+ const linterRuleSet = options.linterRuleSet ?? {};
162
154
  const linterRuleSetChanged = useCallback((linterRuleSet) => {
163
155
  onOptionsChanged({
164
156
  ...options,
165
157
  linterRuleSet,
166
158
  });
167
159
  }, [options]);
168
- return (jsxs("div", { children: [jsxs(Fragment, { children: ["Emitter: ", selectedEmitter] }), jsx(Divider, { style: { marginTop: 20 } }), jsx("h3", { children: "Options" }), library && (jsx(EmitterOptionsForm, { library: library, options: (_b = options.options) !== null && _b !== void 0 ? _b : {}, optionsChanged: emitterOptionsChanged })), jsx(Divider, { style: { marginTop: 20 } }), jsx("h3", { children: "Linter" }), jsx(LinterForm, { libraries: host.libraries, linterRuleSet: linterRuleSet, onLinterRuleSetChanged: linterRuleSetChanged })] }));
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 })] }));
169
161
  };
170
162
 
171
163
  const CompilerSettingsDialogButton = ({ selectedEmitter, compilerOptions, onCompilerOptionsChange, }) => {
@@ -200,15 +192,14 @@ const Editor = ({ model, options, actions, onMount }) => {
200
192
  automaticLayout: true,
201
193
  ...options,
202
194
  });
203
- onMount === null || onMount === void 0 ? void 0 : onMount({ editor: editorRef.current });
195
+ onMount?.({ editor: editorRef.current });
204
196
  }, []);
205
197
  useEffect(() => {
206
- var _a;
207
- editor.setTheme((_a = options.theme) !== null && _a !== void 0 ? _a : "typespec");
198
+ editor.setTheme(options.theme ?? "typespec");
208
199
  }, [options.theme]);
209
200
  useEffect(() => {
210
201
  const disposables = [];
211
- for (const command of actions !== null && actions !== void 0 ? actions : []) {
202
+ for (const command of actions ?? []) {
212
203
  disposables.push(editorRef.current.addAction(command));
213
204
  }
214
205
  return () => {
@@ -225,9 +216,8 @@ const Editor = ({ model, options, actions, onMount }) => {
225
216
  };
226
217
  function useMonacoModel(uri, language) {
227
218
  return useMemo(() => {
228
- var _a;
229
219
  const monacoUri = Uri.parse(uri);
230
- return (_a = editor.getModel(monacoUri)) !== null && _a !== void 0 ? _a : editor.createModel("", language, monacoUri);
220
+ return editor.getModel(monacoUri) ?? editor.createModel("", language, monacoUri);
231
221
  }, [uri, language]);
232
222
  }
233
223
 
@@ -297,8 +287,7 @@ const FileOutput = ({ filename, content, viewers }) => {
297
287
  setSelected(data.value);
298
288
  }, [selected]);
299
289
  const selectedRender = useMemo(() => {
300
- var _a;
301
- return (_a = viewers.find((x) => x.key === selected)) === null || _a === void 0 ? void 0 : _a.render;
290
+ return viewers.find((x) => x.key === selected)?.render;
302
291
  }, [selected, viewers]);
303
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 })] }));
304
293
  };
@@ -384,7 +373,7 @@ const OutputViewInternal = ({ compilationResult, viewers, editorOptions }) => {
384
373
  if (viewSelection.type === "file") {
385
374
  if (outputFiles.length > 0) {
386
375
  const fileStillThere = outputFiles.find((x) => x === viewSelection.filename);
387
- void loadOutputFile(fileStillThere !== null && fileStillThere !== void 0 ? fileStillThere : outputFiles[0]);
376
+ void loadOutputFile(fileStillThere ?? outputFiles[0]);
388
377
  }
389
378
  else {
390
379
  setViewSelection({ type: "file", filename: viewSelection.filename, content: "" });
@@ -424,7 +413,7 @@ function getRawFileViewer(editorOptions) {
424
413
  };
425
414
  }
426
415
  const OutputContent = ({ viewSelection, program, viewers, editorOptions, }) => {
427
- const resolvedViewers = useMemo(() => [getRawFileViewer(editorOptions), ...(viewers !== null && viewers !== void 0 ? viewers : [])], [viewers]);
416
+ const resolvedViewers = useMemo(() => [getRawFileViewer(editorOptions), ...(viewers ?? [])], [viewers]);
428
417
  switch (viewSelection.type) {
429
418
  case "file":
430
419
  return (jsx(FileOutput, { filename: viewSelection.filename, content: viewSelection.content, viewers: resolvedViewers }));
@@ -455,7 +444,7 @@ const DiagnosticList = ({ diagnostics, onDiagnosticSelected, }) => {
455
444
  return jsx("div", { className: style$3["list"], children: "No errors" });
456
445
  }
457
446
  const handleItemSelected = useCallback((diagnostic) => {
458
- onDiagnosticSelected === null || onDiagnosticSelected === void 0 ? void 0 : onDiagnosticSelected(diagnostic);
447
+ onDiagnosticSelected?.(diagnostic);
459
448
  }, [onDiagnosticSelected]);
460
449
  return (jsx("div", { className: style$3["list"], children: diagnostics.map((x, i) => {
461
450
  return jsx(DiagnosticItem, { diagnostic: x, onItemSelected: handleItemSelected }, i);
@@ -546,7 +535,6 @@ const Sash = ({ className, render, onDragStart, onDragging, onDragEnd, onReset,
546
535
  };
547
536
 
548
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 }) => {
549
- var _a;
550
538
  const [resolvedPropSize, updateSizes] = useControllableValue(propSizes, defaultSizes, onChange);
551
539
  const axis = useRef({ x: 0, y: 0 });
552
540
  const wrapper = useRef(null);
@@ -555,8 +543,7 @@ const SplitPane = ({ children, sizes: propSizes, initialSizes: defaultSizes, all
555
543
  const [isDragging, setDragging] = useState(false);
556
544
  useEffect(() => {
557
545
  const resizeObserver = new ResizeObserver(() => {
558
- var _a, _b;
559
- setWrapperRect((_b = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : {});
546
+ setWrapperRect(wrapper?.current?.getBoundingClientRect() ?? {});
560
547
  });
561
548
  resizeObserver.observe(wrapper.current);
562
549
  return () => {
@@ -568,11 +555,11 @@ const SplitPane = ({ children, sizes: propSizes, initialSizes: defaultSizes, all
568
555
  splitPos: split === "vertical" ? "left" : "top",
569
556
  splitAxis: split === "vertical" ? "x" : "y",
570
557
  }), [split]);
571
- const wrapSize = (_a = wrapperRect[sizeName]) !== null && _a !== void 0 ? _a : 0;
558
+ const wrapSize = wrapperRect[sizeName] ?? 0;
572
559
  // Get limit sizes via children
573
560
  const paneLimitSizes = useMemo(() => children.map((childNode) => {
574
561
  const limits = [0, Infinity];
575
- if ((childNode === null || childNode === void 0 ? void 0 : childNode.type) === Pane) {
562
+ if (childNode?.type === Pane) {
576
563
  const { minSize, maxSize } = childNode.props;
577
564
  limits[0] = assertsSize(minSize, wrapSize, 0);
578
565
  limits[1] = assertsSize(maxSize, wrapSize);
@@ -604,8 +591,7 @@ const SplitPane = ({ children, sizes: propSizes, initialSizes: defaultSizes, all
604
591
  }, [...resolvedPropSize, children.length, wrapSize]);
605
592
  const sashPosSizes = useMemo(() => sizes.reduce((a, b) => [...a, a[a.length - 1] + b], [0]), [...sizes]);
606
593
  const dragStart = useCallback((e) => {
607
- var _a, _b;
608
- (_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add(style["split-disabled"]);
594
+ document?.body?.classList?.add(style["split-disabled"]);
609
595
  axis.current = { x: e.pageX, y: e.pageY };
610
596
  cacheSizes.current = { sizes, sashPosSizes };
611
597
  setDragging(true);
@@ -617,8 +603,7 @@ const SplitPane = ({ children, sizes: propSizes, initialSizes: defaultSizes, all
617
603
  }
618
604
  }, [defaultSizes, updateSizes]);
619
605
  const dragEnd = useCallback((e) => {
620
- var _a, _b;
621
- (_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove(style["split-disabled"]);
606
+ document?.body?.classList?.remove(style["split-disabled"]);
622
607
  axis.current = { x: e.pageX, y: e.pageY };
623
608
  cacheSizes.current = { sizes, sashPosSizes };
624
609
  setDragging(false);
@@ -678,16 +663,14 @@ function assertsSize(size, sum, defaultValue = Infinity) {
678
663
  }
679
664
 
680
665
  const Playground = (props) => {
681
- var _a, _b, _c, _d;
682
666
  const { host, onSave } = props;
683
667
  const editorRef = useRef(undefined);
684
668
  const [selectedEmitter, onSelectedEmitterChange] = useControllableValue(props.emitter, props.defaultEmitter, props.onEmitterChange);
685
- const [compilerOptions, onCompilerOptionsChange] = useControllableValue(props.compilerOptions, (_a = props.defaultCompilerOptions) !== null && _a !== void 0 ? _a : {}, props.onCompilerOptionsChange);
669
+ const [compilerOptions, onCompilerOptionsChange] = useControllableValue(props.compilerOptions, props.defaultCompilerOptions ?? {}, props.onCompilerOptionsChange);
686
670
  const [selectedSampleName, onSelectedSampleNameChange] = useControllableValue(props.sampleName, props.defaultSampleName, props.onSampleNameChange);
687
671
  const [content, setContent] = useState(props.defaultContent);
688
672
  const isSampleUntouched = useMemo(() => {
689
- var _a, _b;
690
- return Boolean(selectedSampleName && content === ((_b = (_a = props.samples) === null || _a === void 0 ? void 0 : _a[selectedSampleName]) === null || _b === void 0 ? void 0 : _b.content));
673
+ return Boolean(selectedSampleName && content === props.samples?.[selectedSampleName]?.content);
691
674
  }, [content, selectedSampleName, props.samples]);
692
675
  const typespecModel = useMonacoModel("inmemory://test/main.tsp", "typespec");
693
676
  const [compilationState, setCompilationState] = useState(undefined);
@@ -704,7 +687,7 @@ const Playground = (props) => {
704
687
  severity: diag.severity === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning,
705
688
  tags: diag.code === "deprecated" ? [CompletionItemTag.Deprecated] : undefined,
706
689
  }));
707
- editor.setModelMarkers(typespecModel, "owner", markers !== null && markers !== void 0 ? markers : []);
690
+ editor.setModelMarkers(typespecModel, "owner", markers ?? []);
708
691
  }
709
692
  else {
710
693
  editor.setModelMarkers(typespecModel, "owner", []);
@@ -716,8 +699,7 @@ const Playground = (props) => {
716
699
  }
717
700
  }, [typespecModel]);
718
701
  useEffect(() => {
719
- var _a;
720
- updateTypeSpec((_a = props.defaultContent) !== null && _a !== void 0 ? _a : "");
702
+ updateTypeSpec(props.defaultContent ?? "");
721
703
  }, []);
722
704
  useEffect(() => {
723
705
  if (selectedSampleName && props.samples) {
@@ -762,8 +744,7 @@ const Playground = (props) => {
762
744
  isSampleUntouched,
763
745
  ]);
764
746
  const formatCode = useCallback(() => {
765
- var _a, _b;
766
- void ((_b = (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.getAction("editor.action.formatDocument")) === null || _b === void 0 ? void 0 : _b.run());
747
+ void editorRef.current?.getAction("editor.action.formatDocument")?.run();
767
748
  }, [typespecModel]);
768
749
  const fileBug = useCallback(async () => {
769
750
  if (props.onFileBug) {
@@ -790,10 +771,9 @@ const Playground = (props) => {
790
771
  setVerticalPaneSizes(sizes);
791
772
  }, [setVerticalPaneSizes]);
792
773
  const handleDiagnosticSelected = useCallback((diagnostic) => {
793
- var _a;
794
- (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.setSelection(getMonacoRange(host.compiler, diagnostic.target));
774
+ editorRef.current?.setSelection(getMonacoRange(host.compiler, diagnostic.target));
795
775
  }, [setVerticalPaneSizes]);
796
- 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: (_b = props.links) === null || _b === void 0 ? void 0 : _b.documentationUrl }), jsx(TypeSpecEditor, { model: typespecModel, actions: typespecEditorActions, options: props.editorOptions, onMount: onTypeSpecEditorMount })] }), jsx(Pane, { children: jsx(OutputView, { compilationState: compilationState, editorOptions: props.editorOptions, viewers: (_c = props.emitterViewers) === null || _c === void 0 ? void 0 : _c[selectedEmitter] }) })] }) }), jsx(Pane, { minSize: 30, children: jsx(ProblemPane, { collapsed: verticalPaneSizes[1] === verticalPaneSizesConst.collapsed[1], compilationState: compilationState, onHeaderClick: toggleProblemPane, onDiagnosticSelected: handleDiagnosticSelected }) })] }), (_d = props.footer) !== null && _d !== void 0 ? _d : jsx(DefaultFooter, {})] }) }));
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, {})] }) }));
797
777
  };
798
778
  const verticalPaneSizesConst = {
799
779
  collapsed: [undefined, 30],
@@ -801,7 +781,6 @@ const verticalPaneSizesConst = {
801
781
  };
802
782
  const outputDir = "./tsp-output";
803
783
  async function compile(host, content, selectedEmitter, options) {
804
- var _a;
805
784
  await host.writeFile("main.tsp", content);
806
785
  await emptyOutputDir(host);
807
786
  try {
@@ -811,7 +790,7 @@ async function compile(host, content, selectedEmitter, options) {
811
790
  options: {
812
791
  ...options.options,
813
792
  [selectedEmitter]: {
814
- ...(_a = options.options) === null || _a === void 0 ? void 0 : _a[selectedEmitter],
793
+ ...options.options?.[selectedEmitter],
815
794
  "emitter-output-dir": "tsp-output",
816
795
  },
817
796
  },
@@ -884,16 +863,13 @@ const StandalonePlayground = (config) => {
884
863
  void navigator.clipboard.writeText(window.location.toString());
885
864
  dispatchToast(jsxs(Toast, { children: [jsx(ToastTitle, { children: "Saved!" }), jsx(ToastBody, { children: "Playground link has been copied to the clipboard." })] }), { intent: "success" });
886
865
  }, [dispatchToast, context]);
887
- const fixedOptions = useMemo(() => {
888
- var _a;
889
- return context && {
890
- host: context.host,
891
- libraries: config.libraries,
892
- defaultContent: context.initialState.content,
893
- defaultEmitter: (_a = context.initialState.emitter) !== null && _a !== void 0 ? _a : config.defaultEmitter,
894
- defaultCompilerOptions: context.initialState.options,
895
- defaultSampleName: context.initialState.sampleName,
896
- };
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,
897
873
  }, [context]);
898
874
  if (context === undefined || fixedOptions === undefined) {
899
875
  return config.fallback;